From 2bbab4e2bf6bee3866af4a1e950c6fb03c129300 Mon Sep 17 00:00:00 2001
From: Aaron Viets <aaron.viets@ligo.org>
Date: Thu, 23 Aug 2018 14:12:38 -0700
Subject: [PATCH] lal_dqtukey:  fixed bug for invert_window option.

---
 gstlal-calibration/gst/lal/gstlal_dqtukey.c  |  2 +-
 gstlal-calibration/tests/lal_dqtukey_test.py | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/gstlal-calibration/gst/lal/gstlal_dqtukey.c b/gstlal-calibration/gst/lal/gstlal_dqtukey.c
index 5b2ea5a2b1..17b0e5f276 100644
--- a/gstlal-calibration/gst/lal/gstlal_dqtukey.c
+++ b/gstlal-calibration/gst/lal/gstlal_dqtukey.c
@@ -332,7 +332,7 @@ double_ramp: \
 		if(!(i % num_cycle_in)) { \
 			for(j = 0; j < num_cycle_out; j++, dst++, (*ramp_down_index)++, (*ramp_up_index)++) { \
 				if(invert_window) \
-					*dst = ramp[*ramp_down_index] * (1.0 - (*ramp_up_index < transition_samples ? ramp[*ramp_up_index] : 1.0)); \
+					*dst = 1.0 - (1.0 - ramp[*ramp_down_index]) * (*ramp_up_index < transition_samples ? ramp[*ramp_up_index] : 1.0); \
 				else \
 					*dst = (1.0 - ramp[*ramp_down_index]) * (*ramp_up_index < transition_samples ? ramp[*ramp_up_index] : 1.0); \
  \
diff --git a/gstlal-calibration/tests/lal_dqtukey_test.py b/gstlal-calibration/tests/lal_dqtukey_test.py
index c5a2f88472..e45093d3ea 100755
--- a/gstlal-calibration/tests/lal_dqtukey_test.py
+++ b/gstlal-calibration/tests/lal_dqtukey_test.py
@@ -49,7 +49,8 @@ def lal_dqtukey_01(pipeline, name):
 	rate_in = 16		# Hz
 	rate_out = 16384	# Hz
 	buffer_length = 1.0	# seconds
-	test_duration = 30.0	# seconds
+	test_duration = 300.0	# seconds
+	transition_samples = 997
 
 	#
 	# build pipeline
@@ -58,10 +59,10 @@ def lal_dqtukey_01(pipeline, name):
 	head = test_common.int_test_src(pipeline, buffer_length = buffer_length, rate = rate_in, width = 32, test_duration = test_duration, wave = 5, freq = 0)
 	head = pipeparts.mktee(pipeline, head)
 	pipeparts.mknxydumpsink(pipeline, head, "%s_in.txt" % name)
-	normal = pipeparts.mkgeneric(pipeline, head, "lal_dqtukey", transition_samples = 1024, required_on = 2, required_off = 1, invert_control = False)
-	invert = pipeparts.mkgeneric(pipeline, head, "lal_dqtukey", transition_samples = 1024, required_on = 2, required_off = 1, invert_control = True)
-	invwin = pipeparts.mkgeneric(pipeline, head, "lal_dqtukey", transition_samples = 1024, required_on = 2, required_off = 1, invert_control = False, invert_window = True)
-	invboth = pipeparts.mkgeneric(pipeline, head, "lal_dqtukey", transition_samples = 1024, required_on = 2, required_off = 1, invert_control = True, invert_window = True)
+	normal = pipeparts.mkgeneric(pipeline, head, "lal_dqtukey", transition_samples = transition_samples, required_on = 2, required_off = 1, invert_control = False)
+	invert = pipeparts.mkgeneric(pipeline, head, "lal_dqtukey", transition_samples = transition_samples, required_on = 2, required_off = 1, invert_control = True)
+	invwin = pipeparts.mkgeneric(pipeline, head, "lal_dqtukey", transition_samples = transition_samples, required_on = 2, required_off = 1, invert_control = False, invert_window = True)
+	invboth = pipeparts.mkgeneric(pipeline, head, "lal_dqtukey", transition_samples = transition_samples, required_on = 2, required_off = 1, invert_control = True, invert_window = True)
 	normal = pipeparts.mkcapsfilter(pipeline, normal, "audio/x-raw,rate=%s,format=F64LE" % rate_out)
 	invert = pipeparts.mkcapsfilter(pipeline, invert, "audio/x-raw,rate=%s,format=F64LE" % rate_out)
 	invwin = pipeparts.mkcapsfilter(pipeline, invwin, "audio/x-raw,rate=%s,format=F64LE" % rate_out)
-- 
GitLab