| 
									
										
										
										
											2016-07-25 21:11:38 +00:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							| 
									
										
										
										
											2016-07-12 20:24:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-13 20:16:09 +00:00
										 |  |  | ywindow_of () { | 
					
						
							|  |  |  |     max=0 | 
					
						
							|  |  |  |     min=-5 | 
					
						
							|  |  |  |     while read line | 
					
						
							|  |  |  | #    for line in $(cat $1) | 
					
						
							|  |  |  |     do | 
					
						
							|  |  |  |         read xval yval xerr yerr <<< $line | 
					
						
							|  |  |  |         echo $xval $yval | 
					
						
							|  |  |  |         if (bc <<< "$yval > $max"); then max=$yval; fi | 
					
						
							|  |  |  |         if (bc <<< "$yval < $min"); then min=$yval; fi | 
					
						
							|  |  |  | #    done | 
					
						
							|  |  |  |     done < $1 | 
					
						
							|  |  |  |     echo $(bc <<< "$min - 0.5") $(bc <<< "$max + 0.5") | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  | mkdir -p analyses/tables | 
					
						
							|  |  |  | mkdir -p analyses/plots | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 06:11:17 +00:00
										 |  |  | # Restore the proper naming conventions for any files stripped | 
					
						
							|  |  |  | # of their unicode characters. | 
					
						
							|  |  |  | scripts/fix_thor_names.sh | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Create tables and plot the power spectra distributions and time lags. | 
					
						
							| 
									
										
										
										
											2016-07-12 20:24:21 +00:00
										 |  |  | for analysis in analyses/* | 
					
						
							|  |  |  | do | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  |     # Grab and determine labels of analyses, skip if over the same band. | 
					
						
							| 
									
										
										
										
											2016-07-27 06:11:17 +00:00
										 |  |  |     ref_band=$(basename $analysis|sed 's|\([^≺]*\)[_ ]≺[_ ][^≺_ ]*[_ ]{[^_ ]*}|\1|') | 
					
						
							|  |  |  |     echo_band=$(basename $analysis|sed 's|[^≺]*[_ ]≺[_ ]\([^≺_ ]*\)[_ ]{[^_ ]*}|\1|') | 
					
						
							|  |  |  |     err_str=$(basename $analysis|sed 's|[^≺]*[_ ]≺[_ ][^≺_ ]*[_ ]{[^_ ]*;\(σ∊[CLM][MFC]\)}|\1|') | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Prepare files | 
					
						
							|  |  |  |     echo "Plotting PSD and time lags for $echo_band, referred to ${ref_band}." | 
					
						
							| 
									
										
										
										
											2016-07-27 06:11:17 +00:00
										 |  |  |     echoPSD_tabfile=analyses/tables/PSD_${echo_band}_\{${err_str}\}.tab | 
					
						
							|  |  |  |     refPSD_tabfile=analyses/tables/PSD_${ref_band}_\{${err_str}\}.tab | 
					
						
							|  |  |  |     timelag_tabfile=analyses/tables/timelag_${ref_band}_≺_${echo_band}_\{${err_str}\}.tab | 
					
						
							| 
									
										
										
										
											2016-08-11 05:56:50 +00:00
										 |  |  |     PSD_plotfile=analyses/plots/PSD_${echo_band}_\{${err_str}\}.pdf | 
					
						
							|  |  |  |     timelag_plotfile=analyses/plots/timelag_${ref_band}_≺_${echo_band}_\{${err_str}\}.pdf | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Output curves to temporary files using perl script, move tables to | 
					
						
							|  |  |  |     # permanent location. This just assumes there are no conflicts. | 
					
						
							| 
									
										
										
										
											2016-08-10 02:38:11 +00:00
										 |  |  |     scripts/extract_tables.pl $analysis > /dev/null | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  |     mv tmp.echoPSD $echoPSD_tabfile | 
					
						
							|  |  |  |     mv tmp.refPSD $refPSD_tabfile | 
					
						
							| 
									
										
										
										
											2016-07-13 03:31:47 +00:00
										 |  |  |     mv tmp.timelag $timelag_tabfile | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-13 20:16:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  |     # Plot PSD and save using gnuplot | 
					
						
							| 
									
										
										
										
											2016-07-13 20:16:09 +00:00
										 |  |  | #    read ymin ymax <<< $(ywindow_of $timelag_tabfile) | 
					
						
							|  |  |  | #    echo $ymin $ymax | 
					
						
							| 
									
										
										
										
											2016-08-11 05:56:50 +00:00
										 |  |  |     cat scripts/templates/psd.gp| | 
					
						
							|  |  |  |         sed "s|%TITLE%|Power Spectrum for Lightcurves $echo_band and $ref_band|"| | 
					
						
							|  |  |  |         sed "s|%SUBTITLE%|as reported by Fausnaugh et. al, STORM III, 2016|"| | 
					
						
							|  |  |  |         sed "s|%FILE1%|$echoPSD_tabfile|"| | 
					
						
							| 
									
										
										
										
											2016-08-11 06:33:49 +00:00
										 |  |  |         sed "s|%LABEL1%|${echo_band}|"| | 
					
						
							| 
									
										
										
										
											2016-08-11 05:56:50 +00:00
										 |  |  |         #sed "s|%FILE2%|$refPSD_tabfile|"| | 
					
						
							| 
									
										
										
										
											2016-08-11 06:33:49 +00:00
										 |  |  |         #sed "s|%LABEL2%|${ref_band}|"| | 
					
						
							| 
									
										
										
										
											2016-08-11 05:56:50 +00:00
										 |  |  |         sed "s|%YMIN%|$ymin|"|sed "s|%YMAX|$ymax|"| | 
					
						
							|  |  |  |         sed "s|%OUTPUTFILE%|$PSD_plotfile|" > tmp.gp | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  |     gnuplot tmp.gp | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Plot time lags and save using gnuplot | 
					
						
							| 
									
										
										
										
											2016-07-13 20:16:09 +00:00
										 |  |  | #    read ymin ymax <<< $(ywindow_of $timelag_tabfile) | 
					
						
							| 
									
										
										
										
											2016-08-11 06:33:49 +00:00
										 |  |  |     cat scripts/templates/timelag.gp| | 
					
						
							| 
									
										
										
										
											2016-08-11 05:56:50 +00:00
										 |  |  |         sed "s|%TITLE%|Time Lag for Lightcurve $echo_band relative to $ref_band|"| | 
					
						
							|  |  |  |         sed "s|%SUBTITLE%|as reported by Fausnaugh et. al, STORM III, 2016|"| | 
					
						
							|  |  |  |         sed "s|%FILE1%|$timelag_tabfile|"| | 
					
						
							| 
									
										
										
										
											2016-08-11 06:33:49 +00:00
										 |  |  |         sed "s|%LABEL1%|${echo_band}|"| | 
					
						
							| 
									
										
										
										
											2016-08-11 05:56:50 +00:00
										 |  |  |         sed "s|%YMIN%|$ymin|"|sed "s|%YMAX|$ymax|"| | 
					
						
							|  |  |  |         sed "s|%OUTPUTFILE%|$timelag_plotfile|" > tmp.gp | 
					
						
							| 
									
										
										
										
											2016-07-13 03:28:11 +00:00
										 |  |  |     gnuplot tmp.gp | 
					
						
							| 
									
										
										
										
											2016-07-12 20:24:21 +00:00
										 |  |  | done | 
					
						
							| 
									
										
										
										
											2016-07-12 20:37:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-13 20:16:09 +00:00
										 |  |  | rm tmp.* |