From b9a62f384f1c7a46b14ac080ab181f87521f5b7d Mon Sep 17 00:00:00 2001
From: Aaron Viets <aaron.viets@ligo.org>
Date: Mon, 10 Feb 2025 15:19:02 -0600
Subject: [PATCH 1/2] calibration_parts.py:  Remove signal exists gate from
 line subtraction when filter latency is not zero

---
 gnuscripts/depcomp          | 15 +++++++--------
 python/calibration_parts.py | 15 ++++++++++-----
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/gnuscripts/depcomp b/gnuscripts/depcomp
index 1f0aa972c..65cbf7093 100755
--- a/gnuscripts/depcomp
+++ b/gnuscripts/depcomp
@@ -1,9 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2024-06-19.01; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2024 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -47,13 +47,11 @@ Environment variables:
   libtool     Whether libtool is used (yes/no).
 
 Report bugs to <bug-automake@gnu.org>.
-GNU Automake home page: <https://www.gnu.org/software/automake/>.
-General help using GNU software: <https://www.gnu.org/gethelp/>.
 EOF
     exit $?
     ;;
   -v | --v*)
-    echo "depcomp (GNU Automake) $scriptversion"
+    echo "depcomp $scriptversion"
     exit $?
     ;;
 esac
@@ -115,6 +113,7 @@ nl='
 # These definitions help.
 upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
 lower=abcdefghijklmnopqrstuvwxyz
+digits=0123456789
 alpha=${upper}${lower}
 
 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
@@ -129,7 +128,7 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
 
 rm -f "$tmpdepfile"
 
-# Avoid interference from the environment.
+# Avoid interferences from the environment.
 gccflag= dashmflag=
 
 # Some modes work just like other modes, but use different flags.  We
@@ -199,8 +198,8 @@ gcc3)
   ;;
 
 gcc)
-## Note that this doesn't just cater to obsolete pre-3.x GCC compilers.
-## but also to in-use compilers like IBM xlc/xlC and the HP C compiler.
+## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
+## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
 ## (see the conditional assignment to $gccflag above).
 ## There are various ways to get dependency output from gcc.  Here's
 ## why we pick this rather obscure method:
diff --git a/python/calibration_parts.py b/python/calibration_parts.py
index c635c29d1..a237d7f38 100644
--- a/python/calibration_parts.py
+++ b/python/calibration_parts.py
@@ -521,10 +521,11 @@ def remove_lines_with_witnesses(pipeline, signal, witnesses, freqs, freq_vars, f
 	signal = pipeparts.mktee(pipeline, signal)
 	function_inst_num = int(signal.name[3:])
 	# Check whether the signal exists, and use this to gate the TF
-	signal_exists = pipeparts.mkbitvectorgen(pipeline, signal, threshold = 1e-50, bit_vector = 1)
-	signal_exists = pipeparts.mkcapsfilter(pipeline, signal_exists, "audio/x-raw, format=U32LE, rate=%d, channel-mask=(bitmask)0x0" % rate_out)
-	signal_exists = pipeparts.mkgeneric(pipeline, signal_exists, "lal_logicalundersample", required_on = 1, status_out = 1)
-	signal_exists = pipeparts.mktee(pipeline, pipeparts.mkcapsfilter(pipeline, signal_exists, "audio/x-raw, format=U32LE, rate=%d, channel-mask=(bitmask)0x0" % compute_rate))
+	if filter_latency == 0:
+		signal_exists = pipeparts.mkbitvectorgen(pipeline, signal, threshold = 1e-50, bit_vector = 1)
+		signal_exists = pipeparts.mkcapsfilter(pipeline, signal_exists, "audio/x-raw, format=U32LE, rate=%d, channel-mask=(bitmask)0x0" % rate_out)
+		signal_exists = pipeparts.mkgeneric(pipeline, signal_exists, "lal_logicalundersample", required_on = 1, status_out = 1)
+		signal_exists = pipeparts.mktee(pipeline, pipeparts.mkcapsfilter(pipeline, signal_exists, "audio/x-raw, format=U32LE, rate=%d, channel-mask=(bitmask)0x0" % compute_rate))
 
 	signal_minus_lines = [signal]
 
@@ -620,7 +621,11 @@ def remove_lines_with_witnesses(pipeline, signal, witnesses, freqs, freq_vars, f
 				tf_at_f = mkinsertgap(pipeline, tf_at_f, replace_value = 0)
 				# Remove worthless data from computation of transfer function if we can
 				tf_at_f = mkgate(pipeline, tf_at_f, witness_downsampled[i], 1.0001 * witness_absent_value, attack_length = -((1.0 - filter_latency) * (filter_samples + resample_shift)), name = "linesub_witness_downsampled_gate_%d_%d_%d_%d" % (m, n, i, function_inst_num), queue_length = queue_length)
-				tf_at_f = mkgate(pipeline, tf_at_f, signal_exists, 1, attack_length = -((1.0 - filter_latency) * filter_samples), name = "linesub_signal_exists_gate_%d_%d_%d_%d" % (m, n, i, function_inst_num), queue_length = queue_length)
+				if filter_latency == 0:
+					# When filter_latency is 1, the queues before the gate below sometimes
+					# store data unnecessarily, refusing to release the data at EOS. This may
+					# be due to a race condition.
+					tf_at_f = mkgate(pipeline, tf_at_f, signal_exists, 1, attack_length = -((1.0 - filter_latency) * filter_samples), name = "linesub_signal_exists_gate_%d_%d_%d_%d" % (m, n, i, function_inst_num), queue_length = queue_length)
 				if noisesub_gate_bit is not None:
 					tf_at_f = mkgate(pipeline, tf_at_f, noisesub_gate_bit, 1, attack_length = -((1.0 - filter_latency) * filter_samples), name = "linesub_gate_%d_%d_%d_%d" % (m, n, i, function_inst_num), queue_length = queue_length)
 				if any(amp_channels):
-- 
GitLab


From a622b58ad9d7cc5b923b906c3b159a93a7940359 Mon Sep 17 00:00:00 2001
From: Aaron Viets <aaron.viets@ligo.org>
Date: Wed, 12 Feb 2025 12:27:38 -0600
Subject: [PATCH 2/2] undo changes to depcomp

---
 gnuscripts/depcomp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gnuscripts/depcomp b/gnuscripts/depcomp
index 65cbf7093..1f0aa972c 100755
--- a/gnuscripts/depcomp
+++ b/gnuscripts/depcomp
@@ -1,9 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2018-03-07.03; # UTC
+scriptversion=2024-06-19.01; # UTC
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2024 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -47,11 +47,13 @@ Environment variables:
   libtool     Whether libtool is used (yes/no).
 
 Report bugs to <bug-automake@gnu.org>.
+GNU Automake home page: <https://www.gnu.org/software/automake/>.
+General help using GNU software: <https://www.gnu.org/gethelp/>.
 EOF
     exit $?
     ;;
   -v | --v*)
-    echo "depcomp $scriptversion"
+    echo "depcomp (GNU Automake) $scriptversion"
     exit $?
     ;;
 esac
@@ -113,7 +115,6 @@ nl='
 # These definitions help.
 upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
 lower=abcdefghijklmnopqrstuvwxyz
-digits=0123456789
 alpha=${upper}${lower}
 
 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
@@ -128,7 +129,7 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
 
 rm -f "$tmpdepfile"
 
-# Avoid interferences from the environment.
+# Avoid interference from the environment.
 gccflag= dashmflag=
 
 # Some modes work just like other modes, but use different flags.  We
@@ -198,8 +199,8 @@ gcc3)
   ;;
 
 gcc)
-## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
-## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
+## Note that this doesn't just cater to obsolete pre-3.x GCC compilers.
+## but also to in-use compilers like IBM xlc/xlC and the HP C compiler.
 ## (see the conditional assignment to $gccflag above).
 ## There are various ways to get dependency output from gcc.  Here's
 ## why we pick this rather obscure method:
-- 
GitLab