diff --git a/scripts/compute_psdlags.sh b/scripts/compute_psdlags.sh index 7bd8895..d6ea948 100755 --- a/scripts/compute_psdlags.sh +++ b/scripts/compute_psdlags.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash -mkdir -p data +mkdir -p data/tables +mkdir -p logs + +analysis_script="psdlag_4bin.py" ref_band="1367A" refpsd_tabfile=data/tables/psd_${ref_band}.tab @@ -20,16 +23,23 @@ do echo -n "Running psdlag using ref band ${ref_band}" echo " and echo band $echo_band." - # psdlag python script will call clag and print rudimentary tables to *.out - time scripts/psdlag_4bin.py data/lc/${ref_band}.lc $lightcurve > /dev/null + echo $(date) >> logs/$echo_band + 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, # 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/ mv -v tmp.echopsd $echopsd_tabfile mv -v tmp.refpsd $refpsd_tabfile mv -v tmp.lag $timelag_tabfile + + echo "" done diff --git a/scripts/plot.sh b/scripts/plot.sh index 4c1e03a..4cf8767 100755 --- a/scripts/plot.sh +++ b/scripts/plot.sh @@ -8,13 +8,12 @@ ref_band="1367A" case $1 in "PSD"|"psd"|"PSDs"|"PSDS"|"psds") gnuplot_file=psd_atlas.gp - scripts/propagate_tables.sh gnuplot_input=$(cat scripts/templates/${gnuplot_file}| perl -pe 's|\n|␤|g') for tabfile in data/tables/psd_*.tab; do 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 gnuplot_input_edit=$(echo "$gnuplot_input"| sed "s|%FILE%|$tabfile|"| diff --git a/scripts/process_tables.pl b/scripts/process_tables.pl index a76487a..f59fafd 100755 --- a/scripts/process_tables.pl +++ b/scripts/process_tables.pl @@ -158,15 +158,16 @@ while( each %function_bin) { } close($datafile); -open($datafile,'>',"tmp.crsspctrm") or die $!; -while( each %function_bin) { - say $datafile - $_ . " " . - $function_bin{$_}{"crsspctrm_PSD_μ"} . " " . - $function_bin{$_}{"Δ"} . " " . - $function_bin{$_}{"crsspctrm_PSD_σ"}; -} -close($datafile); +# cross spectrum not needed +# open($datafile,'>',"tmp.crsspctrm") or die $!; +# while( each %function_bin) { +# say $datafile +# $_ . " " . +# $function_bin{$_}{"crsspctrm_PSD_μ"} . " " . +# $function_bin{$_}{"Δ"} . " " . +# $function_bin{$_}{"crsspctrm_PSD_σ"}; +# } +# close($datafile); open($datafile,'>',"tmp.lag") or die $!; while( each %function_bin) { diff --git a/scripts/templates/psd.gp b/scripts/templates/psd.gp new file mode 100644 index 0000000..ca5b22f --- /dev/null +++ b/scripts/templates/psd.gp @@ -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" diff --git a/scripts/templates/psd_atlas.gp b/scripts/templates/psd_atlas.gp new file mode 100644 index 0000000..fa7cbc4 --- /dev/null +++ b/scripts/templates/psd_atlas.gp @@ -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 + diff --git a/scripts/templates/timelag.gp b/scripts/templates/timelag.gp new file mode 100644 index 0000000..731221f --- /dev/null +++ b/scripts/templates/timelag.gp @@ -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" \ No newline at end of file diff --git a/scripts/templates/timelag_atlas.gp b/scripts/templates/timelag_atlas.gp new file mode 100644 index 0000000..e72429d --- /dev/null +++ b/scripts/templates/timelag_atlas.gp @@ -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 + diff --git a/scripts/templates/timelag_compare.gp b/scripts/templates/timelag_compare.gp new file mode 100644 index 0000000..dc04b07 --- /dev/null +++ b/scripts/templates/timelag_compare.gp @@ -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%" diff --git a/scripts/templates/tophat_freqdomain.gp b/scripts/templates/tophat_freqdomain.gp new file mode 100644 index 0000000..7eae0ae --- /dev/null +++ b/scripts/templates/tophat_freqdomain.gp @@ -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" \ No newline at end of file diff --git a/scripts/templates/tophat_timedomain.gp b/scripts/templates/tophat_timedomain.gp new file mode 100644 index 0000000..d4bf48c --- /dev/null +++ b/scripts/templates/tophat_timedomain.gp @@ -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" \ No newline at end of file