From d4a5502752de46cc81d11852090fc2313343da64 Mon Sep 17 00:00:00 2001
From: cal <cal@ldas-pcdev6.ligo-wa.caltech.edu>
Date: Mon, 19 Aug 2019 12:36:08 -0700
Subject: [PATCH] Edits to plotting scripts for calibration checks

---
 .../check_calibration/ASD_comparison_plots     |  8 ++++----
 .../check_calibration/response_function.py     |  6 +++---
 .../check_calibration/timeserieskappas.py      | 18 ++++++++++++++++++
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/gstlal-calibration/tests/check_calibration/ASD_comparison_plots b/gstlal-calibration/tests/check_calibration/ASD_comparison_plots
index 9d9769175f..afd2a34fce 100755
--- a/gstlal-calibration/tests/check_calibration/ASD_comparison_plots
+++ b/gstlal-calibration/tests/check_calibration/ASD_comparison_plots
@@ -40,7 +40,7 @@ calcs_asd = calcs_data.asd(4, 2, method = 'lal_median_mean')
 hoft_asd = hoft_data.asd(4, 2, method = 'lal_median_mean')
 if options.analyze_additional_hoft_channel:
 	additional_hoft_asd = additional_hoft_data.asd(4,2, method = 'lal_median_mean')
-	additional_hoft_asd = additional_hoft_asd.filter([30]*6, [0.3]*6, 1e-12 / 4e3)
+	#additional_hoft_asd = additional_hoft_asd.filter([30]*6, [0.3]*6, 1e-12 / 4e3)
 
 #dewhiten CALCS
 calcs_asd = calcs_asd.filter([30]*6, [0.3]*6, 1e-12 / 4e3)
@@ -53,7 +53,7 @@ if options.analyze_additional_hoft_channel:
 ax = plot.gca()
 ax.set_ylabel('Strain [Hz $^{-1/2}$]', fontname = 'Times', fontsize = 18)
 ax.set_xlabel('Frequency [Hz]', fontname = 'Times', fontsize = 18)
-ax.legend([r'CAL-DELTAL\_EXTERNAL', r'GDS-CALIB\_STRAIN', r'CAL-CFTD\_DELTAL\_EXTERNAL'], loc='upper right', fontsize='small')
+ax.legend([r'CAL-DELTAL\_EXTERNAL', r'GDS-CALIB\_STRAIN', r'DCS-CALIB\_STRAIN'], loc='upper right', fontsize='small')
 ax.set_xlim(0.5,8192)
 ax.set_ylim(1e-24,1e-16)
 plot.save('%s_%s_%s_spectrum_comparison.png' % (options.ifo, start_time, end_time))
@@ -69,7 +69,7 @@ if options.analyze_additional_hoft_channel:
 ax = plot.gca()
 ax.set_ylabel('Strain [Hz $^{-1/2}$]', fontname = 'Times', fontsize = 18)
 ax.set_xlabel('Frequency [Hz]', fontname = 'Times', fontsize = 18)
-ax.legend([r'GDS h(t) ASD / CALCS h(t) ASD', r'CALCS h(t) ASD / CFTD CALCS h(t) ASD', r'GDS h(t) ASD / CFTD CALCS h(t) ASD'], loc='upper right', fontsize='small')
-ax.set_xlim(5,5000)
+ax.legend([r'GDS h(t) ASD / CALCS h(t) ASD', r'CALCS h(t) ASD / DCS h(t) ASD', r'GDS h(t) ASD / DCS h(t) ASD'], loc='upper right', fontsize='small')
+ax.set_xlim(0.5,8192)
 ax.set_ylim(0.75, 1.25)
 plot.save('%s_%s_%s_ASD_residual.png' % (options.ifo, start_time, end_time))
diff --git a/gstlal-calibration/tests/check_calibration/response_function.py b/gstlal-calibration/tests/check_calibration/response_function.py
index 976321a5a5..c705b08f29 100644
--- a/gstlal-calibration/tests/check_calibration/response_function.py
+++ b/gstlal-calibration/tests/check_calibration/response_function.py
@@ -154,7 +154,7 @@ if options.analyze_calcs_hoft:
 	plot.add_frequencyseries(CALCS_tf, dB=False, color='#4ba6ff', linewidth=2)
 if options.analyze_additional_hoft:
 	plot.add_frequencyseries(additional_hoft_tf*3995.1, dB = False, color="#94ded7", linewidth=2)
-plot.legend([r'Reference model response function', r'GDS h(t) derived response function', r'CALCS h(t) derived response function'], loc='upper right', fontsize='x-small')
+plot.legend([r'Reference model response function', r'GDS h(t) derived response function', r'CALCS h(t) derived response function', r'DCS h(t) derived response function'], loc='upper right', fontsize='x-small')
 # FIXME: Figure out how to make the legend and title appropriate and flexible
 plot.maxes.set_yscale('log')
 plot.paxes.set_yscale("linear")
@@ -172,7 +172,7 @@ if options.analyze_calcs_hoft:
 	plot.add_frequencyseries(ratio_CALCS, dB = False, color='#4ba6ff',linewidth=2)
 if options.analyze_additional_hoft:
 	plot.add_frequencyseries(ratio_additional_hoft*3995.1, dB = False, color="#94ded7", linewidth=2)
-plot.legend([r'GDS h(t) derived response / Reference model response', 'CALCS h(t) derived response / Reference model response'], loc='upper right', fontsize='small')
+plot.legend([r'GDS h(t) derived response / Reference model response', r'CALCS h(t) derived response / Reference model response', r'DCS h(t) derived response / Reference model response'], loc='upper right', fontsize='small')
 plot.maxes.set_yscale('linear')
 plot.paxes.set_yscale('linear')
 plot.maxes.set_ylim(0,2)
@@ -183,7 +183,7 @@ if options.analyze_calcs_hoft:
 	plot.add_frequencyseries(ratio_CALCS, dB = False, color='#4ba6ff',linewidth=2)
 if options.analyze_additional_hoft:
 	plot.add_frequencyseries(ratio_additional_hoft*3995.1, dB = False, color="#94ded7", linewidth=2)
-plot.legend([r'GDS h(t) derived response / Reference model response', r'CALCS h(t) derived response / Reference model response'], loc='upper right', fontsize='small')
+plot.legend([r'GDS h(t) derived response / Reference model response', r'CALCS h(t) derived response / Reference model response', r'DCS h(t) derived response / Reference model response'], loc='upper right', fontsize='small')
 plot.maxes.set_yscale('linear')
 plot.paxes.set_yscale('linear')
 plot.maxes.set_ylim(.9, 1.1)
diff --git a/gstlal-calibration/tests/check_calibration/timeserieskappas.py b/gstlal-calibration/tests/check_calibration/timeserieskappas.py
index a6927b2520..320f2fd746 100644
--- a/gstlal-calibration/tests/check_calibration/timeserieskappas.py
+++ b/gstlal-calibration/tests/check_calibration/timeserieskappas.py
@@ -13,6 +13,9 @@ parser.add_option("--ifo", metavar = "name", help = "Interferometer to perform t
 parser.add_option("--frame-cache", metavar = "name", help = "Filename for frame cache to be analyzed.")
 parser.add_option("--channel-list", metavar = "list", help = "List of channels to be plotted.")
 parser.add_option("--front-end-channel-list", metavar = "list", help = "List of channels to be plotted from the front-end.")
+parser.add_option("--analyze-additional-hoft", action = "store_true", help = "Set this to analyze an additional h(t) channel.")
+parser.add_option("--additional-hoft-frames-cache", metavar = "name", help = "If desired, provide an additional frame cache for a secondary h(t) data stream to be analyzed.")
+parser.add_option("--additional-channel-list", metavar = "list", help = "List of channels to be plotted from additional h(t) frames.")
 
 options, filenames = parser.parse_args()
 
@@ -28,6 +31,17 @@ if options.channel_list is not None:
 else:
 	raise ValueError('Channel list option must be set.')
 
+if options.analyze_additional_hoft:
+	additional_channel_list = []
+	if options.additional_channel_list is not None:
+		additional_channels = options.additional_channel_list.split(',')
+		for channel in additional_channels:
+			additional_channel_list.append((ifo, channel))
+		plot_additional_hoft = True
+	else:
+		plot_additional_hoft = False
+
+
 front_end_channel_list = []
 if options.front_end_channel_list is not None:
 	front_end_channels = options.front_end_channel_list.split(',')
@@ -40,6 +54,8 @@ else:
 data = TimeSeriesDict.read(options.frame_cache, map("%s:%s".__mod__, channel_list), start = start, end = end)
 if plot_front_end:
 	front_end_data = TimeSeriesDict.fetch(map("%s:%s".__mod__, front_end_channel_list), start = start, end = end)
+if plot_additional_hoft:
+	additional_hoft_data = TimeSeriesDict.read(options.additional_hoft_frames_cache, map("%s:%s".__mod__, additional_channel_list), start = start, end = end)
 
 print(map("%s:%s".__mod__, front_end_channel_list))
 
@@ -50,6 +66,8 @@ for n, channel in enumerate(channels):
 	ax = plot.gca()
 	if plot_front_end:
 		ax.plot(front_end_data["%s:%s" % (ifo, front_end_channels[n])])
+	if plot_additional_hoft:
+		ax.plot(additional_hoft_data["%s:%s" % (ifo, additional_channels[n])])
 	ax.set_ylabel('Correction value')
 	plot.gca().legend()
 	#title = item
-- 
GitLab