Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALSimBurstImg.c
Go to the documentation of this file.
1#include <math.h>
2#include <string.h>
3
4#include <gsl/gsl_rng.h>
5
6#include <lal/LALStdlib.h>
7#include <lal/LALConstants.h>
8#include <lal/Date.h>
9#include <lal/TimeSeries.h>
10#include <lal/Units.h>
11#include <lal/LALSimBurst.h>
12
13/**
14 * \brief Generates a burst injection with a time-frequency structure specified
15 * in an image array.
16 *
17 * \note The image array data is ordered so that the first point corresponds
18 * to the upper-left point of the image. The number of rows in the image
19 * is given in NUMROWS = image->dimLength->data[0] and the number of columns in
20 * the image is given in NUMCOLUMNS = image->dimLength->data[1]. The data is
21 * packed in row-major order so that offset = row * NUMCOLUMNS + column.
22 *
23 * \note The time-frequency volume of each pixel, dt * df, must be at least
24 * 2/pi.
25 */
27 REAL8TimeSeries **hplus, /**< plus-polarization waveform [returned] */
28 REAL8TimeSeries **hcross, /**< cross-polarization waveform [returned] */
29 REAL8Array *image, /**< image array */
30 double dt, /**< pixel time duration (s) */
31 double df, /**< pixel frequency bandwidth (Hz) */
32 double fstart, /**< start frequency of image (Hz) */
33 double hrss, /**< root-sum-squared value of the waveform (s) */
34 double deltaT, /**< sampleing interval (s) */
35 gsl_rng *rng /**< random number generator */
36)
37{
39 size_t row, col, nrow, ncol, pad, length;
40 double fac, hss;
41 size_t j;
42
43 /* sanity check on input values */
44 XLAL_CHECK(dt * df > LAL_2_PI, XLAL_EINVAL, "Time-frequency volume dt*df must be greater than 2/pi");
45 XLAL_CHECK(image->dimLength->length == 2, XLAL_EINVAL, "Requires a 2-dimensional array");
46
47 nrow = image->dimLength->data[0];
48 ncol = image->dimLength->data[1];
49
50 /* make a time series that has some padding at start and end */
51 pad = floor(15.0 * dt / deltaT);
52 length = floor((ncol - 1.) * dt / deltaT) + 2 * pad;
53 XLALGPSSetREAL8(&epoch, -1. * pad * deltaT);
54 *hplus = XLALCreateREAL8TimeSeries("Image +", &epoch, 0.0, deltaT, &lalStrainUnit, length);
55 *hcross = XLALCreateREAL8TimeSeries("Image x", &epoch, 0.0, deltaT, &lalStrainUnit, length);
56 if (!*hplus || !*hcross)
58 memset((*hplus)->data->data, 0, length * sizeof(*(*hplus)->data->data));
59 memset((*hcross)->data->data, 0, length * sizeof(*(*hcross)->data->data));
60
61 for (row = 0; row < nrow; ++row) {
62 for (col = 0; col < ncol; ++col) {
65 double t = floor(col * dt / deltaT) * deltaT;
66 double f = fstart + (nrow - row) * df;
67 double Y = image->data[row * ncol + col];
68 if (XLALGenerateBandAndTimeLimitedWhiteNoiseBurst(&hp, &hc, dt, f, df, 0., 0., Y, deltaT, rng) < 0) {
72 }
73 XLALGPSAdd(&hp->epoch, t);
74 XLALGPSAdd(&hc->epoch, t);
75 XLALAddREAL8TimeSeries(*hplus, hp);
76 XLALAddREAL8TimeSeries(*hcross, hc);
79 }
80 }
81
82 /* normalize to desired hrss value */
83 hss = 0;
84 for (j = 0; j < (*hplus)->data->length; ++j) {
85 double h = (*hplus)->data->data[j];
86 hss += h * h * (*hplus)->deltaT;
87 }
88 for (j = 0; j < (*hcross)->data->length; ++j) {
89 double h = (*hcross)->data->data[j];
90 hss += h * h * (*hcross)->deltaT;
91 }
92 fac = hrss / sqrt(hss);
93 for (j = 0; j < (*hplus)->data->length; ++j)
94 (*hplus)->data->data[j] *= fac;
95 for (j = 0; j < (*hcross)->data->length; ++j)
96 (*hcross)->data->data[j] *= fac;
97
98 return 0;
99}
double dt
Definition: bh_ringdown.c:113
#define LAL_2_PI
int XLALSimBurstImg(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8Array *image, double dt, double df, double fstart, double hrss, double deltaT, gsl_rng *rng)
Generates a burst injection with a time-frequency structure specified in an image array.
int XLALGenerateBandAndTimeLimitedWhiteNoiseBurst(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 duration, REAL8 frequency, REAL8 bandwidth, REAL8 eccentricity, REAL8 phase, REAL8 int_hdot_squared, REAL8 delta_t, gsl_rng *rng)
Generate a band- and time-limited white-noise burst waveform with Gaussian envelopes in the time and ...
Definition: LALSimBurst.c:745
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
REAL8TimeSeries * XLALAddREAL8TimeSeries(REAL8TimeSeries *arg1, const REAL8TimeSeries *arg2)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalStrainUnit
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
XLAL_EFUNC
XLAL_EINVAL
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
UINT4Vector * dimLength
REAL8 * data
LIGOTimeGPS epoch
UINT4 * data
LIGOTimeGPS epoch
Definition: unicorn.c:20
double hrss
Definition: unicorn.c:21
double deltaT
Definition: unicorn.c:24