From 33e4f36a777c0ccbc0ebc14d89d53fcd88e938e0 Mon Sep 17 00:00:00 2001 From: Aaron Viets <aaron.viets@ligo.org> Date: Thu, 13 Dec 2018 07:59:56 -0800 Subject: [PATCH] lal_property: A few bug fixes to get it working right. --- gstlal-calibration/gst/lal/gstlal_property.c | 25 +++--- gstlal-calibration/tests/lal_property_test.py | 87 +++++++++++++++++++ 2 files changed, 101 insertions(+), 11 deletions(-) create mode 100755 gstlal-calibration/tests/lal_property_test.py diff --git a/gstlal-calibration/gst/lal/gstlal_property.c b/gstlal-calibration/gst/lal/gstlal_property.c index 19a64b47f1..a5225a6bef 100644 --- a/gstlal-calibration/gst/lal/gstlal_property.c +++ b/gstlal-calibration/gst/lal/gstlal_property.c @@ -223,11 +223,11 @@ static gboolean set_caps(GstBaseSink *sink, GstCaps *caps) { /* Record the data type */ if(success) { - if(!strchr(name, 'S')) + if(strchr(name, 'S')) element->data_type = GSTLAL_PROPERTY_SIGNED; - else if(!strchr(name, 'U')) + else if(strchr(name, 'U')) element->data_type = GSTLAL_PROPERTY_UNSIGNED; - else if(!strchr(name, 'F')) + else if(strchr(name, 'F')) element->data_type = GSTLAL_PROPERTY_FLOAT; else g_assert_not_reached(); @@ -270,46 +270,49 @@ static GstFlowReturn render(GstBaseSink *sink, GstBuffer *buffer) { switch(element->data_type) { case GSTLAL_PROPERTY_SIGNED: switch(element->unit_size) { - case 8: + case 1: average_input_data_gint8(element, (gint8 *) mapinfo.data, mapinfo.size / element->unit_size, GST_BUFFER_PTS(buffer)); break; - case 16: + case 2: average_input_data_gint16(element, (gint16 *) mapinfo.data, mapinfo.size / element->unit_size, GST_BUFFER_PTS(buffer)); break; - case 32: + case 4: average_input_data_gint32(element, (gint32 *) mapinfo.data, mapinfo.size / element->unit_size, GST_BUFFER_PTS(buffer)); break; default: g_assert_not_reached(); break; } + break; case GSTLAL_PROPERTY_UNSIGNED: switch(element->unit_size) { - case 8: + case 1: average_input_data_guint8(element, (guint8 *) mapinfo.data, mapinfo.size / element->unit_size, GST_BUFFER_PTS(buffer)); break; - case 16: + case 2: average_input_data_guint16(element, (guint16 *) mapinfo.data, mapinfo.size / element->unit_size, GST_BUFFER_PTS(buffer)); break; - case 32: + case 4: average_input_data_guint32(element, (guint32 *) mapinfo.data, mapinfo.size / element->unit_size, GST_BUFFER_PTS(buffer)); break; default: g_assert_not_reached(); break; } + break; case GSTLAL_PROPERTY_FLOAT: switch(element->unit_size) { - case 32: + case 4: average_input_data_float(element, (float *) mapinfo.data, mapinfo.size / element->unit_size, GST_BUFFER_PTS(buffer)); break; - case 64: + case 8: average_input_data_double(element, (double *) mapinfo.data, mapinfo.size / element->unit_size, GST_BUFFER_PTS(buffer)); break; default: g_assert_not_reached(); break; } + break; default: g_assert_not_reached(); break; diff --git a/gstlal-calibration/tests/lal_property_test.py b/gstlal-calibration/tests/lal_property_test.py new file mode 100755 index 0000000000..2a2d90e24d --- /dev/null +++ b/gstlal-calibration/tests/lal_property_test.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# Copyright (C) 2018 Aaron Viets +# +# 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 the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# +# ============================================================================= +# +# Preamble +# +# ============================================================================= +# + + +import numpy +import sys +from gstlal import pipeparts +from gstlal import calibration_parts +import test_common + + +# +# ============================================================================= +# +# Pipelines +# +# ============================================================================= +# + +def lal_property_test_01(pipeline, name): + # + # This test makes a stream changing between 2's and 8's. + # It should square the 2's and take the 8's to the 8th power. + # + + rate = 512 # Hz + width = 64 + buffer_length = 1.0 # seconds + test_duration = 100.0 # seconds + gap_frequency = 0.1 # Hz + gap_threshold = 0.0 + control_dump_filename = "control_property_test_01.dump" + bad_data_intervals2 = [0.0, 1e35] + bad_data_intervals = [-1e35, 1e-35] + + head = test_common.test_src(pipeline, buffer_length = buffer_length, rate = rate, width = width, channels = 1, test_duration = test_duration, wave = 0, freq = 0.1, volume = 1) + head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals = bad_data_intervals, insert_gap = False, fill_discont = True, replace_value = 2.0) + head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals = bad_data_intervals2, insert_gap = False, fill_discont = True, replace_value = 8.0) + head = pipeparts.mktee(pipeline, head) + pipeparts.mknxydumpsink(pipeline, head, "%s_in.dump" % name) + lal_prop_exponent = pipeparts.mkgeneric(pipeline, head, "lal_property", update_when_change = True) + head = calibration_parts.mkpow(pipeline, head, exponent = 0.0) + + lal_prop_exponent.connect("notify::current-average", calibration_parts.update_property_simple, head, "current_average", "exponent") + + pipeparts.mknxydumpsink(pipeline, head, "%s_out.dump" % name) + + # + # done + # + + return pipeline + +# +# ============================================================================= +# +# Main +# +# ============================================================================= +# + + +test_common.build_and_run(lal_property_test_01, "lal_property_test_01") + + -- GitLab