From 17b7906d36302070fa12afb74f8f8baba22d4131 Mon Sep 17 00:00:00 2001 From: Aaron Viets <aaron.viets@ligo.org> Date: Wed, 20 Mar 2019 11:43:05 -0700 Subject: [PATCH] lal_dqtukey: added option to use Planck-taper window instead of half-Hann window. --- gstlal-calibration/gst/lal/gstlal_dqtukey.c | 50 ++++++++++++++++++-- gstlal-calibration/gst/lal/gstlal_dqtukey.h | 1 + gstlal-calibration/tests/lal_dqtukey_test.py | 4 +- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/gstlal-calibration/gst/lal/gstlal_dqtukey.c b/gstlal-calibration/gst/lal/gstlal_dqtukey.c index f35f5557a6..d6a148074c 100644 --- a/gstlal-calibration/gst/lal/gstlal_dqtukey.c +++ b/gstlal-calibration/gst/lal/gstlal_dqtukey.c @@ -735,8 +735,32 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf element->remainder = 0; element->num_since_bad = 0; - /* If we haven't made a half-Hann window for transitions between zeros and ones yet, do it now */ - if(!element->ramp) { + /* If we haven't made a window for transitions between zeros and ones yet, do it now */ + if(!element->ramp && element->planck_taper) { + /* Make a Planck-taper window */ + if(element->unit_size_out == 4) { + element->ramp = g_malloc(element->transition_samples * sizeof(float)); + float *ramp = (float *) element->ramp; + gint64 i; + float i_frac, Z; + for(i = 0; i < element->transition_samples; i++) { + i_frac = (i + 1.0) / (element->transition_samples + 1.0); + Z = 1.0 / i_frac + 1.0 / (i_frac - 1); + ramp[i] = (float) (1.0 / (1.0 + expf(Z))); + } + } else { + element->ramp = g_malloc(element->transition_samples * sizeof(double)); + double *ramp = (double *) element->ramp; + gint64 i; + double i_frac, Z; + for(i = 0; i < element->transition_samples; i++) { + i_frac = (i + 1.0) / (element->transition_samples + 1.0); + Z = 1.0 / i_frac + 1.0 / (i_frac - 1); + ramp[i] = 1.0 / (1.0 + exp(Z)); + } + } + } else if(!element->ramp) { + /* Make a half-Hann window */ if(element->unit_size_out == 4) { element->ramp = g_malloc(element->transition_samples * sizeof(float)); float *ramp = (float *) element->ramp; @@ -842,7 +866,8 @@ enum property { ARG_REQUIRED_OFF, ARG_TRANSITION_SAMPLES, ARG_INVERT_WINDOW, - ARG_INVERT_CONTROL + ARG_INVERT_CONTROL, + ARG_PLANCK_TAPER }; @@ -873,6 +898,10 @@ static void set_property(GObject *object, enum property prop_id, const GValue *v element->invert_control = g_value_get_boolean(value); break; + case ARG_PLANCK_TAPER: + element->planck_taper = g_value_get_boolean(value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -909,6 +938,10 @@ static void get_property(GObject *object, enum property prop_id, GValue *value, g_value_set_boolean(value, element->invert_control); break; + case ARG_PLANCK_TAPER: + g_value_set_boolean(value, element->planck_taper); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1013,6 +1046,17 @@ static void gstlal_dqtukey_class_init(GSTLALDQTukeyClass *klass) { G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT ) ); + g_object_class_install_property( + gobject_class, + ARG_PLANCK_TAPER, + g_param_spec_boolean( + "planck-taper", + "Planck Taper", + "Set to True to use a Planck-taper window instead of a half-Hann window.", + FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT + ) + ); } diff --git a/gstlal-calibration/gst/lal/gstlal_dqtukey.h b/gstlal-calibration/gst/lal/gstlal_dqtukey.h index a20aec28f9..515749f0d5 100644 --- a/gstlal-calibration/gst/lal/gstlal_dqtukey.h +++ b/gstlal-calibration/gst/lal/gstlal_dqtukey.h @@ -103,6 +103,7 @@ struct _GSTLALDQTukey { gint64 transition_samples; gboolean invert_window; gboolean invert_control; + gboolean planck_taper; }; diff --git a/gstlal-calibration/tests/lal_dqtukey_test.py b/gstlal-calibration/tests/lal_dqtukey_test.py index e45093d3ea..9fa3e0d3f9 100755 --- a/gstlal-calibration/tests/lal_dqtukey_test.py +++ b/gstlal-calibration/tests/lal_dqtukey_test.py @@ -46,10 +46,10 @@ def lal_dqtukey_01(pipeline, name): # This test passes a random series of integers through lal_dqtukey # - rate_in = 16 # Hz + rate_in = 4 # Hz rate_out = 16384 # Hz buffer_length = 1.0 # seconds - test_duration = 300.0 # seconds + test_duration = 2.0 # seconds transition_samples = 997 # -- GitLab