Skip to content
Snippets Groups Projects
Commit ad622084 authored by Chris Pankow's avatar Chris Pankow
Browse files

gstlal_snglburst.{c,h}: Add utility functions for direct buffer -> trigger list conversion

parent 115a3c13
No related branches found
No related tags found
No related merge requests found
......@@ -174,3 +174,67 @@ GstBuffer *gstlal_snglburst_new_buffer_from_list(SnglBurst *input, GstPad *pad,
return srcbuf;
}
SnglBurst *gstlal_snglburst_new_list_from_double_buffer(double *input, SnglBurst *bankarray, GstClockTime time, guint channels, guint samples, guint rate, gdouble threshold, SnglBurst* output)
{
/* advance the pointer if we have one */
guint channel, sample;
/* FIXME do error checking */
for (channel = 0; channel < channels; channel++) {
for (sample = 0; sample < samples; sample++) {
if (input[channels*sample+channel] > threshold) {
SnglBurst *new_event = XLALCreateSnglBurst();
memcpy(new_event, &(bankarray[channel]), sizeof(*new_event));
LIGOTimeGPS peak_time;
XLALINT8NSToGPS(&peak_time, time);
XLALGPSAdd(&peak_time, (double) sample / rate);
XLALGPSAdd(&peak_time, -new_event->duration/2);
// Center the tile
XLALGPSAdd(&peak_time, 1.0/(2.0*rate));
LIGOTimeGPS start_time = peak_time;
XLALGPSAdd(&start_time, -new_event->duration/2);
new_event->snr = fabs(input[channels*sample+channel]);
new_event->start_time = start_time;
new_event->peak_time = peak_time;
new_event->next = output;
output = new_event;
}
}
}
return output;
}
SnglBurst *gstlal_snglburst_new_list_from_complex_double_buffer(complex double *input, SnglBurst *bankarray, GstClockTime time, guint channels, guint samples, guint rate, gdouble threshold, SnglBurst* output)
{
/* advance the pointer if we have one */
guint channel, sample;
/* FIXME do error checking */
for (channel = 0; channel < channels; channel++) {
for (sample = 0; sample < samples; sample++) {
/* FIXME Which are we thresholding on. the EP version uses the
* squared value, so we make this consistent */
if (cabs(input[channels*sample+channel]) > sqrt(threshold)) {
SnglBurst *new_event = XLALCreateSnglBurst();
memcpy(new_event, &(bankarray[channel]), sizeof(*new_event));
LIGOTimeGPS peak_time;
XLALINT8NSToGPS(&peak_time, time);
XLALGPSAdd(&peak_time, (double) sample / rate);
XLALGPSAdd(&peak_time, -new_event->duration/2);
// Center the tile
XLALGPSAdd(&peak_time, 1.0/(2.0*rate));
LIGOTimeGPS start_time = peak_time;
XLALGPSAdd(&start_time, -new_event->duration/2);
new_event->snr = cabs(input[channels*sample+channel]);
new_event->start_time = start_time;
new_event->peak_time = peak_time;
new_event->next = output;
output = new_event;
}
}
}
return output;
}
......@@ -25,6 +25,9 @@ SnglBurst *gstlal_snglburst_new_double_buffer_from_peak(struct gstlal_peak_state
SnglBurst *gstlal_snglburst_new_list_from_peak(struct gstlal_peak_state *input, SnglBurst *bankarray, GstClockTime time, guint rate, SnglBurst* output);
SnglBurst *gstlal_snglburst_new_list_from_double_peak(struct gstlal_peak_state *input, SnglBurst *bankarray, GstClockTime time, guint rate, SnglBurst* output);
SnglBurst *gstlal_snglburst_new_list_from_double_buffer(double *input, SnglBurst *bankarray, GstClockTime time, guint channels, guint samples, guint rate, gdouble threshold, SnglBurst* output);
SnglBurst *gstlal_snglburst_new_list_from_complex_double_buffer(double *input, SnglBurst *bankarray, GstClockTime time, guint channels, guint samples, guint rate, gdouble threshold, SnglBurst* output);
GstBuffer *gstlal_snglburst_new_buffer_from_list(SnglBurst *input, GstPad *pad, guint64 offset, guint64 length, GstClockTime time, guint rate, guint64 *count);
G_END_DECLS
......
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