added gnuplot templates

This commit is contained in:
caes 2017-06-22 07:11:39 -04:00
parent 539cb359ed
commit 3130b78f58
10 changed files with 476 additions and 15 deletions

View File

@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
mkdir -p data mkdir -p data/tables
mkdir -p logs
analysis_script="psdlag_4bin.py"
ref_band="1367A" ref_band="1367A"
refpsd_tabfile=data/tables/psd_${ref_band}.tab refpsd_tabfile=data/tables/psd_${ref_band}.tab
@ -20,16 +23,23 @@ do
echo -n "Running psdlag using ref band ${ref_band}" echo -n "Running psdlag using ref band ${ref_band}"
echo " and echo band $echo_band." echo " and echo band $echo_band."
# psdlag python script will call clag and print rudimentary tables to *.out echo $(date) >> logs/$echo_band
time scripts/psdlag_4bin.py data/lc/${ref_band}.lc $lightcurve > /dev/null echo " " >> logs/$echo_band
# psdlag python script will call clag and print rudimentary tables to *.out,
# and is logged to the log file
time scripts/${analysis_script} data/lc/${ref_band}.lc $lightcurve >> logs/${echo_band}
# process_tables perl script reads *.out files from the python script, # process_tables perl script reads *.out files from the python script,
# then creates other useful tables # then creates other useful tables
scripts/process_tables.pl $echo_band > /dev/null
scripts/process_tables.pl $echo_band
# saves the tables to data/tables/ # saves the tables to data/tables/
mv -v tmp.echopsd $echopsd_tabfile mv -v tmp.echopsd $echopsd_tabfile
mv -v tmp.refpsd $refpsd_tabfile mv -v tmp.refpsd $refpsd_tabfile
mv -v tmp.lag $timelag_tabfile mv -v tmp.lag $timelag_tabfile
echo ""
done done

View File

@ -8,13 +8,12 @@ ref_band="1367A"
case $1 in case $1 in
"PSD"|"psd"|"PSDs"|"PSDS"|"psds") "PSD"|"psd"|"PSDs"|"PSDS"|"psds")
gnuplot_file=psd_atlas.gp gnuplot_file=psd_atlas.gp
scripts/propagate_tables.sh
gnuplot_input=$(cat scripts/templates/${gnuplot_file}| gnuplot_input=$(cat scripts/templates/${gnuplot_file}|
perl -pe 's|\n|␤|g') perl -pe 's|\n|␤|g')
for tabfile in data/tables/psd_*.tab; for tabfile in data/tables/psd_*.tab;
do do
echo_band=$(basename $tabfile| echo_band=$(basename $tabfile|
sed 's|psd_\([0-9]????A\).tab|\1|') sed 's|psd_\([0-9]\{4\}A\).tab|\1|')
if [[ "$echo_band" == "$ref_band" ]] ; then continue; fi if [[ "$echo_band" == "$ref_band" ]] ; then continue; fi
gnuplot_input_edit=$(echo "$gnuplot_input"| gnuplot_input_edit=$(echo "$gnuplot_input"|
sed "s|%FILE%|$tabfile|"| sed "s|%FILE%|$tabfile|"|

View File

@ -158,15 +158,16 @@ while( each %function_bin) {
} }
close($datafile); close($datafile);
open($datafile,'>',"tmp.crsspctrm") or die $!; # cross spectrum not needed
while( each %function_bin) { # open($datafile,'>',"tmp.crsspctrm") or die $!;
say $datafile # while( each %function_bin) {
$_ . " " . # say $datafile
$function_bin{$_}{"crsspctrm_PSD_μ"} . " " . # $_ . " " .
$function_bin{$_}{"Δ"} . " " . # $function_bin{$_}{"crsspctrm_PSD_μ"} . " " .
$function_bin{$_}{"crsspctrm_PSD_σ"}; # $function_bin{$_}{"Δ"} . " " .
} # $function_bin{$_}{"crsspctrm_PSD_σ"};
close($datafile); # }
# close($datafile);
open($datafile,'>',"tmp.lag") or die $!; open($datafile,'>',"tmp.lag") or die $!;
while( each %function_bin) { while( each %function_bin) {

34
scripts/templates/psd.gp Normal file
View File

@ -0,0 +1,34 @@
# This method assumes y values are in logarithm units already.
set terminal pdf
set output "%OUTPUTFILE%"
set termopt enhanced
set macros
# Placement of the a,b,c,d labels in the graphs
POS = "at graph 0.8,0.84 font 'Times,24'"
XLABEL = "set xlabel 'Temporal Frequency [days^{-1}]' font 'Times' off 0,1;\
set format x '10^{%+3T}'"
YLABEL = "set ylabel 'log_{10} PSD' font 'Times' offset 1,2.5;\
set format y '%.0t'"
unset title
unset key
set xlabel "Temporal Frequency [days^{-1}]" font "Times,24"
set xrange [0.005:0.620]
set xtics auto font 'Times,16'
set logscale x
set ylabel "log_{10} PSD" font "Times,24"
set yrange [-5.5:0.5]
set ytics auto font 'Times,16'
set ytics add ('' -0.5 1,'' -1.5 1,'' -2.5 1,'' -3.5 1,'' -4.5 1)
set xzeroaxis
set label 1 '%LABEL1%' @POS
plot '%FILE1%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .5 lt rgb "black", \
'%FILE2%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .5 lt rgb "red"

View File

@ -0,0 +1,160 @@
set terminal pdf size 3.5,5
set output "psd_atlas.pdf"
set termopt enhanced
set macros
# Placement of the a,b,c,d labels in the graphs
POS = "at graph 0.61,0.85 font 'Times,12'"
# x- and ytics for each row resp. column
NOXNUMS = "unset xlabel;\
set format x ''"
XNUMS = "unset xlabel;\
set format x '10^{%+3T}'"
XLABEL = "set xlabel 'Temporal Frequency [days^{-1}]' font 'Times' off 0,1;\
set format x '10^{%+3T}'"
YLABEL = "set ylabel 'log_{10} PSD' font 'Times' offset 1,2.5;\
set format y '%.0t'"
NOYNUMS = "set format y ''; unset ylabel"
YNUMS = "set format y '%.0t'"
VSET_1 = "set tmargin at screen 0.97; set bmargin at screen 0.825"
VSET_2 = "set tmargin at screen 0.825; set bmargin at screen 0.68"
VSET_3 = "set tmargin at screen 0.68; set bmargin at screen 0.535"
VSET_4 = "set tmargin at screen 0.535; set bmargin at screen 0.39"
VSET_5 = "set tmargin at screen 0.39; set bmargin at screen 0.245"
VSET_6 = "set tmargin at screen 0.245; set bmargin at screen 0.10"
HSET_1 = "set lmargin at screen 0.15; set rmargin at screen 0.42"
HSET_2 = "set lmargin at screen 0.42; set rmargin at screen 0.69"
HSET_3 = "set lmargin at screen 0.69; set rmargin at screen 0.96"
unset key
set logscale x
set xtics auto font 'Times,9' offset 0,.5
set ytics auto font 'Times,9'
set ytics add ('' -0.5 1,'' -1.5 1,'' -2.5 1,'' -3.5 1,'' -4.5 1)
# xrange from 2016 REU freq bins
#set xrange [0.005:0.620];
set yrange [-5.5:0.5]
# xrange pulled from example.py from first version of clag
set xrange [0.001:5]
set yrange [-5.5:0.5]
set multiplot layout 6,3 rowsfirst
# --- GRAPH a
@VSET_1; @HSET_1
@NOXNUMS; @YNUMS
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH b
@NOXNUMS; @NOYNUMS
@VSET_1; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
#-- GRAPH c
@NOXNUMS; @NOYNUMS
@VSET_1; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH d
@NOXNUMS; @YNUMS
@VSET_2; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_2; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_2; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @YNUMS
@VSET_3; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_3; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_3; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @YLABEL
@VSET_4; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_4; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_4; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @YNUMS
@VSET_5; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_5; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_5; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@XNUMS; @YNUMS
@VSET_6; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@XLABEL; @NOYNUMS
@VSET_6; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@XNUMS; @NOYNUMS
@VSET_6; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
unset multiplot

View File

@ -0,0 +1,36 @@
set terminal pdf
set output "%OUTPUTFILE%"
set termopt enhanced
set macros
# Placement of the a,b,c,d labels in the graphs
POS = "at graph 0.8,0.92 font 'Times,24'"
XLABEL = "set xlabel 'Temporal Frequency [days^{-1}]' font 'Times' off 0,1;\
set format x '10^{%+3T}'"
YLABEL = "set ylabel 'log_{10} PSD' font 'Times' offset 1,2.5;\
set format y '%.0t'"
unset title
unset key
set xlabel "Temporal Frequency [days^{-1}]" font "Times,24"
set xrange [0.005:0.620]
set xtics auto font 'Times,16'
set logscale x
set xzeroaxis
set ylabel "Lag [days]" font "Times,24"
set yrange [-2:6]
#set ytics (-1,0,1,2,3,4,5) font 'Times,16'
set ytics auto font 'Times,16'
set ytics add ('' -1.5 1,'' -0.5 1,'' 0.5 1,'' 1.5 1,'' 2.5 1,'' 3.5 1,'' 4.5 1,'' 5.5 1)
# Draw line at origin
#set arrow from 0.005,0 to 0.620,0 nohead lt 3 lc rgb 'black'
#set pointsize 0
set label 1 '%LABEL1%' @POS
plot '%FILE1%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .5 lt rgb "black"

View File

@ -0,0 +1,159 @@
set terminal pdf size 3.5,5
set output "timelag_atlas.pdf"
set termopt enhanced
set macros
# Placement of the a,b,c,d labels in the graphs
POS = "at graph 0.61,0.85 font 'Times,12'"
# x- and ytics for each row resp. column
NOXNUMS = "unset xlabel;\
set format x ''"
XNUMS = "unset xlabel;\
set format x '10^{%+3T}'"
XLABEL = "set xlabel 'Temporal Frequency [days^{-1}]' font 'Times' off 0,1;\
set format x '10^{%+3T}'"
YLABEL = "set ylabel 'Lag [days]' font 'Times' offset 1,2.5;\
set format y '%.0t'"
NOYNUMS = "set format y ''; unset ylabel"
YNUMS = "set format y '%.0t'"
VSET_1 = "set tmargin at screen 0.97; set bmargin at screen 0.825"
VSET_2 = "set tmargin at screen 0.825; set bmargin at screen 0.68"
VSET_3 = "set tmargin at screen 0.68; set bmargin at screen 0.535"
VSET_4 = "set tmargin at screen 0.535; set bmargin at screen 0.39"
VSET_5 = "set tmargin at screen 0.39; set bmargin at screen 0.245"
VSET_6 = "set tmargin at screen 0.245; set bmargin at screen 0.10"
HSET_1 = "set lmargin at screen 0.15; set rmargin at screen 0.42"
HSET_2 = "set lmargin at screen 0.42; set rmargin at screen 0.69"
HSET_3 = "set lmargin at screen 0.69; set rmargin at screen 0.96"
unset key
set logscale x
set xtics auto font 'Times,9' offset 0,.5
set ytics (-1,0,1,2,3,4,5) font 'Times,9'
set ytics add ('' -1.5 1,'' -0.5 1,'' 0.5 1,'' 1.5 1,'' 2.5 1,'' 3.5 1,'' 4.5 1,'' 5.5 1)
set xrange [0.005:0.620];
set yrange [-2:6]
# Draw line at origin
set arrow from 0.005,0 to 0.620,0 nohead lt 3 lc rgb 'black'
set pointsize 0
set multiplot layout 6,3 rowsfirst
# --- GRAPH a
@VSET_1; @HSET_1
@NOXNUMS; @YNUMS
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH b
@NOXNUMS; @NOYNUMS
@VSET_1; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
#-- GRAPH c
@NOXNUMS; @NOYNUMS
@VSET_1; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH d
@NOXNUMS; @YNUMS
@VSET_2; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_2; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_2; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @YNUMS
@VSET_3; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_3; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_3; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @YLABEL
@VSET_4; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_4; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_4; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @YNUMS
@VSET_5; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_5; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@NOXNUMS; @NOYNUMS
@VSET_5; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@XNUMS; @YNUMS
@VSET_6; @HSET_1
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@XLABEL; @NOYNUMS
@VSET_6; @HSET_2
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
# --- GRAPH a
@XNUMS; @NOYNUMS
@VSET_6; @HSET_3
set label 1 '%LABEL%' @POS
plot '%FILE%' using 1:2:($2-$4):($2+$4) with yerrorbars pt 7 ps .3 lt rgb "black"
unset multiplot

View File

@ -0,0 +1,21 @@
set terminal pdf
set termoption dash
set termopt enhanced
set output "%OUTPUTFILE%"
set title "%TITLE%\n{/*0.7 %SUBTITLE%}"
set xlabel "Temporal Frequency [days^{-1}]"
set xrange [0.005:0.620]
set logscale x
set ylabel "Lag [days]"
#set yrange [%YMIN:%YMAX]
#set yrange [-5:7]
set key outside
set key center bottom
# Draw line at origin
set arrow from 0.005,0 to 0.620,0 nohead lt 3 lc rgb 'black'
set pointsize 0
plot '%FILE1%' using 1:2:3:4 with xyerrorbars title "%LABEL1%", \
"%FILE2%" using 1:2:3:4 with xyerrorbars title "%LABEL2%"

View File

@ -0,0 +1,22 @@
set terminal pdf
set termopt enhanced
set output "tophat_freqdomain.pdf"
set xrange [0.005:0.620]
set logscale x
set xlabel "Temporal Frequency [days^{-1}]" font "Times,24"
set xtics font 'Times,16'
set mxtics
set yrange [-30:30]
set ylabel "Time Delay [days]" font "Times,24"
set ytics font 'Times,16'
set mytics
unset key
plot "analyses/tables/tophat_fft1.tab" using 1:2 with lines lc rgb "red", \
"analyses/tables/tophat_fft2.tab" using 1:2 with lines lc rgb "green", \
"analyses/tables/tophat_fft3.tab" using 1:2 with lines lc rgb "blue"

View File

@ -0,0 +1,19 @@
set terminal pdf
set output "tophat_timedomain.pdf"
set xrange [0:35]
set xlabel "Time [days]" font "Times,24"
set xtics font 'Times,16'
set mxtics
set yrange [0:0.5]
set ylabel "Response [n.u.]" font "Times,24"
set ytics font 'Times,16'
set mytics
unset key
plot "analyses/tables/tophat1.tab" using 1:2 with lines lc rgb "red", \
"analyses/tables/tophat2.tab" using 1:2 with lines lc rgb "green", \
"analyses/tables/tophat3.tab" using 1:2 with lines lc rgb "blue"