From e71c420e985a8fb3d5d2b55b9c4bd5a3ce7d67df Mon Sep 17 00:00:00 2001
From: Aaron Viets <aaron.viets@ligo.org>
Date: Sat, 27 Oct 2018 14:55:53 -0700
Subject: [PATCH] gstlal_compute_strain:  Only use UIM line for computing
 kappa_U. Added another coherence uncertainty bit the the calib state vector.

---
 gstlal-calibration/bin/gstlal_compute_strain  | 381 ++++++++++--------
 .../tests/H1DCS_AllCorrections_Cleaning.ini   |   2 +
 .../H1DCS_FreqIndepCorrections_Cleaning.ini   |   2 +
 3 files changed, 212 insertions(+), 173 deletions(-)

diff --git a/gstlal-calibration/bin/gstlal_compute_strain b/gstlal-calibration/bin/gstlal_compute_strain
index a08e38bc2f..94a44eccab 100755
--- a/gstlal-calibration/bin/gstlal_compute_strain
+++ b/gstlal-calibration/bin/gstlal_compute_strain
@@ -318,7 +318,6 @@ compute_kappatst = Config.getboolean("TDCFConfigurations", "computekappatst")
 compute_kappapu = Config.getboolean("TDCFConfigurations", "computekappapu")
 compute_kappapum = Config.getboolean("TDCFConfigurations", "computekappapum")
 compute_kappauim = Config.getboolean("TDCFConfigurations", "computekappauim")
-use_uim_line = Config.getboolean("TDCFConfigurations", "useuimline")
 compute_kappac = Config.getboolean("TDCFConfigurations", "computekappac")
 compute_fcc = Config.getboolean("TDCFConfigurations", "computefcc")
 compute_fs = Config.getboolean("TDCFConfigurations", "computefs")
@@ -402,13 +401,13 @@ try:
 	if act_pcal_line_freq > 10:
 		pcal_line_removal_dict["pcal1"] = [None, act_pcal_line_freq, pcal_corr_at_act_freq_real, pcal_corr_at_act_freq_imag, False]
 except:
-	if compute_kappatst or compute_kappapu or compute_kappauim or compute_kappac or compute_fcc or compute_fs or compute_srcq:
+	if compute_kappatst or compute_kappapum or compute_kappauim or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
 		raise ValueError("Cannot compute any time-dependent correction factors, as the ~30 Hz pcal line frequency is not in the filters file")
 try:
 	darm_ctrl_line_freq = float(filters["ka_esd_line_freq"])
 except:
-	if(compute_kappapu or (compute_kappauim and not use_uim_line)):
-		raise ValueError("Cannot compute kappa_U or kappa_PU using DARM ctrl line, because the specified filters do not have the DARM ctrl line frequency")
+	if compute_kappapu:
+		raise ValueError("Cannot compute kappa_PU using DARM ctrl line, because the specified filters do not have the DARM ctrl line frequency")
 try:
 	opt_gain_fcc_line_freq = float(filters["kc_pcal_line_freq"])
 	pcal_corr_at_opt_gain_fcc_freq_real = float(filters["kc_pcal_corr_re"])
@@ -423,21 +422,21 @@ try:
 	if esd_act_line_freq > 10:
 		act_line_removal_dict["esd1"] = [None, esd_act_line_freq, "EP10_real", "EP10_imag", False, apply_complex_kappatst, apply_kappatst, None]
 except:
-	if compute_kappatst or compute_kappapu or (compute_kappauim and not use_uim_line) or compute_kappac or compute_fcc or compute_fs or compute_srcq:
-		raise ValueError("Cannot compute any time-dependent correction factors, as the ESD line frequency is not in the filters file")
+	if compute_kappatst or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
+		raise ValueError("Cannot compute time-dependent correction factors, as the ESD line frequency is not in the filters file")
 try:
 	pum_act_line_freq = float(filters["pum_act_line_freq"])
 	if pum_act_line_freq > 10:
 		act_line_removal_dict["pum1"] = [None, pum_act_line_freq, "EP23_real", "EP23_imag", False, apply_complex_kappapum, apply_kappapum, None]
 except:
-	if compute_kappapum:
+	if compute_kappapum or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
 		raise ValueError("Cannot compute kappa_PUM, as the specified filters file does not contain the needed calibration line frequency")
 try:
 	uim_act_line_freq = float(filters["uim_act_line_freq"])
 	if uim_act_line_freq > 10:
 		act_line_removal_dict["uim1"] = [None, uim_act_line_freq, "EP24_real", "EP24_imag", False, apply_complex_kappauim, apply_kappauim, None]
 except:
-	if compute_kappauim and use_uim_line:
+	if compute_kappauim or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
 		raise ValueError("Cannot compute kappa_UIM using the UIM actuation line, as the specified filters file does not contain that calibration line frequency")
 
 try:
@@ -665,46 +664,41 @@ if compute_calib_statevector:
 # If we are using the front-end EPICS records to either compute the TDCFs or the CALIB_STATE_VECTOR, we need to add those channels
 # Needed for kappa_tst, kappa_pum, kappa_uim, kappa_pu, kappa_c, f_cc, f_s, and Q
 if not factors_from_filters_file or compute_calib_statevector:
-	if (compute_kappatst or compute_kappapu or compute_kappapum or compute_kappauim or compute_kappac or compute_fcc or compute_fs or compute_srcq):
+	# Needed for kappa_TST
+	if compute_kappatst or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
 		channel_list.extend(((instrument, ChannelNames["ep1realchannel"]), (instrument, ChannelNames["ep1imagchannel"])))
 		headkeys.extend(("EP1_real", "EP1_imag"))
 	# These are needed for kappa_PUM
-	if compute_kappapum or (compute_kappauim and (not use_uim_line or compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+	if compute_kappapum or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
 		channel_list.extend(((instrument, ChannelNames["ep15realchannel"]), (instrument, ChannelNames["ep15imagchannel"])))
 		headkeys.extend(("EP15_real", "EP15_imag"))
 	# These are needed for kappa_UIM
-	if compute_kappauim or (compute_kappapum and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
-		if use_uim_line:
-			channel_list.extend(((instrument, ChannelNames["ep22realchannel"]), (instrument, ChannelNames["ep22imagchannel"])))
-			headkeys.extend(("EP22_real", "EP22_imag"))
-		else:
-			channel_list.extend(((instrument, ChannelNames["ep2realchannel"]), (instrument, ChannelNames["ep2imagchannel"]), (instrument, ChannelNames["ep4realchannel"]), (instrument, ChannelNames["ep4imagchannel"]), (instrument, ChannelNames["ep16realchannel"]), (instrument, ChannelNames["ep16imagchannel"]), (instrument, ChannelNames["ep17realchannel"]), (instrument, ChannelNames["ep17imagchannel"])))
-			headkeys.extend(("EP2_real", "EP2_imag", "EP4_real", "EP4_imag", "EP16_real", "EP16_imag", "EP17_real", "EP17_imag"))
+	if compute_kappauim or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+		channel_list.extend(((instrument, ChannelNames["ep22realchannel"]), (instrument, ChannelNames["ep22imagchannel"])))
+		headkeys.extend(("EP22_real", "EP22_imag"))
+		channel_list.extend(((instrument, ChannelNames["ep2realchannel"]), (instrument, ChannelNames["ep2imagchannel"]), (instrument, ChannelNames["ep4realchannel"]), (instrument, ChannelNames["ep4imagchannel"]), (instrument, ChannelNames["ep16realchannel"]), (instrument, ChannelNames["ep16imagchannel"]), (instrument, ChannelNames["ep17realchannel"]), (instrument, ChannelNames["ep17imagchannel"])))
+		headkeys.extend(("EP2_real", "EP2_imag", "EP4_real", "EP4_imag", "EP16_real", "EP16_imag", "EP17_real", "EP17_imag"))
 	# These are needed for kappa_PU
-	if (compute_kappapu or ((compute_kappac or compute_fcc or compute_fs or compute_srcq) and not (compute_kappapum or compute_kappauim))):
-		channel_list.extend(((instrument, ChannelNames["ep3realchannel"]), (instrument, ChannelNames["ep3imagchannel"])))
-		headkeys.extend(("EP3_real", "EP3_imag"))
-		# Additionally, if kappa_UIM is not calculated using the DARM line, we need these
-		if use_uim_line or not (compute_kappauim or (compute_kappapum and (compute_kappac or compute_fcc or compute_fs or compute_srcq))):
-			channel_list.extend(((instrument, ChannelNames["ep2realchannel"]), (instrument, ChannelNames["ep2imagchannel"]), (instrument, ChannelNames["ep4realchannel"]), (instrument, ChannelNames["ep4imagchannel"])))
-			headkeys.extend(("EP2_real", "EP2_imag", "EP4_real", "EP4_imag"))
+	if compute_kappapu:
+		channel_list.extend(((instrument, ChannelNames["ep2realchannel"]), (instrument, ChannelNames["ep2imagchannel"]), (instrument, ChannelNames["ep3realchannel"]), (instrument, ChannelNames["ep3imagchannel"]), (instrument, ChannelNames["ep4realchannel"]), (instrument, ChannelNames["ep4imagchannel"])))
+		headkeys.extend(("EP2_real", "EP2_imag", "EP3_real", "EP3_imag", "EP4_real", "EP4_imag"))
 	# These are needed for kappa_C and f_cc
 	if compute_kappac or compute_fcc or compute_fs or compute_srcq:
-		if compute_kappapum or compute_kappauim:
-			channel_list.extend(((instrument, ChannelNames["ep6realchannel"]), (instrument, ChannelNames["ep6imagchannel"]), (instrument, ChannelNames["ep7realchannel"]), (instrument, ChannelNames["ep7imagchannel"]), (instrument, ChannelNames["ep8realchannel"]), (instrument, ChannelNames["ep8imagchannel"]), (instrument, ChannelNames["ep18realchannel"]), (instrument, ChannelNames["ep18imagchannel"]), (instrument, ChannelNames["ep19realchannel"]), (instrument, ChannelNames["ep19imagchannel"])))
-			headkeys.extend(("EP6_real", "EP6_imag", "EP7_real", "EP7_imag", "EP8_real", "EP8_imag", "EP18_real", "EP18_imag", "EP19_real", "EP19_imag"))
-		else:
+		if compute_kappapu:
 			channel_list.extend(((instrument, ChannelNames["ep6realchannel"]), (instrument, ChannelNames["ep6imagchannel"]), (instrument, ChannelNames["ep7realchannel"]), (instrument, ChannelNames["ep7imagchannel"]), (instrument, ChannelNames["ep8realchannel"]), (instrument, ChannelNames["ep8imagchannel"]), (instrument, ChannelNames["ep9realchannel"]), (instrument, ChannelNames["ep9imagchannel"])))
 			headkeys.extend(("EP6_real", "EP6_imag", "EP7_real", "EP7_imag", "EP8_real", "EP8_imag", "EP9_real", "EP9_imag"))
+		else:
+			channel_list.extend(((instrument, ChannelNames["ep6realchannel"]), (instrument, ChannelNames["ep6imagchannel"]), (instrument, ChannelNames["ep7realchannel"]), (instrument, ChannelNames["ep7imagchannel"]), (instrument, ChannelNames["ep8realchannel"]), (instrument, ChannelNames["ep8imagchannel"]), (instrument, ChannelNames["ep18realchannel"]), (instrument, ChannelNames["ep18imagchannel"]), (instrument, ChannelNames["ep19realchannel"]), (instrument, ChannelNames["ep19imagchannel"])))
+			headkeys.extend(("EP6_real", "EP6_imag", "EP7_real", "EP7_imag", "EP8_real", "EP8_imag", "EP18_real", "EP18_imag", "EP19_real", "EP19_imag"))
 
 	# These are needed if we compute the optical spring frequency and/or Q-factor of the Signal Recycling Cavity (SRC)
 	if compute_fs or compute_srcq:
-		if compute_kappapum or compute_kappauim:
-			channel_list.extend(((instrument, ChannelNames["ep11realchannel"]), (instrument, ChannelNames["ep11imagchannel"]), (instrument, ChannelNames["ep12realchannel"]), (instrument, ChannelNames["ep12imagchannel"]), (instrument, ChannelNames["ep13realchannel"]), (instrument, ChannelNames["ep13imagchannel"]), (instrument, ChannelNames["ep20realchannel"]), (instrument, ChannelNames["ep20imagchannel"]), (instrument, ChannelNames["ep21realchannel"]), (instrument, ChannelNames["ep21imagchannel"])))
-			headkeys.extend(("EP11_real", "EP11_imag", "EP12_real", "EP12_imag", "EP13_real", "EP13_imag", "EP20_real", "EP20_imag", "EP21_real", "EP21_imag"))
-		else:
+		if compute_kappapu:
 			channel_list.extend(((instrument, ChannelNames["ep11realchannel"]), (instrument, ChannelNames["ep11imagchannel"]), (instrument, ChannelNames["ep12realchannel"]), (instrument, ChannelNames["ep12imagchannel"]), (instrument, ChannelNames["ep13realchannel"]), (instrument, ChannelNames["ep13imagchannel"]), (instrument, ChannelNames["ep14realchannel"]), (instrument, ChannelNames["ep14imagchannel"])))
 			headkeys.extend(("EP11_real", "EP11_imag", "EP12_real", "EP12_imag", "EP13_real", "EP13_imag", "EP14_real", "EP14_imag"))
+		else:
+			channel_list.extend(((instrument, ChannelNames["ep11realchannel"]), (instrument, ChannelNames["ep11imagchannel"]), (instrument, ChannelNames["ep12realchannel"]), (instrument, ChannelNames["ep12imagchannel"]), (instrument, ChannelNames["ep13realchannel"]), (instrument, ChannelNames["ep13imagchannel"]), (instrument, ChannelNames["ep20realchannel"]), (instrument, ChannelNames["ep20imagchannel"]), (instrument, ChannelNames["ep21realchannel"]), (instrument, ChannelNames["ep21imagchannel"])))
+			headkeys.extend(("EP11_real", "EP11_imag", "EP12_real", "EP12_imag", "EP13_real", "EP13_imag", "EP20_real", "EP20_imag", "EP21_real", "EP21_imag"))
 	# EP10 is needed to remove the ESD line
 	if remove_cal_lines and "esd1" in act_line_removal_dict.keys():
 		channel_list.extend(((instrument, ChannelNames["ep10realchannel"]), (instrument, ChannelNames["ep10imagchannel"])))
@@ -721,23 +715,38 @@ if not factors_from_filters_file or compute_calib_statevector:
 	# If we are using pre-computed coherence to gate kappas
 if use_coherence:
 	if compute_kappatst or compute_kappapum or compute_kappauim or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
-		channel_list.extend(((instrument, ChannelNames["cohuncsusline1channel"]), (instrument, ChannelNames["cohuncpcalyline1channel"]), (instrument, ChannelNames["cohuncdarmline1channel"])))
-		headkeys.extend(("pcaly_line1_coh", "sus_coh", "darm_coh"))
+		channel_list.append((instrument, ChannelNames["cohuncpcalyline1channel"]))
+		headkeys.append("pcaly_line1_coh")
+	if compute_kappatst or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
+		channel_list.append((instrument, ChannelNames["cohuncsusline3channel"]))
+		headkeys.append("sus_line3_coh")
+	if compute_kappapu:
+		channel_list.append((instrument, ChannelNames["cohuncdarmline1channel"]))
+		headkeys.append("darm_coh")
+	if compute_kappapum or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+		channel_list.append((instrument, "cohuncsusline2channel"))
+		headkeys.append("sus_line2_coh")
+	if compute_kappauim or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+		channel_list.append((instrument, "cohuncsusline1channel"))
+		headkeys.append("sus_line1_coh")
 	if compute_kappac or compute_fcc or compute_fs or compute_srcq:
 		channel_list.append((instrument, ChannelNames["cohuncpcalyline2channel"]))
 		headkeys.append("pcaly_line2_coh")
+	if (compute_fs or compute_srcq) and (src_pcal_line_freq != act_pcal_line_freq):
+		channel_list.append((instrument, ChannelNames["cohuncpcalyline4channel"]))
+		headkeys.append("pcaly_line4_coh")
 
 # We also need excitation channels for computing kappas
-if compute_kappatst or compute_kappapum or compute_kappauim or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq or (remove_cal_lines and "esd1" in act_line_removal_dict.keys()):
+if compute_kappatst or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq or (remove_cal_lines and "esd1" in act_line_removal_dict.keys()):
 	channel_list.append((instrument, ChannelNames["tstexcchannel"]))
 	headkeys.append("tstexc")
-if compute_kappapum or (compute_kappauim and (compute_kappac or compute_fcc or compute_fs or compute_srcq)) or (remove_cal_lines and "pum1" in act_line_removal_dict.keys()):
+if compute_kappapum or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)) or (remove_cal_lines and "pum1" in act_line_removal_dict.keys()):
 	channel_list.append((instrument, ChannelNames["pumexcchannel"]))
 	headkeys.append("pumexc")
-if use_uim_line and (compute_kappauim or compute_kappapum and (compute_kappac or compute_fcc or compute_fs or compute_srcq)) or (remove_cal_lines and "uim1" in act_line_removal_dict.keys()):
+if compute_kappauim or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)) or (remove_cal_lines and "uim1" in act_line_removal_dict.keys()):
 	channel_list.append((instrument, ChannelNames["uimexcchannel"]))
 	headkeys.append("uimexc")
-if compute_kappapu or ((not use_uim_line or not (compute_kappapum or compute_kappauim)) and (compute_kappauim or compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+if compute_kappapu:
 	channel_list.append((instrument, ChannelNames["darmexcchannel"]))
 	headkeys.append("darmexc")
 
@@ -771,7 +780,7 @@ if ChannelNames["witnesschannellist"] != "None":
 	witness_notch_frequencies = DataCleaningConfigs["witnessnotchfrequencies"].split(';')
 	witness_rates = SampleRates["witnesschannelsr"].split(';')
 	if len(witness_channel_list) != len(witness_notch_frequencies) or len(witness_channel_list) != len(witness_rates):
-		raise ValueError("WitnessChannelList, WitnessChannelSR, and WitnessNotchFrequencies must all be the same length, i.e, they must all have the same number of semicolons (;)")
+		raise ValueError("WitnessChannelList, WitnessChannelSR, and WitnessNotchFrequencies must all be the same length, i.e., they must all have the same number of semicolons (;)")
 	for i in range(0, len(witness_channel_list)):
 		witness_channel_list[i] = witness_channel_list[i].split(',')
 		for j in range(0, len(witness_channel_list[i])):
@@ -787,7 +796,6 @@ if ChannelNames["witnesschannellist"] != "None":
 else:
 	witness_channel_list = None
 
-
 ####################################################################################################
 ####################################### Main Pipeline ##############################################
 ####################################################################################################
@@ -861,36 +869,53 @@ if use_coherence:
 	if compute_kappatst or compute_kappapum or compute_kappauim or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
 		pcaly_line1_coh = calibration_parts.caps_and_progress(pipeline, head_dict["pcaly_line1_coh"], coh_caps, "pcaly_line1_coh")
 		pcaly_line1_coh = calibration_parts.mkresample(pipeline, pcaly_line1_coh, 0, False, compute_calib_factors_caps)
-		sus_coh = calibration_parts.caps_and_progress(pipeline, head_dict["sus_coh"], coh_caps, "sus_coh")
-		sus_coh = calibration_parts.mkresample(pipeline, sus_coh, 0, False, compute_calib_factors_caps)
+		pcaly_line1_coh = pipeparts.mktee(pipeline, pcaly_line1_coh)
+	if compute_kappatst or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
+		sus_line3_coh = calibration_parts.caps_and_progress(pipeline, head_dict["sus_line3_coh"], coh_caps, "sus_line3_coh")
+		sus_line3_coh = calibration_parts.mkresample(pipeline, sus_line3_coh, 0, False, compute_calib_factors_caps)
+		sus_line3_coh = pipeparts.mktee(pipeline, sus_line3_coh)
+	if compute_kappapum or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+		sus_line2_coh = calibration_parts.caps_and_progress(pipeline, head_dict["sus_line2_coh"], coh_caps, "sus_line2_coh")
+		sus_line2_coh = calibration_parts.mkresample(pipeline, sus_line2_coh, 0, False, compute_calib_factors_caps)
+		sus_line2_coh = pipeparts.mktee(pipeline, sus_line2_coh)
+	if compute_kappauim or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+		sus_line1_coh = calibration_parts.caps_and_progress(pipeline, head_dict["sus_line1_coh"], coh_caps, "sus_line1_coh")
+		sus_line1_coh = calibration_parts.mkresample(pipeline, sus_line1_coh, 0, False, compute_calib_factors_caps)
+		sus_line1_coh = pipeparts.mktee(pipeline, sus_line1_coh)
+	if compute_kappapu:
 		darm_coh = calibration_parts.caps_and_progress(pipeline, head_dict["darm_coh"], coh_caps, "darm_coh")
 		darm_coh = calibration_parts.mkresample(pipeline, darm_coh, 0, False, compute_calib_factors_caps)
-		pcaly_line1_coh = pipeparts.mktee(pipeline, pcaly_line1_coh)
-		sus_coh = pipeparts.mktee(pipeline, sus_coh)
 		darm_coh = pipeparts.mktee(pipeline, darm_coh)
 	if compute_kappac or compute_fcc or compute_fs or compute_srcq:
 		pcaly_line2_coh = calibration_parts.caps_and_progress(pipeline, head_dict["pcaly_line2_coh"], coh_caps, "pcaly_line2_coh")
 		pcaly_line2_coh = calibration_parts.mkresample(pipeline, pcaly_line2_coh, 0, False, compute_calib_factors_caps)
 		pcaly_line2_coh = pipeparts.mktee(pipeline, pcaly_line2_coh)
+	if compute_fs or compute_srcq:
+		if src_pcal_line_freq != act_pcal_line_freq:
+			pcaly_line4_coh = calibration_parts.caps_and_progress(pipeline, head_dict["pcaly_line4_coh"], coh_caps, "pcaly_line4_coh")
+			pcaly_line4_coh = calibration_parts.mkresample(pipeline, pcaly_line4_coh, 0, False, compute_calib_factors_caps)
+			pcaly_line4_coh = pipeparts.mktee(pipeline, pcaly_line4_coh)
+		else:
+			pcaly_line4_coh = pcaly_line1_coh
 
-if compute_kappatst or compute_kappapum or compute_kappauim or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq or (remove_cal_lines and "esd1" in act_line_removal_dict.keys()):
+if compute_kappatst or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq or (remove_cal_lines and "esd1" in act_line_removal_dict.keys()):
 	tstexccaps = "audio/x-raw, format=F64LE, rate=%d" % tst_exc_sr
 	tstexc = calibration_parts.caps_and_progress(pipeline, head_dict["tstexc"], tstexccaps, "tstexc")
 	act_line_removal_dict["esd1"][0] = tstexc
-if compute_kappapum or (compute_kappauim and (compute_kappac or compute_fcc or compute_fs or compute_srcq)) or (remove_cal_lines and "pum1" in act_line_removal_dict.keys()):
+if compute_kappapum or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)) or (remove_cal_lines and "pum1" in act_line_removal_dict.keys()):
 	pumexccaps = "audio/x-raw, format=F64LE, rate=%d" % pum_exc_sr
 	pumexc = calibration_parts.caps_and_progress(pipeline, head_dict["pumexc"], pumexccaps, "pumexc")
 	act_line_removal_dict["pum1"][0] = pumexc
-if use_uim_line and (compute_kappauim or compute_kappapum and (compute_kappac or compute_fcc or compute_fs or compute_srcq)) or (remove_cal_lines and "uim1" in act_line_removal_dict.keys()):
+if compute_kappauim or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)) or (remove_cal_lines and "uim1" in act_line_removal_dict.keys()):
 	uimexccaps = "audio/x-raw, format=F64LE, rate=%d" % uim_exc_sr
 	uimexc = calibration_parts.caps_and_progress(pipeline, head_dict["uimexc"], uimexccaps, "uimexc")
 	act_line_removal_dict["uim1"][0] = uimexc
 
-if compute_kappapu or ((not use_uim_line or not (compute_kappapum or compute_kappauim)) and (compute_kappauim or compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+if compute_kappapu:
 	darmexc = calibration_parts.caps_and_progress(pipeline, head_dict["darmexc"], hoft_caps, "darmexc")
 
 # Set up computations for kappa_tst, kappa_pum, kappa_uim, kappa_pu,kappa_c, f_cc, f_s, and Q, if applicable
-if compute_kappac or compute_fcc or compute_kappatst or compute_kappapu or compute_srcq or compute_fs:
+if compute_kappatst or compute_kappapum or compute_kappauim or compute_kappapu or compute_kappac or compute_fcc or compute_srcq or compute_fs:
 
 	# pcal excitation channel, which will be demodulated
 	pcal = calibration_parts.caps_and_progress(pipeline, head_dict["pcal"], hoft_caps, "pcal")
@@ -949,11 +974,9 @@ if compute_kappac or compute_fcc or compute_kappatst or compute_kappapu or compu
 
 		if use_coherence:
 			# Gate kappa_tst with the coherence of the PCALY_line1 line
-			ktst_gated = calibration_parts.mkgate(pipeline, ktst, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_tst with the coherence of the suspension line
-			ktst_gated = calibration_parts.mkgate(pipeline, ktst_gated, sus_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_tst with the coherence of the DARM line
-			ktst_gated = calibration_parts.mkgate(pipeline, ktst_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+			ktst_gated = calibration_parts.mkgate(pipeline, ktst, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'ktstgate1')
+			# Gate kappa_tst with the coherence of the TST (L3) suspension line
+			ktst_gated = calibration_parts.mkgate(pipeline, ktst_gated, sus_line3_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'ktstgate2')
 
 			# Smooth kappa_tst
 			smooth_ktst = calibration_parts.smooth_complex_kappas(pipeline, ktst_gated, expected_kappatst_real, expected_kappatst_imag, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
@@ -975,7 +998,7 @@ if compute_kappac or compute_fcc or compute_kappatst or compute_kappapu or compu
 				act_line_removal_dict["esd1"][7] = smooth_ktstRtee
 
 # Check if we need to compute kappa_pum
-if compute_kappapum or compute_kappauim and (not use_uim_line or compute_kappac or compute_fcc or compute_fs or compute_srcq):
+if compute_kappapum or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
 	# demodulate the PUM excitation channel at the PUM actuation line frequency
 	pumexc_at_pum_act_freq = calibration_parts.demodulate(pipeline, pumexc, pum_act_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
 	pumexc_at_pum_act_freq = pipeparts.mktee(pipeline, pumexc_at_pum_act_freq)
@@ -1001,11 +1024,9 @@ if compute_kappapum or compute_kappauim and (not use_uim_line or compute_kappac
 
 		if use_coherence:
 			# Gate kappa_pum with the coherence of the PCALY_line1 line
-			kpum_gated = calibration_parts.mkgate(pipeline, kpum, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_pum with the coherence of the suspension line
-			kpum_gated = calibration_parts.mkgate(pipeline, kpum_gated, sus_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_pum with the coherence of the DARM line
-			kpum_gated = calibration_parts.mkgate(pipeline, kpum_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+			kpum_gated = calibration_parts.mkgate(pipeline, kpum, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kpumgate1')
+			# Gate kappa_pum with the coherence of the PUM (L2) suspension line
+			kpum_gated = calibration_parts.mkgate(pipeline, kpum_gated, sus_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kpumgate2')
 
 			# Smooth kappa_pum
 			smooth_kpum = calibration_parts.smooth_complex_kappas(pipeline, kpum_gated, expected_kappapum_real, expected_kappapum_imag, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
@@ -1027,41 +1048,20 @@ if compute_kappapum or compute_kappauim and (not use_uim_line or compute_kappac
 				act_line_removal_dict["pum1"][7] = smooth_kpumRtee
 
 # Check if we need to compute kappa_uim
-if compute_kappauim or (compute_kappapum and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
-	if use_uim_line:
-		# Demodulate DARM_ERR and the UIM excitation channel at the UIM actuation line frequency
-		derr_at_uim_act_freq = calibration_parts.demodulate(pipeline, derrtee, uim_act_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
-		uimexc_at_uim_act_freq = calibration_parts.demodulate(pipeline, uimexc, uim_act_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
-		uimexc_at_uim_act_freq = pipeparts.mktee(pipeline, uimexc_at_uim_act_freq)
-		act_line_removal_dict["uim1"][0] = uimexc_at_uim_act_freq
-		act_line_removal_dict["uim1"][4] = True
-
-		# Compute kappa_uim, either using reference factors from the filters file or reading them from EPICS channels
-		if not factors_from_filters_file:
-			EP22 = calibration_parts.merge_into_complex(pipeline, misc_epics_dict["EP22_real"][0], misc_epics_dict["EP22_imag"][0])
-			kuim = calibration_parts.compute_kappauim_uim_line(pipeline, derr_at_uim_act_freq, uimexc_at_uim_act_freq, pcal_at_act_pcal_freq, derr_at_act_pcal_freq, EP22)
-		else:
-			kuim = calibration_parts.compute_kappauim_from_filters_file_uim_line(pipeline, derr_at_uim_act_freq, uimexc_at_uim_act_freq, pcal_at_act_pcal_freq, derr_at_act_pcal_freq, EP22_real, EP22_imag)
-
+if compute_kappauim or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+	# Demodulate DARM_ERR and the UIM excitation channel at the UIM actuation line frequency
+	derr_at_uim_act_freq = calibration_parts.demodulate(pipeline, derrtee, uim_act_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
+	uimexc_at_uim_act_freq = calibration_parts.demodulate(pipeline, uimexc, uim_act_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
+	uimexc_at_uim_act_freq = pipeparts.mktee(pipeline, uimexc_at_uim_act_freq)
+	act_line_removal_dict["uim1"][0] = uimexc_at_uim_act_freq
+	act_line_removal_dict["uim1"][4] = True
+
+	# Compute kappa_uim, either using reference factors from the filters file or reading them from EPICS channels
+	if not factors_from_filters_file:
+		EP22 = calibration_parts.merge_into_complex(pipeline, misc_epics_dict["EP22_real"][0], misc_epics_dict["EP22_imag"][0])
+		kuim = calibration_parts.compute_kappauim_uim_line(pipeline, derr_at_uim_act_freq, uimexc_at_uim_act_freq, pcal_at_act_pcal_freq, derr_at_act_pcal_freq, EP22)
 	else:
-		# Demodulate DARM_ERR and the darm excitation channel at the darm actuation line frequency
-		derr_at_darm_act_freq = calibration_parts.demodulate(pipeline, derrtee, darm_ctrl_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
-		darmexc_at_darm_act_freq = calibration_parts.demodulate(pipeline, darmexc, darm_ctrl_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
-		if compute_kappapu:
-			derr_at_darm_act_freq = pipeparts.mktee(pipeline, derr_at_darm_act_freq)
-			darmexc_at_darm_act_freq = pipeparts.mktee(pipeline, darmexc_at_darm_act_freq)
-
-		# Compute the factor A(fctrl) that will be used in the computation of kappa_uim, either using reference factors from the filters file or reading them from EPICS channels
-		if not factors_from_filters_file:
-			EP2 = calibration_parts.merge_into_complex(pipeline, misc_epics_dict["EP2_real"][0], misc_epics_dict["EP2_imag"][0])
-			EP4 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP4_real"][0], A_epics_dict["EP4_imag"][0])
-			EP16 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP16_real"][0], A_epics_dict["EP16_imag"][0])
-			EP17 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP17_real"][0], A_epics_dict["EP17_imag"][0])
-			afctrl = calibration_parts.compute_afctrl(pipeline, derr_at_darm_act_freq, darmexc_at_darm_act_freq, pcal_at_act_pcal_freq, derr_at_act_pcal_freq, EP2)
-			kuim = calibration_parts.compute_kappauim(pipeline, EP16, afctrl, ktst, EP4, kpum, EP17)
-		else:
-			afctrl = calibration_parts.compute_afctrl_from_filters_file(pipeline, derr_at_darm_act_freq, darmexc_at_darm_act_freq, pcal_at_act_pcal_freq, derr_at_act_pcal_freq, EP2_real, EP2_imag)
-			kuim = calibration_parts.compute_kappauim_from_filters_file(pipeline, EP16_real, EP16_imag, afctrl, ktst, EP4_real, EP4_imag, kpum, EP17_real, EP17_imag)
+		kuim = calibration_parts.compute_kappauim_from_filters_file_uim_line(pipeline, derr_at_uim_act_freq, uimexc_at_uim_act_freq, pcal_at_act_pcal_freq, derr_at_act_pcal_freq, EP22_real, EP22_imag)
 
 	kuim = pipeparts.mktee(pipeline, kuim)
 
@@ -1072,11 +1072,9 @@ if compute_kappauim or (compute_kappapum and (compute_kappac or compute_fcc or c
 
 		if use_coherence:
 			# Gate kappa_uim with the coherence of the PCALY_line1 line
-			kuim_gated = calibration_parts.mkgate(pipeline, kuim, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_uim with the coherence of the suspension line
-			kuim_gated = calibration_parts.mkgate(pipeline, kuim_gated, sus_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_uim with the coherence of the DARM line
-			kuim_gated = calibration_parts.mkgate(pipeline, kuim_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+			kuim_gated = calibration_parts.mkgate(pipeline, kuim, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kuimgate1')
+			# Gate kappa_uim with the coherence of the UIM (L1) suspension line
+			kuim_gated = calibration_parts.mkgate(pipeline, kuim_gated, sus_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kuimgate1')
 
 			# Smooth kappa_uim
 			smooth_kuim = calibration_parts.smooth_complex_kappas(pipeline, kuim_gated, expected_kappauim_real, expected_kappauim_imag, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
@@ -1098,13 +1096,12 @@ if compute_kappauim or (compute_kappapum and (compute_kappac or compute_fcc or c
 				act_line_removal_dict["uim1"][7] = smooth_kuimRtee
 
 # Check if we need to compute kappa_PU
-if compute_kappapu or (compute_kappac or compute_fcc or compute_fs or compute_srcq) and not (compute_kappapum or compute_kappauim):
-	if use_uim_line or not (compute_kappauim or (compute_kappapum and (compute_kappac or compute_fcc or compute_fs or compute_srcq))):
-		# demodulate excitation channel at darm actuation line frequency
-		darmexc_at_darm_act_freq = calibration_parts.demodulate(pipeline, darmexc, darm_ctrl_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
+if compute_kappapu:
+	# demodulate excitation channel at darm actuation line frequency
+	darmexc_at_darm_act_freq = calibration_parts.demodulate(pipeline, darmexc, darm_ctrl_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
 
-		# demodulate DARM_ERR at the darm actuation line frequency
-		derr_at_darm_act_freq = calibration_parts.demodulate(pipeline, derrtee, darm_ctrl_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
+	# demodulate DARM_ERR at the darm actuation line frequency
+	derr_at_darm_act_freq = calibration_parts.demodulate(pipeline, derrtee, darm_ctrl_line_freq, td, compute_factors_sr, demodulation_filter_time, filter_latency_factor)
 	if dewhitening:
 		# dewhiten DARM_ERR at the darm actuation line frequency
 		derr_at_darm_act_freq = calibration_parts.complex_audioamplify(pipeline, derr_at_darm_act_freq, derr_dewhiten_at_pu_act_freq_real, derr_dewhiten_at_pu_act_freq_imag)
@@ -1123,29 +1120,28 @@ if compute_kappapu or (compute_kappac or compute_fcc or compute_fs or compute_sr
 	kpu = pipeparts.mktee(pipeline, kpu)
 
 	# Now apply the gating and smoothing to \kappa_pu
-	if compute_kappapu:
-		smooth_kpu_nogate = pipeparts.mkgeneric(pipeline, kpu, "lal_smoothkappas", default_kappa_re = expected_kappapu_real, default_kappa_im = expected_kappapu_imag, array_size = median_smoothing_samples, avg_array_size = factors_average_samples, default_to_median = tdcf_default_to_median, filter_latency = filter_latency_factor)
-		smooth_kpuR_nogate, smooth_kpuI_nogate = calibration_parts.split_into_real(pipeline, smooth_kpu_nogate)
+	smooth_kpu_nogate = pipeparts.mkgeneric(pipeline, kpu, "lal_smoothkappas", default_kappa_re = expected_kappapu_real, default_kappa_im = expected_kappapu_imag, array_size = median_smoothing_samples, avg_array_size = factors_average_samples, default_to_median = tdcf_default_to_median, filter_latency = filter_latency_factor)
+	smooth_kpuR_nogate, smooth_kpuI_nogate = calibration_parts.split_into_real(pipeline, smooth_kpu_nogate)
 
-		if use_coherence:
-			# Gate kappa_pu with the coherence of the DARM line
-			kpu_gated = calibration_parts.mkgate(pipeline, kpu, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_pu with the coherence of the PCALY_line1 line
-			kpu_gated = calibration_parts.mkgate(pipeline, kpu_gated, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_pu with the coherence of the suspension coherence
-			kpu_gated = calibration_parts.mkgate(pipeline, kpu_gated, sus_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Smooth kappa_pu
-			smooth_kpu = calibration_parts.smooth_complex_kappas(pipeline, kpu_gated, expected_kappapu_real, expected_kappapu_imag, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
+	if use_coherence:
+		# Gate kappa_pu with the coherence of the DARM line
+		kpu_gated = calibration_parts.mkgate(pipeline, kpu, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kpugate1')
+		# Gate kappa_pu with the coherence of the PCALY_line1 line
+		kpu_gated = calibration_parts.mkgate(pipeline, kpu_gated, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kpugate2')
+		# Gate kappa_pu with the coherence of the suspension coherence
+		kpu_gated = calibration_parts.mkgate(pipeline, kpu_gated, sus_line3_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kpugate3')
+		# Smooth kappa_pu
+		smooth_kpu = calibration_parts.smooth_complex_kappas(pipeline, kpu_gated, expected_kappapu_real, expected_kappapu_imag, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
 
-		else:
-			# Smooth kappa_pu
-			smooth_kpu = calibration_parts.smooth_complex_kappas_no_coherence(pipeline, kpu, kappapu_real_var, kappapu_imag_var, expected_kappapu_real, expected_kappapu_imag, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
+	else:
+		# Smooth kappa_pu
+		smooth_kpu = calibration_parts.smooth_complex_kappas_no_coherence(pipeline, kpu, kappapu_real_var, kappapu_imag_var, expected_kappapu_real, expected_kappapu_imag, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
 
-		smooth_kputee = pipeparts.mktee(pipeline, smooth_kpu)
-		smooth_kpuR, smooth_kpuI = calibration_parts.split_into_real(pipeline, smooth_kputee)
+	smooth_kputee = pipeparts.mktee(pipeline, smooth_kpu)
+	smooth_kpuR, smooth_kpuI = calibration_parts.split_into_real(pipeline, smooth_kputee)
 
-		smooth_kpuRtee = pipeparts.mktee(pipeline, smooth_kpuR)
-		smooth_kpuItee = pipeparts.mktee(pipeline, smooth_kpuI)	
+	smooth_kpuRtee = pipeparts.mktee(pipeline, smooth_kpuR)
+	smooth_kpuItee = pipeparts.mktee(pipeline, smooth_kpuI)	
 
 # Compute \kappa_c and f_cc
 if compute_kappac or compute_fcc or compute_fs or compute_srcq:
@@ -1170,9 +1166,9 @@ if compute_kappac or compute_fcc or compute_fs or compute_srcq:
 		EP6 = calibration_parts.merge_into_complex(pipeline, C_epics_dict["EP6_real"][0], C_epics_dict["EP6_imag"][0])
 		EP7 = calibration_parts.merge_into_complex(pipeline, D_epics_dict["EP7_real"][0], D_epics_dict["EP7_imag"][0])
 		EP8 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP8_real"][0], A_epics_dict["EP8_imag"][0])
-		if compute_kappapum or compute_kappauim:
+		if not compute_kappapu:
 			kpum_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, kpum, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / pum_act_line_freq)
-			kuim_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, kuim, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / (uim_act_line_freq if use_uim_line else darm_ctrl_line_freq))
+			kuim_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, kuim, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / uim_act_line_freq)
 			EP18 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP18_real"][0], A_epics_dict["EP18_imag"][0])
 			EP19 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP19_real"][0], A_epics_dict["EP19_imag"][0])
 			S = calibration_parts.compute_S_split_act(pipeline, EP6, pcal_at_opt_gain_freq, derr_at_opt_gain_freq, EP7, ktst_at_opt_gain_freq, EP8, kpum_at_opt_gain_freq, EP18, kuim_at_opt_gain_freq, EP19)
@@ -1181,10 +1177,10 @@ if compute_kappac or compute_fcc or compute_fs or compute_srcq:
 			EP9 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP9_real"][0], A_epics_dict["EP9_imag"][0])
 			S = calibration_parts.compute_S(pipeline, EP6, pcal_at_opt_gain_freq, derr_at_opt_gain_freq, EP7, ktst_at_opt_gain_freq, EP8, kpu_at_opt_gain_freq, EP9)
 
-	elif factors_from_filters_file:
-		if compute_kappapum or compute_kappauim:
+	else:
+		if not compute_kappapu:
 			kpum_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, kpum, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / pum_act_line_freq)
-			kuim_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, kuim, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / (uim_act_line_freq if use_uim_line else darm_ctrl_line_freq))
+			kuim_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, kuim, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / uim_act_line_freq)
 			S = calibration_parts.compute_S_from_filters_file_split_act(pipeline, EP6_real, EP6_imag, pcal_at_opt_gain_freq, derr_at_opt_gain_freq, EP7_real, EP7_imag, ktst_at_opt_gain_freq, EP8_real, EP8_imag, kpum_at_opt_gain_freq, EP18_real, EP18_imag, kuim_at_opt_gain_freq, EP19_real, EP19_imag)
 		else:
 			kpu_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, kpu, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / darm_ctrl_line_freq)
@@ -1206,11 +1202,15 @@ if compute_kappac or compute_fcc or compute_fs or compute_srcq:
 		smooth_kc_nogate = pipeparts.mkgeneric(pipeline, kc, "lal_smoothkappas", default_kappa_re = expected_kappac, array_size = median_smoothing_samples, avg_array_size = factors_average_samples, default_to_median = tdcf_default_to_median, filter_latency = filter_latency_factor)
 
 		if use_coherence:
-			# Gate kappa_c with the coherence of all four of the calibration lines
-			kc_gated = calibration_parts.mkgate(pipeline, kc, pcaly_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			kc_gated = calibration_parts.mkgate(pipeline, kc_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			kc_gated = calibration_parts.mkgate(pipeline, kc_gated, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			kc_gated = calibration_parts.mkgate(pipeline, kc_gated, sus_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+			# Gate kappa_c with the coherence of all of the calibration lines used to compute it
+			kc_gated = calibration_parts.mkgate(pipeline, kc, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kcgate1')
+			kc_gated = calibration_parts.mkgate(pipeline, kc_gated, pcaly_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kcgate2')
+			if compute_kappapu:
+				kc_gated = calibration_parts.mkgate(pipeline, kc_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kcgate3')
+			else:
+				kc_gated = calibration_parts.mkgate(pipeline, kc_gated, sus_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kcgate4')
+				kc_gated = calibration_parts.mkgate(pipeline, kc_gated, sus_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kcgate5')
+				kc_gated = calibration_parts.mkgate(pipeline, kc_gated, sus_line3_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'kcgate6')
 
 			# Smooth kappa_c
 			smooth_kc = calibration_parts.smooth_kappas(pipeline, kc_gated, expected_kappac, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
@@ -1230,10 +1230,14 @@ if compute_kappac or compute_fcc or compute_fs or compute_srcq:
 
 		if use_coherence:
 			# Gate f_cc with all four of the calibration lines
-			fcc_gated = calibration_parts.mkgate(pipeline, fcc, pcaly_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, sus_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+			fcc_gated = calibration_parts.mkgate(pipeline, fcc, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'fccgate1')
+			fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, pcaly_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'fccgate2')
+			if compute_kappapu:
+				fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'fccgate3')
+			else:
+				fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, sus_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'fccgate4')
+				fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, sus_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'fccgate5')
+				fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, sus_line3_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True, name = 'fccgate6')
 
 			# Smooth f_cc
 			smooth_fcc = calibration_parts.smooth_kappas(pipeline, fcc_gated, fcc_default, median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
@@ -1277,9 +1281,9 @@ if compute_fs or compute_srcq:
 		EP11 = calibration_parts.merge_into_complex(pipeline, C_epics_dict["EP11_real"][0], C_epics_dict["EP11_imag"][0])
 		EP12 = calibration_parts.merge_into_complex(pipeline, D_epics_dict["EP12_real"][0], D_epics_dict["EP12_imag"][0])
 		EP13 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP13_real"][0], A_epics_dict["EP13_imag"][0])
-		if compute_kappapum or compute_kappauim:
+		if not compute_kappapu:
 			kpum_at_src_freq = pipeparts.mkgeneric(pipeline, kpum, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / pum_act_line_freq)
-			kuim_at_src_freq = pipeparts.mkgeneric(pipeline, kuim, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / (uim_act_line_freq if use_uim_line else darm_ctrl_line_freq))
+			kuim_at_src_freq = pipeparts.mkgeneric(pipeline, kuim, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / uim_act_line_freq)
 			EP20 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP20_real"][0], A_epics_dict["EP20_imag"][0])
 			EP21 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP21_real"][0], A_epics_dict["EP21_imag"][0])
 			Xi = calibration_parts.compute_Xi_split_act(pipeline, pcal_at_src_freq, derr_at_src_freq, src_pcal_line_freq, EP11, EP12, EP13, EP20, EP21, ktst_at_src_freq, kpum_at_src_freq, kuim_at_src_freq, kc, fcc)
@@ -1288,9 +1292,9 @@ if compute_fs or compute_srcq:
 			EP14 = calibration_parts.merge_into_complex(pipeline, A_epics_dict["EP14_real"][0], A_epics_dict["EP14_imag"][0])
 			Xi = calibration_parts.compute_Xi(pipeline, pcal_at_src_freq, derr_at_src_freq, src_pcal_line_freq, EP11, EP12, EP13, EP14, ktst_at_src_freq, kpu_at_src_freq, kc, fcc)
 	else:
-		if compute_kappapum or compute_kappauim:
+		if not compute_kappapu:
 			kpum_at_src_freq = pipeparts.mkgeneric(pipeline, kpum, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / pum_act_line_freq)
-			kuim_at_src_freq = pipeparts.mkgeneric(pipeline, kuim, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / (uim_act_line_freq if use_uim_line else darm_ctrl_line_freq))
+			kuim_at_src_freq = pipeparts.mkgeneric(pipeline, kuim, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / uim_act_line_freq)
 			Xi = calibration_parts.compute_Xi_from_filters_file_split_act(pipeline, pcal_at_src_freq, derr_at_src_freq, src_pcal_line_freq, EP11_real, EP11_imag, EP12_real, EP12_imag, EP13_real, EP13_imag, EP20_real, EP20_imag, EP21_real, EP21_imag, ktst_at_src_freq, kpum_at_src_freq, kuim_at_src_freq, kc, fcc)
 		else:
 			kpu_at_src_freq = pipeparts.mkgeneric(pipeline, kpu, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / darm_ctrl_line_freq)
@@ -1301,10 +1305,15 @@ if compute_fs or compute_srcq:
 
 	if use_coherence:
 		# Gate Xi with all coherences. We apply the gating and smoothing here since Q depends on the inverse of Im(Xi), which fluctuates about zero.
-		Xi_gated = calibration_parts.mkgate(pipeline, Xi, pcaly_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-		Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+		Xi_gated = calibration_parts.mkgate(pipeline, Xi, pcaly_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
 		Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, pcaly_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-		Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, sus_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+		Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, pcaly_line4_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+		Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, sus_line3_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+		if compute_kappapu:
+			Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, darm_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+		else:
+			Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, sus_line1_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
+			Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, sus_line2_coh, coherence_unc_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
 
 		smooth_Xi = calibration_parts.smooth_complex_kappas(pipeline, Xi_gated, float(numpy.real(expected_Xi)), float(numpy.imag(expected_Xi)), median_smoothing_samples, factors_average_samples, tdcf_default_to_median, filter_latency_factor)
 
@@ -1902,30 +1911,56 @@ if compute_calib_statevector:
 	#
 	if use_coherence:
 		coherence_ok_list = []
+		if compute_kappatst or compute_kappapum or compute_kappauim or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
+			# PCALY_LINE1 is used for all time-dependence calculations
+			pcaly_line1_coh_ok = pipeparts.mkbitvectorgen(pipeline, pcaly_line1_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,19), invert_control = True)
+			pcaly_line1_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line1_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
+			pcaly_line1_coh_ok = pipeparts.mkgeneric(pipeline, pcaly_line1_coh_ok, "lal_logicalundersample", required_on = pow(2,19), status_out = pow(2,19))
+			pcaly_line1_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line1_coh_ok, calibstate_caps)
+			coherence_ok_list.append(pcaly_line1_coh_ok)
+		if compute_kappatst or compute_kappapu or compute_kappac or compute_fcc or compute_fs or compute_srcq:
+			# SUS_LINE3 is used to compute kappa_TST and everything that is computed from it
+			sus_line3_coh_ok = pipeparts.mkbitvectorgen(pipeline, sus_line3_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,16), invert_control = True)		    
+			sus_line3_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_line3_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr) 
+			sus_line3_coh_ok = pipeparts.mkgeneric(pipeline, sus_line3_coh_ok, "lal_logicalundersample", required_on = pow(2,16), status_out = pow(2,16))
+			sus_line3_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_line3_coh_ok, calibstate_caps)
+			coherence_ok_list.append(sus_line3_coh_ok)
+		if compute_kappapum or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+			# SUS_LINE2 is used to compute kappa_PUM and everything that is computed from it
+			sus_line2_coh_ok = pipeparts.mkbitvectorgen(pipeline, sus_line2_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,17), invert_control = True)
+			sus_line2_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_line2_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
+			sus_line2_coh_ok = pipeparts.mkgeneric(pipeline, sus_line2_coh_ok, "lal_logicalundersample", required_on = pow(2,17), status_out = pow(2,17))
+			sus_line2_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_line2_coh_ok, calibstate_caps)
+			coherence_ok_list.append(sus_line2_coh_ok)
+		if compute_kappauim or (not compute_kappapu and (compute_kappac or compute_fcc or compute_fs or compute_srcq)):
+			# SUS_LINE1 is used to compute kappa_UIM and everything that is computed from it
+			sus_line1_coh_ok = pipeparts.mkbitvectorgen(pipeline, sus_line1_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,18), invert_control = True)
+			sus_line1_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_line1_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
+			sus_line1_coh_ok = pipeparts.mkgeneric(pipeline, sus_line1_coh_ok, "lal_logicalundersample", required_on = pow(2,18), status_out = pow(2,18))
+			sus_line1_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_line1_coh_ok, calibstate_caps)
+			coherence_ok_list.append(sus_line1_coh_ok)
+		if compute_kappapu:
+			# The DARM line is used only for kappa_PU
+			darm_coh_ok = pipeparts.mkbitvectorgen(pipeline, darm_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,18), invert_control = True)
+			darm_coh_ok = pipeparts.mkcapsfilter(pipeline, darm_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
+			darm_coh_ok = pipeparts.mkgeneric(pipeline, darm_coh_ok, "lal_logicalundersample", required_on = pow(2,18), status_out = pow(2,18))
+			darm_coh_ok = pipeparts.mkcapsfilter(pipeline, darm_coh_ok, calibstate_caps)
+			coherence_ok_list.append(darm_coh_ok)
 		if compute_kappac or compute_fcc or compute_srcq or compute_fs:
 			# PCALY_LINE2 is only used for \kappa_c, f_cc, f_s, and Q
-			pcaly_line2_coh_ok = pipeparts.mkbitvectorgen(pipeline, pcaly_line2_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,19), invert_control = True)
+			pcaly_line2_coh_ok = pipeparts.mkbitvectorgen(pipeline, pcaly_line2_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,20), invert_control = True)
 			pcaly_line2_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line2_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
-			pcaly_line2_coh_ok = pipeparts.mkgeneric(pipeline, pcaly_line2_coh_ok, "lal_logicalundersample", required_on = pow(2,19), status_out = pow(2,19))
+			pcaly_line2_coh_ok = pipeparts.mkgeneric(pipeline, pcaly_line2_coh_ok, "lal_logicalundersample", required_on = pow(2,20), status_out = pow(2,20))
 			pcaly_line2_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line2_coh_ok, calibstate_caps)
 			coherence_ok_list.append(pcaly_line2_coh_ok)
-		if compute_kappatst or compute_kappapu or compute_kappac or compute_fcc or compute_srcq or compute_fs:
-			# The coherences of these lines are all used to gate all the time dependence calculations
-			pcaly_line1_coh_ok = pipeparts.mkbitvectorgen(pipeline, pcaly_line1_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,18), invert_control = True)
-			pcaly_line1_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line1_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
-			pcaly_line1_coh_ok = pipeparts.mkgeneric(pipeline, pcaly_line1_coh_ok, "lal_logicalundersample", required_on = pow(2,18), status_out = pow(2,18))
-			pcaly_line1_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line1_coh_ok, calibstate_caps)
+		if compute_fs or compute_srcq:
+			# PCALY_LINE4 is used to compute f_s and Q
+			pcaly_line4_coh_ok = pipeparts.mkbitvectorgen(pipeline, pcaly_line4_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,21), invert_control = True)
+			pcaly_line4_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line4_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
+			pcaly_line4_coh_ok = pipeparts.mkgeneric(pipeline, pcaly_line4_coh_ok, "lal_logicalundersample", required_on = pow(2,21), status_out = pow(2,21))
+			pcaly_line4_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line4_coh_ok, calibstate_caps)
+			coherence_ok_list.append(pcaly_line4_coh_ok)
 
-			sus_coh_ok = pipeparts.mkbitvectorgen(pipeline, sus_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,16), invert_control = True)
-			sus_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
-			sus_coh_ok = pipeparts.mkgeneric(pipeline, sus_coh_ok, "lal_logicalundersample", required_on = pow(2,16), status_out = pow(2,16))
-			sus_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_coh_ok, calibstate_caps)
-
-			darm_coh_ok = pipeparts.mkbitvectorgen(pipeline, darm_coh, threshold = coherence_unc_threshold, bit_vector = pow(2,17), invert_control = True)
-			darm_coh_ok = pipeparts.mkcapsfilter(pipeline, darm_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % coh_sr)
-			darm_coh_ok = pipeparts.mkgeneric(pipeline, darm_coh_ok, "lal_logicalundersample", required_on = pow(2,17), status_out = pow(2,17))
-			darm_coh_ok = pipeparts.mkcapsfilter(pipeline, darm_coh_ok, calibstate_caps)
-			coherence_ok_list.extend((pcaly_line1_coh_ok, sus_coh_ok, darm_coh_ok))
 			coherence_bits = calibration_parts.mkadder(pipeline, tuple(coherence_ok_list))
 
 	#
@@ -1998,8 +2033,8 @@ if compute_calib_statevector:
 			D_epics_check = pipeparts.mkgeneric(pipeline, D_epics_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
 			D_epics_check_list.append(D_epics_check)
 		D_epics_check = calibration_parts.mkadder(pipeline, tuple(D_epics_check_list))
-		D_epics_bit = pipeparts.mkbitvectorgen(pipeline, D_epics_check, bit_vector = pow(2,21), threshold = D_epics_threshold)
-		D_epics_bit = pipeparts.mkgeneric(pipeline, D_epics_bit, "lal_logicalundersample", required_on = pow(2,21), status_out = pow(2,21))
+		D_epics_bit = pipeparts.mkbitvectorgen(pipeline, D_epics_check, bit_vector = pow(2,22), threshold = D_epics_threshold)
+		D_epics_bit = pipeparts.mkgeneric(pipeline, D_epics_bit, "lal_logicalundersample", required_on = pow(2,22), status_out = pow(2,22))
 		D_epics_bit = pipeparts.mkcapsfilter(pipeline, D_epics_bit, calibstate_caps)
 		epics_bits_list.append(D_epics_bit)
 
@@ -2012,8 +2047,8 @@ if compute_calib_statevector:
 			A_epics_check = pipeparts.mkgeneric(pipeline, A_epics_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
 			A_epics_check_list.append(A_epics_check)
 		A_epics_check = calibration_parts.mkadder(pipeline, tuple(A_epics_check_list))
-		A_epics_bit = pipeparts.mkbitvectorgen(pipeline, A_epics_check, bit_vector = pow(2,22), threshold = A_epics_threshold)
-		A_epics_bit = pipeparts.mkgeneric(pipeline, A_epics_bit, "lal_logicalundersample", required_on = pow(2,22), status_out = pow(2,22))
+		A_epics_bit = pipeparts.mkbitvectorgen(pipeline, A_epics_check, bit_vector = pow(2,23), threshold = A_epics_threshold)
+		A_epics_bit = pipeparts.mkgeneric(pipeline, A_epics_bit, "lal_logicalundersample", required_on = pow(2,23), status_out = pow(2,23))
 		A_epics_bit = pipeparts.mkcapsfilter(pipeline, A_epics_bit, calibstate_caps)
 		epics_bits_list.append(A_epics_bit)
 
@@ -2026,8 +2061,8 @@ if compute_calib_statevector:
 			C_epics_check = pipeparts.mkgeneric(pipeline, C_epics_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
 			C_epics_check_list.append(C_epics_check)
 		C_epics_check = calibration_parts.mkadder(pipeline, tuple(C_epics_check_list))
-		C_epics_bit = pipeparts.mkbitvectorgen(pipeline, C_epics_check, bit_vector = pow(2,23), threshold = C_epics_threshold)
-		C_epics_bit = pipeparts.mkgeneric(pipeline, C_epics_bit, "lal_logicalundersample", required_on = pow(2,23), status_out = pow(2,23))
+		C_epics_bit = pipeparts.mkbitvectorgen(pipeline, C_epics_check, bit_vector = pow(2,24), threshold = C_epics_threshold)
+		C_epics_bit = pipeparts.mkgeneric(pipeline, C_epics_bit, "lal_logicalundersample", required_on = pow(2,24), status_out = pow(2,24))
 		C_epics_bit = pipeparts.mkcapsfilter(pipeline, C_epics_bit, calibstate_caps)
 		epics_bits_list.append(C_epics_bit)
 
@@ -2040,8 +2075,8 @@ if compute_calib_statevector:
 			misc_epics_check = pipeparts.mkgeneric(pipeline, misc_epics_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
 			misc_epics_check_list.append(misc_epics_check)
 		misc_epics_check = calibration_parts.mkadder(pipeline, tuple(misc_epics_check_list))
-		misc_epics_bit = pipeparts.mkbitvectorgen(pipeline, misc_epics_check, bit_vector = pow(2,24), threshold = misc_epics_threshold)
-		misc_epics_bit = pipeparts.mkgeneric(pipeline, misc_epics_bit, "lal_logicalundersample", required_on = pow(2,24), status_out = pow(2,24))
+		misc_epics_bit = pipeparts.mkbitvectorgen(pipeline, misc_epics_check, bit_vector = pow(2,25), threshold = misc_epics_threshold)
+		misc_epics_bit = pipeparts.mkgeneric(pipeline, misc_epics_bit, "lal_logicalundersample", required_on = pow(2,25), status_out = pow(2,25))
 		misc_epics_bit = pipeparts.mkcapsfilter(pipeline, misc_epics_bit, calibstate_caps)
 		epics_bits_list.append(misc_epics_bit)
 
@@ -2204,7 +2239,7 @@ if compute_calib_statevector and (remove_cal_lines or remove_power_lines or witn
 	clean_strain_rms_lowfreq = calibration_parts.compute_rms(pipeline, clean_straintee, low_rms_rate, cleaning_check_rms_time, f_min = cleaning_check_range_low_min, f_max = cleaning_check_range_low_max, filter_latency = filter_latency_factor, rate_out = calibstate_sr, td = td)
 	# Require that ratio RMS(strain) / RMS(clean_strain) > 1.0
 	clean_hoft_ok_lowfreq = calibration_parts.complex_division(pipeline, strain_rms_lowfreq, clean_strain_rms_lowfreq)
-	clean_hoft_ok_lowfreq = pipeparts.mkbitvectorgen(pipeline, clean_hoft_ok_lowfreq, bit_vector=pow(2,25), threshold=1.0)
+	clean_hoft_ok_lowfreq = pipeparts.mkbitvectorgen(pipeline, clean_hoft_ok_lowfreq, bit_vector=pow(2,26), threshold=1.0)
 	clean_hoft_ok_lowfreq = pipeparts.mkcapsfilter(pipeline, clean_hoft_ok_lowfreq, calibstate_caps)
 
 	# Compute the RMS of the uncleaned strain in a mid-frequency range to test subtraction of noise and/or the ~300 Hz pcal line
@@ -2213,7 +2248,7 @@ if compute_calib_statevector and (remove_cal_lines or remove_power_lines or witn
 	clean_strain_rms_midfreq = calibration_parts.compute_rms(pipeline, clean_straintee, mid_rms_rate, cleaning_check_rms_time, f_min = cleaning_check_range_mid_min, f_max = cleaning_check_range_mid_max, filter_latency = filter_latency_factor, rate_out = calibstate_sr, td = td)
 	# Require that ratio RMS(strain) / RMS(clean_strain) > 1.0
 	clean_hoft_ok_midfreq = calibration_parts.complex_division(pipeline, strain_rms_midfreq, clean_strain_rms_midfreq)
-	clean_hoft_ok_midfreq = pipeparts.mkbitvectorgen(pipeline, clean_hoft_ok_midfreq, bit_vector=pow(2,26), threshold=1.0)
+	clean_hoft_ok_midfreq = pipeparts.mkbitvectorgen(pipeline, clean_hoft_ok_midfreq, bit_vector=pow(2,27), threshold=1.0)
 	clean_hoft_ok_midfreq = pipeparts.mkcapsfilter(pipeline, clean_hoft_ok_midfreq, calibstate_caps)
 
 	# Add these into the CALIB_STATE_VECTOR
diff --git a/gstlal-calibration/config_files/O2/H1/tests/H1DCS_AllCorrections_Cleaning.ini b/gstlal-calibration/config_files/O2/H1/tests/H1DCS_AllCorrections_Cleaning.ini
index 4621a710a4..813b071ce3 100644
--- a/gstlal-calibration/config_files/O2/H1/tests/H1DCS_AllCorrections_Cleaning.ini
+++ b/gstlal-calibration/config_files/O2/H1/tests/H1DCS_AllCorrections_Cleaning.ini
@@ -199,6 +199,8 @@ PCALChannel: CAL-PCALY_TX_PD_OUT_DQ
 # Coherence Uncertainty Channel Names #
 #######################################
 CohUncSusLine1Channel: CAL-CS_TDEP_SUS_LINE1_UNCERTAINTY
+CohUncSusLine2Channel: CAL-CS_TDEP_SUS_LINE2_UNCERTAINTY
+CohUncSusLine3Channel: CAL-CS_TDEP_SUS_LINE1_UNCERTAINTY
 CohUncPcalyLine1Channel: CAL-CS_TDEP_PCALY_LINE1_UNCERTAINTY
 CohUncPcalyLine2Channel: CAL-CS_TDEP_PCALY_LINE2_UNCERTAINTY
 CohUncDARMLine1Channel: CAL-CS_TDEP_DARM_LINE1_UNCERTAINTY
diff --git a/gstlal-calibration/config_files/O2/H1/tests/H1DCS_FreqIndepCorrections_Cleaning.ini b/gstlal-calibration/config_files/O2/H1/tests/H1DCS_FreqIndepCorrections_Cleaning.ini
index 12b9b228ab..9568341f79 100644
--- a/gstlal-calibration/config_files/O2/H1/tests/H1DCS_FreqIndepCorrections_Cleaning.ini
+++ b/gstlal-calibration/config_files/O2/H1/tests/H1DCS_FreqIndepCorrections_Cleaning.ini
@@ -199,6 +199,8 @@ PCALChannel: CAL-PCALY_TX_PD_OUT_DQ
 # Coherence Uncertainty Channel Names #
 #######################################
 CohUncSusLine1Channel: CAL-CS_TDEP_SUS_LINE1_UNCERTAINTY
+CohUncSusLine2Channel: CAL-CS_TDEP_SUS_LINE2_UNCERTAINTY
+CohUncSusLine3Channel: CAL-CS_TDEP_SUS_LINE1_UNCERTAINTY
 CohUncPcalyLine1Channel: CAL-CS_TDEP_PCALY_LINE1_UNCERTAINTY
 CohUncPcalyLine2Channel: CAL-CS_TDEP_PCALY_LINE2_UNCERTAINTY
 CohUncDARMLine1Channel: CAL-CS_TDEP_DARM_LINE1_UNCERTAINTY
-- 
GitLab