From e0379e2b275ee1c7fb8d6f7a8b5cd10b39f65502 Mon Sep 17 00:00:00 2001 From: stbachinger <87909808+stbachinger@users.noreply.github.com> Date: Tue, 21 Sep 2021 17:12:39 +0200 Subject: [PATCH 1/5] Working version without plot reordering --- .../error_norms_convergence_plots.sh | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 tools/processing/error_norms_convergence_plots.sh diff --git a/tools/processing/error_norms_convergence_plots.sh b/tools/processing/error_norms_convergence_plots.sh new file mode 100644 index 00000000..36f57ca4 --- /dev/null +++ b/tools/processing/error_norms_convergence_plots.sh @@ -0,0 +1,117 @@ +#!/bin/bash +## +# @file This file is part of EDGE. +# +# @author Sarah Bachinger (sarah.bachinger AT uni-jena.de) +# +# @section LICENSE +# Copyright (c) 2020, Friedrich Schiller University Jena +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# @section DESCRIPTION +# A script to generate convergence plots from the error norms of an EDGE computation. +# Identifies error norms in xml files and extracts them for plotting according to the error norm. +# The extracted files and the plots will be placed inside a "plots" folder in the same directory as the error directory. +# MAKE SURE there is no other directory named "plots" in there! +# The goal is to use display one plot for every error norm and quantity and display the values for gts, lts, parallel and not parallel +# +# Usage ./error_norms_convergence_plots.sh /path/to/error/folder NumberOfQuantities +# +# @section DEPENDENCIES +# This file depends on the following projects: +# xmlstarlet: http://xmlstar.sourceforge.net/ +# gnuplot: http://www.gnuplot.info/index.html + + +echo "Hi, I am starting now!" + +# remove and make new files + +rm -r -f $1/plots +mkdir $1/plots + +for norm_val in '1' '2' 'inf' +do + for quantity_val in $(seq 1 $2) + do + echo "#L${norm_val} Data Quantity ${quantity_val}" > plots/l${norm_val}_${quantity_val}.csv + done +done + +# find relevant data and extract into different files +# here, + +for timestepping in gts lts +do + for cl in 25 20 15 10 9 8 7 6 5 4 3 2 1 + do + for parallel in 1 13 + do + echo $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml + for i in $(seq 1 $2) + do + echo ${cl}, $(xmlstarlet sel -t -v "error_norms/l1/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/l1_${i}.csv + echo ${cl}, $(xmlstarlet sel -t -v "error_norms/l2/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/l2_${i}.csv + echo ${cl}, $(xmlstarlet sel -t -v "error_norms/linf/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/linf_${i}.csv + done + done + done +done + +# plot data to pdf with gnuplot +gnuplot -e "set terminal pdf ; +set output '$1/plots/output.pdf'; +set style line 1 \ + linecolor rgb '#0060ad' \ + linetype 1 linewidth 2 \ + pointtype 7 pointsize 1.5 ; +set style line 2 \ + linecolor rgb '#dd181f' \ + linetype 1 linewidth 2 \ + pointtype 5 pointsize 1.5; +set style line 3 \ + linecolor rgb '#51ff2e' \ + linetype 1 linewidth 2 \ + pointtype 2 pointsize 1.5; +set style line 4 \ + linecolor rgb '#132f38' \ + linetype 1 linewidth 2 \ + pointtype 3 pointsize 1.5; +set multiplot; +set yrange [0:3700]; +set datafile separator comma; +plot [25:0] '$1/plots/l1_1.csv' with linespoints linestyle 1; +plot [25:0] '$1/plots/l1_2.csv' with linespoints linestyle 2; +plot [25:0] '$1/plots/l1_3.csv' with linespoints linestyle 3; +plot [25:0] '$1/plots/l1_4.csv' with linespoints linestyle 4; +plot [25:0] '$1/plots/l1_5.csv' with linespoints linestyle 5; +unset multiplot; +set multiplot; +set yrange [0:45]; +set datafile separator comma; +plot [25:0] '$1/plots/l2_1.csv' with linespoints linestyle 1; +plot [25:0] '$1/plots/l2_2.csv' with linespoints linestyle 2; +plot [25:0] '$1/plots/l2_3.csv' with linespoints linestyle 3; +plot [25:0] '$1/plots/l2_4.csv' with linespoints linestyle 4; +plot [25:0] '$1/plots/l2_5.csv' with linespoints linestyle 5; +unset multiplot; +set multiplot; +set yrange [0:0.8]; +set datafile separator comma; +plot [25:0] '$1/plots/linf_1.csv' with linespoints linestyle 1; +plot [25:0] '$1/plots/linf_2.csv' with linespoints linestyle 2; +plot [25:0] '$1/plots/linf_3.csv' with linespoints linestyle 3; +plot [25:0] '$1/plots/linf_4.csv' with linespoints linestyle 4; +plot [25:0] '$1/plots/linf_5.csv' with linespoints linestyle 5; +unset multiplot ; +" From a4bc236b6817cbe0785082c27983b8ab6fb1f7b0 Mon Sep 17 00:00:00 2001 From: Sarah Bachinger Date: Mon, 27 Sep 2021 10:36:45 +0200 Subject: [PATCH 2/5] Finished generalized plotting --- .../error_norms_convergence_plots.sh | 68 ++++++++----------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/tools/processing/error_norms_convergence_plots.sh b/tools/processing/error_norms_convergence_plots.sh index 36f57ca4..2c5f997c 100644 --- a/tools/processing/error_norms_convergence_plots.sh +++ b/tools/processing/error_norms_convergence_plots.sh @@ -23,7 +23,7 @@ # Identifies error norms in xml files and extracts them for plotting according to the error norm. # The extracted files and the plots will be placed inside a "plots" folder in the same directory as the error directory. # MAKE SURE there is no other directory named "plots" in there! -# The goal is to use display one plot for every error norm and quantity and display the values for gts, lts, parallel and not parallel +# The goal is to use display one plot for every error norm and quantity and display the values for gts, lts, parallel and not parallel. # # Usage ./error_norms_convergence_plots.sh /path/to/error/folder NumberOfQuantities # @@ -36,38 +36,37 @@ echo "Hi, I am starting now!" # remove and make new files +# $1 is /path/to/error/folder +# $2 is NumberOfQuantities rm -r -f $1/plots mkdir $1/plots -for norm_val in '1' '2' 'inf' -do - for quantity_val in $(seq 1 $2) - do - echo "#L${norm_val} Data Quantity ${quantity_val}" > plots/l${norm_val}_${quantity_val}.csv - done -done - # find relevant data and extract into different files # here, -for timestepping in gts lts +#: ' +echo 'start extracting ... ' +for timestepping in 'gts' 'lts' do for cl in 25 20 15 10 9 8 7 6 5 4 3 2 1 do for parallel in 1 13 do - echo $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml + #echo $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml for i in $(seq 1 $2) do - echo ${cl}, $(xmlstarlet sel -t -v "error_norms/l1/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/l1_${i}.csv - echo ${cl}, $(xmlstarlet sel -t -v "error_norms/l2/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/l2_${i}.csv - echo ${cl}, $(xmlstarlet sel -t -v "error_norms/linf/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/linf_${i}.csv + echo ${cl}, $(xmlstarlet sel -t -v "error_norms/l1/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/l1_${i}_${timestepping}_pa_${parallel}.csv + echo ${cl}, $(xmlstarlet sel -t -v "error_norms/l2/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/l2_${i}_${timestepping}_pa_${parallel}.csv + echo ${cl}, $(xmlstarlet sel -t -v "error_norms/linf/q[${i}]" -nl $1/errors/${timestepping}_cl_${cl}_pa_${parallel}.xml) >> $1/plots/linf_${i}_${timestepping}_pa_${parallel}.csv done done done done +echo 'All data extracted... start plotting' +#' + # plot data to pdf with gnuplot gnuplot -e "set terminal pdf ; set output '$1/plots/output.pdf'; @@ -87,31 +86,18 @@ set style line 4 \ linecolor rgb '#132f38' \ linetype 1 linewidth 2 \ pointtype 3 pointsize 1.5; -set multiplot; -set yrange [0:3700]; -set datafile separator comma; -plot [25:0] '$1/plots/l1_1.csv' with linespoints linestyle 1; -plot [25:0] '$1/plots/l1_2.csv' with linespoints linestyle 2; -plot [25:0] '$1/plots/l1_3.csv' with linespoints linestyle 3; -plot [25:0] '$1/plots/l1_4.csv' with linespoints linestyle 4; -plot [25:0] '$1/plots/l1_5.csv' with linespoints linestyle 5; -unset multiplot; -set multiplot; -set yrange [0:45]; -set datafile separator comma; -plot [25:0] '$1/plots/l2_1.csv' with linespoints linestyle 1; -plot [25:0] '$1/plots/l2_2.csv' with linespoints linestyle 2; -plot [25:0] '$1/plots/l2_3.csv' with linespoints linestyle 3; -plot [25:0] '$1/plots/l2_4.csv' with linespoints linestyle 4; -plot [25:0] '$1/plots/l2_5.csv' with linespoints linestyle 5; -unset multiplot; -set multiplot; -set yrange [0:0.8]; -set datafile separator comma; -plot [25:0] '$1/plots/linf_1.csv' with linespoints linestyle 1; -plot [25:0] '$1/plots/linf_2.csv' with linespoints linestyle 2; -plot [25:0] '$1/plots/linf_3.csv' with linespoints linestyle 3; -plot [25:0] '$1/plots/linf_4.csv' with linespoints linestyle 4; -plot [25:0] '$1/plots/linf_5.csv' with linespoints linestyle 5; -unset multiplot ; +do for [l in \"1 2 inf\" ] { + do for [ q = 1:$2]{ + set multiplot title 'L'.l.' Q'.q; + set datafile separator comma; + set logscale xy; + plot '$1/plots/l'.l.'_'.q.'_gts_pa_1.csv' with linespoints linestyle 2 title 'L'.l.' Q'.q.' gts non parallel', \ + '$1/plots/l'.l.'_'.q.'_gts_pa_13.csv' with linespoints linestyle 4 title 'L'.l.' Q'.q.' gts parallel', \ + '$1/plots/l'.l.'_'.q.'_lts_pa_1.csv' with linespoints linestyle 3 title 'L'.l.' Q'.q.' lts non parallel', \ + '$1/plots/l'.l.'_'.q.'_lts_pa_13.csv' with linespoints linestyle 1 title 'L'.l.' Q'.q.' lts parallel'; + unset logscale; + unset multiplot; + } +} " +echo 'finished plotting' \ No newline at end of file From fa21da2d93d771bcba4c3f08731177efb6629bde Mon Sep 17 00:00:00 2001 From: Sarah Bachinger Date: Mon, 27 Sep 2021 11:01:44 +0200 Subject: [PATCH 3/5] log plotting, titles and axis labels --- .../error_norms_convergence_plots.sh | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/processing/error_norms_convergence_plots.sh b/tools/processing/error_norms_convergence_plots.sh index 2c5f997c..e1530231 100644 --- a/tools/processing/error_norms_convergence_plots.sh +++ b/tools/processing/error_norms_convergence_plots.sh @@ -39,15 +39,16 @@ echo "Hi, I am starting now!" # $1 is /path/to/error/folder # $2 is NumberOfQuantities -rm -r -f $1/plots -mkdir $1/plots +#rm -r -f $1/plots +#mkdir $1/plots + +# find relevant data and extract into different files -# find relevant data and extract into different files -# here, -#: ' echo 'start extracting ... ' -for timestepping in 'gts' 'lts' + +#for timestepping in 'gts' 'lts' +: ' do for cl in 25 20 15 10 9 8 7 6 5 4 3 2 1 do @@ -63,9 +64,10 @@ do done done done +' echo 'All data extracted... start plotting' -#' + # plot data to pdf with gnuplot gnuplot -e "set terminal pdf ; @@ -90,7 +92,11 @@ do for [l in \"1 2 inf\" ] { do for [ q = 1:$2]{ set multiplot title 'L'.l.' Q'.q; set datafile separator comma; + set grid; set logscale xy; + set size ratio 0.5; + set ylabel 'error'; + set xlabel 'mesh width'; plot '$1/plots/l'.l.'_'.q.'_gts_pa_1.csv' with linespoints linestyle 2 title 'L'.l.' Q'.q.' gts non parallel', \ '$1/plots/l'.l.'_'.q.'_gts_pa_13.csv' with linespoints linestyle 4 title 'L'.l.' Q'.q.' gts parallel', \ '$1/plots/l'.l.'_'.q.'_lts_pa_1.csv' with linespoints linestyle 3 title 'L'.l.' Q'.q.' lts non parallel', \ From 2d3b814622dccf55aaba4c8ad352dca4550b5614 Mon Sep 17 00:00:00 2001 From: Sarah Bachinger Date: Mon, 27 Sep 2021 11:26:40 +0200 Subject: [PATCH 4/5] complete and working --- .../error_norms_convergence_plots.sh | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/processing/error_norms_convergence_plots.sh b/tools/processing/error_norms_convergence_plots.sh index e1530231..16af7b77 100644 --- a/tools/processing/error_norms_convergence_plots.sh +++ b/tools/processing/error_norms_convergence_plots.sh @@ -39,16 +39,15 @@ echo "Hi, I am starting now!" # $1 is /path/to/error/folder # $2 is NumberOfQuantities -#rm -r -f $1/plots -#mkdir $1/plots +rm -r -f $1/plots +mkdir $1/plots # find relevant data and extract into different files echo 'start extracting ... ' -#for timestepping in 'gts' 'lts' -: ' +for timestepping in 'gts' 'lts' do for cl in 25 20 15 10 9 8 7 6 5 4 3 2 1 do @@ -64,7 +63,7 @@ do done done done -' + echo 'All data extracted... start plotting' @@ -75,32 +74,35 @@ set output '$1/plots/output.pdf'; set style line 1 \ linecolor rgb '#0060ad' \ linetype 1 linewidth 2 \ - pointtype 7 pointsize 1.5 ; -set style line 2 \ + pointtype 7 pointsize 1; + set style line 2 \ linecolor rgb '#dd181f' \ linetype 1 linewidth 2 \ - pointtype 5 pointsize 1.5; + pointtype 5 pointsize 1; set style line 3 \ linecolor rgb '#51ff2e' \ linetype 1 linewidth 2 \ - pointtype 2 pointsize 1.5; + pointtype 2 pointsize 1; set style line 4 \ linecolor rgb '#132f38' \ linetype 1 linewidth 2 \ - pointtype 3 pointsize 1.5; + pointtype 3 pointsize 1; do for [l in \"1 2 inf\" ] { do for [ q = 1:$2]{ set multiplot title 'L'.l.' Q'.q; set datafile separator comma; set grid; + set xrange [25:1]; set logscale xy; set size ratio 0.5; set ylabel 'error'; set xlabel 'mesh width'; + set xtics (1,2,5,10,20,50); + set format y \"%4.1e\"; plot '$1/plots/l'.l.'_'.q.'_gts_pa_1.csv' with linespoints linestyle 2 title 'L'.l.' Q'.q.' gts non parallel', \ '$1/plots/l'.l.'_'.q.'_gts_pa_13.csv' with linespoints linestyle 4 title 'L'.l.' Q'.q.' gts parallel', \ - '$1/plots/l'.l.'_'.q.'_lts_pa_1.csv' with linespoints linestyle 3 title 'L'.l.' Q'.q.' lts non parallel', \ - '$1/plots/l'.l.'_'.q.'_lts_pa_13.csv' with linespoints linestyle 1 title 'L'.l.' Q'.q.' lts parallel'; + '$1/plots/l'.l.'_'.q.'_lts_pa_1.csv' with linespoints linestyle 1 title 'L'.l.' Q'.q.' lts non parallel', \ + '$1/plots/l'.l.'_'.q.'_lts_pa_13.csv' with linespoints linestyle 3 title 'L'.l.' Q'.q.' lts parallel'; unset logscale; unset multiplot; } From e16fda6f379cd4ef6cc70e7550804d8cd9d91239 Mon Sep 17 00:00:00 2001 From: Sarah Bachinger Date: Mon, 27 Sep 2021 12:00:46 +0200 Subject: [PATCH 5/5] name change --- tools/processing/error_norms_convergence_plots.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/processing/error_norms_convergence_plots.sh b/tools/processing/error_norms_convergence_plots.sh index 16af7b77..2e485b06 100644 --- a/tools/processing/error_norms_convergence_plots.sh +++ b/tools/processing/error_norms_convergence_plots.sh @@ -99,10 +99,10 @@ do for [l in \"1 2 inf\" ] { set xlabel 'mesh width'; set xtics (1,2,5,10,20,50); set format y \"%4.1e\"; - plot '$1/plots/l'.l.'_'.q.'_gts_pa_1.csv' with linespoints linestyle 2 title 'L'.l.' Q'.q.' gts non parallel', \ - '$1/plots/l'.l.'_'.q.'_gts_pa_13.csv' with linespoints linestyle 4 title 'L'.l.' Q'.q.' gts parallel', \ - '$1/plots/l'.l.'_'.q.'_lts_pa_1.csv' with linespoints linestyle 1 title 'L'.l.' Q'.q.' lts non parallel', \ - '$1/plots/l'.l.'_'.q.'_lts_pa_13.csv' with linespoints linestyle 3 title 'L'.l.' Q'.q.' lts parallel'; + plot '$1/plots/l'.l.'_'.q.'_gts_pa_1.csv' with linespoints linestyle 2 title 'L'.l.' Q'.q.' gts', \ + '$1/plots/l'.l.'_'.q.'_gts_pa_13.csv' with linespoints linestyle 4 title 'L'.l.' Q'.q.' gts mpi', \ + '$1/plots/l'.l.'_'.q.'_lts_pa_1.csv' with linespoints linestyle 1 title 'L'.l.' Q'.q.' lts', \ + '$1/plots/l'.l.'_'.q.'_lts_pa_13.csv' with linespoints linestyle 3 title 'L'.l.' Q'.q.' lts mpi'; unset logscale; unset multiplot; }