Skip to content
Snippets Groups Projects
Commit c9b29411 authored by Aaron Viets's avatar Aaron Viets
Browse files

lal_transferfunction: don't compute transfer functions until all input channels are nonzero.

parent 36afd9a1
No related branches found
No related tags found
No related merge requests found
...@@ -122,6 +122,7 @@ enum property { ...@@ -122,6 +122,7 @@ enum property {
ARG_LOW_PASS, ARG_LOW_PASS,
ARG_TRANSFER_FUNCTIONS, ARG_TRANSFER_FUNCTIONS,
ARG_FIR_FILTERS, ARG_FIR_FILTERS,
ARG_INPUT_MAY_BE_ZERO,
ARG_FAKE ARG_FAKE
}; };
...@@ -423,6 +424,10 @@ static gboolean find_transfer_functions_ ## DTYPE(GSTLALTransferFunction *elemen ...@@ -423,6 +424,10 @@ static gboolean find_transfer_functions_ ## DTYPE(GSTLALTransferFunction *elemen
stride = element->fft_length - element->fft_overlap; \ stride = element->fft_length - element->fft_overlap; \
num_tfs = element->channels - 1; \ num_tfs = element->channels - 1; \
DTYPE *real_fft = (DTYPE *) element->workspace.w ## S_OR_D ## pf.fft; \ DTYPE *real_fft = (DTYPE *) element->workspace.w ## S_OR_D ## pf.fft; \
\
/* Check a few inputs to see if we have valid data yet */ \
for(i = 0; i < 2 * element->channels; i++) \
success &= isnormal(src[i]) || (element->input_may_be_zero && src[i] == 0.0); \
\ \
/* Determine how many fft's we will calculate from combined leftover and new input data */ \ /* Determine how many fft's we will calculate from combined leftover and new input data */ \
num_ffts = minimum64((element->workspace.w ## S_OR_D ## pf.num_leftover + stride - 1) / stride, element->num_ffts - element->workspace.w ## S_OR_D ## pf.num_ffts_in_avg); \ num_ffts = minimum64((element->workspace.w ## S_OR_D ## pf.num_leftover + stride - 1) / stride, element->num_ffts - element->workspace.w ## S_OR_D ## pf.num_ffts_in_avg); \
...@@ -1441,6 +1446,10 @@ static void set_property(GObject *object, enum property id, const GValue *value, ...@@ -1441,6 +1446,10 @@ static void set_property(GObject *object, enum property id, const GValue *value,
gstlal_doubles_from_g_value_array(g_value_get_boxed(value), element->fir_filters, &m); gstlal_doubles_from_g_value_array(g_value_get_boxed(value), element->fir_filters, &m);
break; break;
case ARG_INPUT_MAY_BE_ZERO:
element->input_may_be_zero = g_value_get_boolean(value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, id, pspec);
break; break;
...@@ -1535,6 +1544,10 @@ static void get_property(GObject *object, enum property id, GValue *value, GPara ...@@ -1535,6 +1544,10 @@ static void get_property(GObject *object, enum property id, GValue *value, GPara
} }
break; break;
case ARG_INPUT_MAY_BE_ZERO:
g_value_set_boolean(value, element->input_may_be_zero);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, id, pspec);
break; break;
...@@ -1752,6 +1765,15 @@ static void gstlal_transferfunction_class_init(GSTLALTransferFunctionClass *klas ...@@ -1752,6 +1765,15 @@ static void gstlal_transferfunction_class_init(GSTLALTransferFunctionClass *klas
), ),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE
); );
properties[ARG_INPUT_MAY_BE_ZERO] = g_param_spec_boolean(
"input-may-be-zero",
"Input may be zero",
"Set to True if transfer functions should be computed even if an input\n\t\t\t"
"channel contains zeros. Default is False, to prevent errors when an\n\t\t\t"
"input channel has no data yet at start of stream, etc.",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT
);
g_object_class_install_property( g_object_class_install_property(
...@@ -1824,6 +1846,11 @@ static void gstlal_transferfunction_class_init(GSTLALTransferFunctionClass *klas ...@@ -1824,6 +1846,11 @@ static void gstlal_transferfunction_class_init(GSTLALTransferFunctionClass *klas
ARG_FIR_FILTERS, ARG_FIR_FILTERS,
properties[ARG_FIR_FILTERS] properties[ARG_FIR_FILTERS]
); );
g_object_class_install_property(
gobject_class,
ARG_INPUT_MAY_BE_ZERO,
properties[ARG_INPUT_MAY_BE_ZERO]
);
} }
......
...@@ -143,6 +143,7 @@ struct _GSTLALTransferFunction { ...@@ -143,6 +143,7 @@ struct _GSTLALTransferFunction {
int low_pass; int low_pass;
complex double *transfer_functions; complex double *transfer_functions;
double *fir_filters; double *fir_filters;
gboolean input_may_be_zero;
}; };
......
...@@ -126,7 +126,8 @@ def lal_transferfunction_02(pipeline, name): ...@@ -126,7 +126,8 @@ def lal_transferfunction_02(pipeline, name):
witness1 = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, calibration_parts.highpass(pipeline, hoft, rate, fcut = 400), calibration_parts.lowpass(pipeline, noise, rate, fcut = 400))) witness1 = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, calibration_parts.highpass(pipeline, hoft, rate, fcut = 400), calibration_parts.lowpass(pipeline, noise, rate, fcut = 400)))
witness2 = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, calibration_parts.lowpass(pipeline, hoft, rate, fcut = 600), calibration_parts.highpass(pipeline, noise, rate, fcut = 600))) witness2 = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, calibration_parts.lowpass(pipeline, hoft, rate, fcut = 600), calibration_parts.highpass(pipeline, noise, rate, fcut = 600)))
clean_data = calibration_parts.clean_data(pipeline, hoft, rate, calibration_parts.list_srcs(pipeline, witness1, witness2), rate, 4 * rate, 3 * rate + 1, 128, rate * test_duration, int(0.5 * rate), 5.0, filename = "highpass_lowpass_tfs.txt") hoft = calibration_parts.highpass(pipeline, hoft, rate)
clean_data = calibration_parts.clean_data(pipeline, hoft, rate, calibration_parts.list_srcs(pipeline, witness1, witness2), rate, 4 * rate, 2 * rate, 128, rate * test_duration, int(0.5 * rate), 10.0, filename = "highpass_lowpass_tfs.txt")
pipeparts.mknxydumpsink(pipeline, clean_data, "%s_out.txt" % name) pipeparts.mknxydumpsink(pipeline, clean_data, "%s_out.txt" % name)
return pipeline return pipeline
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment