From 4f54ac104e1a0d8b43195a20fd2aa83d80c76400 Mon Sep 17 00:00:00 2001 From: caes Date: Tue, 9 Aug 2016 22:38:11 -0400 Subject: [PATCH] did a bunch of work to the new main plot.sh script --- plot.sh | 51 +++++++++++++++++++ .../{create_tables.pl => extract_tables.pl} | 3 ++ scripts/plot_psdlag.sh | 2 +- scripts/templates/psd_freq.gp | 21 +++++--- scripts/templates/timelag_compare.gp | 1 - 5 files changed, 68 insertions(+), 10 deletions(-) mode change 100644 => 100755 plot.sh rename scripts/{create_tables.pl => extract_tables.pl} (97%) diff --git a/plot.sh b/plot.sh old mode 100644 new mode 100755 index 9139da3..7c4db22 --- a/plot.sh +++ b/plot.sh @@ -3,3 +3,54 @@ # This metascript uses the available plotting scripts to produce a list of # document-rady plots. +# Only analyses with this error type will be represented in the atlas +errtype="CM" +ref_band="1367Å" +echo_bands=$(ls analyses/*CM*|sed 's|[^≺]*≺_\(.\{5\}\).*|\1|') + +# echo Using list of reverberated bands: $echo_bands + +echo Propagating tables. +scripts/propagate_tables.sh > /dev/null + +case $1 in + "PSD") + echo "Producing PSD atlas." + gnuplot_file=psd_atlas.gp + gnuplot_input=$(cat scripts/templates/${gnuplot_file}|perl -pe 's|\n|␤|g') + for tabfile in analyses/tables/PSD_*${errtype}*; + do + echo_band=$(basename $tabfile| + sed 's|PSD[_ ]\(.\{5\}\)[_ ]{[^_ ]*}.tab|\1|') + if [[ "$echo_band" == "$ref_band" ]] ; then continue; fi + gnuplot_input_edit=$(echo "$gnuplot_input"| + sed "s|%FILE%|$tabfile|"| + sed "s|%LABEL%|$echo_band|") + gnuplot_input="${gnuplot_input_edit}" + done + echo "$gnuplot_input"|perl -pe 's|␤|\n|g' > ${gnuplot_file} + gnuplot $gnuplot_file + + ;; + + "lags") + echo "Producing time delay atlas." + gnuplot_file=timelag_atlas.gp + gnuplot_input=$(cat scripts/templates/${gnuplot_file}|perl -pe 's|\n|␤|g') + for tabfile in analyses/tables/timelag_*${errtype}*; + do + ref_band_extracted=$(basename $tabfile|sed 's|timelag_\([^≺]*\)[_ ]≺[_ ][^≺_ ]*[_ ]{[^_ ]*}.tab|\1|') + echo_band=$(basename $tabfile|sed 's|timelag_[^≺]*[_ ]≺[_ ]\([^≺_ ]*\)[_ ]{[^_ ]*}.tab|\1|') + if [[ "$echo_band" == "$ref_band" ]] ; then continue; fi + gnuplot_input_edit=$(echo "$gnuplot_input"| + sed "s|%FILE%|$tabfile|"| + sed "s|%LABEL%|$echo_band|") + gnuplot_input="${gnuplot_input_edit}" + done + echo "$gnuplot_input"|perl -pe 's|␤|\n|g' > ${gnuplot_file} + gnuplot $gnuplot_file + ;; + default) + echo "Did not understand plot type." + ;; +esac \ No newline at end of file diff --git a/scripts/create_tables.pl b/scripts/extract_tables.pl similarity index 97% rename from scripts/create_tables.pl rename to scripts/extract_tables.pl index 8b27fc0..e353577 100755 --- a/scripts/create_tables.pl +++ b/scripts/extract_tables.pl @@ -1,5 +1,8 @@ #!/usr/bin/env perl +# This extracts the gnuplot-ready tables from a psdlag analysis and saves them +# to temporary files. propogate_tables.sh uses this script to create the +# tables it saves to analyses/tables. use utf8; use Encode qw(encode decode); diff --git a/scripts/plot_psdlag.sh b/scripts/plot_psdlag.sh index 56ef823..79c8f4e 100755 --- a/scripts/plot_psdlag.sh +++ b/scripts/plot_psdlag.sh @@ -42,7 +42,7 @@ do # Output curves to temporary files using perl script, move tables to # permanent location. This just assumes there are no conflicts. - scripts/create_tables.pl $analysis > /dev/null + scripts/extract_tables.pl $analysis > /dev/null mv tmp.echoPSD $echoPSD_tabfile mv tmp.refPSD $refPSD_tabfile mv tmp.timelag $timelag_tabfile diff --git a/scripts/templates/psd_freq.gp b/scripts/templates/psd_freq.gp index 9b595e7..1a6faec 100644 --- a/scripts/templates/psd_freq.gp +++ b/scripts/templates/psd_freq.gp @@ -1,29 +1,34 @@ # This method assumes y values are in logarithm units already. -set terminal pngcairo +set terminal pdf set output "%OUTPUTFILE" -set termoption dash +# set termoption dash set termopt enhanced -set title "%TITLE\n{/*0.7 %SUBTITLE}" -set xlabel "Temporal Frequency [days^{-1}]" +set title "%TITLE\n{/*0.7 %SUBTITLE}" font "Times" +set xlabel "Temporal Frequency [days^{-1}]" font "Times" set xrange [0.005:0.620] +set xtics font "Times" +set ytics font "Times" # Use this if you want to show PSD directly on a log axis # set logscale xy -# set ylabel "PSD" +# set ylabel "PSD" font "Times" # set yrange [%YMIN:%YMAX] # plot '%FILE1' using 1:(10**($2+2)):3:4 with xyerrorbars title "%LABEL1", \ # '%FILE2' using 1:(10**($2+2)):3:4 with xyerrorbars title "%LABEL2" # Use this if you want to show the log value of the PSD set logscale x -set ylabel "log_{10} PSD" +set ylabel "log_{10} PSD" font "Times" #set yrange [%YMIN:%YMAX] #set yrange [-5.5:0.5] set key outside set key center bottom +set key font "Times" -plot '%FILE1' using 1:2:3:4 with xyerrorbars title "%LABEL1", \ -'%FILE2' using 1:2:3:4 with xyerrorbars title "%LABEL2" +set yzeroaxis + +plot '%FILE1' using 1:2:3:4 with xyerrorbars title "%LABEL1" pt 0 ps 1 lt rgb "green", \ +'%FILE2' using 1:2:3:4 with xyerrorbars title "%LABEL2" pt 0 ps 1 lt rgb "red" diff --git a/scripts/templates/timelag_compare.gp b/scripts/templates/timelag_compare.gp index 446b60a..e682c4c 100644 --- a/scripts/templates/timelag_compare.gp +++ b/scripts/templates/timelag_compare.gp @@ -2,7 +2,6 @@ set terminal pngcairo set termoption dash set termopt enhanced set output "%OUTPUTFILE" -set encoding utf8 set title "%TITLE\n{/*0.7 %SUBTITLE}" set xlabel "Temporal Frequency [days^{-1}]"