Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
XLALSimAddInjectionTest.c
Go to the documentation of this file.
1#include <math.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5
6#include <lal/Date.h>
7#include <lal/LALSimulation.h>
8#include <lal/LALSimBurst.h>
9#include <lal/TimeSeries.h>
10#include <lal/Units.h>
11
12#define DELTA_T (1.0 / 16384) /* seconds */
13#define SIMLENGTH (16384 * 16) /* samples */
14#define DSTLENGTH (16384 * 128) /* samples */
15#define OFFSET 86.332874431 /* seconds */
16#define REAL4THRESH .5e-6
17#define REAL8THRESH 1e-12
18
19
21{
22 LIGOTimeGPS epoch = {0, 0};
26 double abs_before, abs_after;
27 unsigned i;
28
29 /* zero target time series */
30 memset(target->data->data, 0, target->data->length * sizeof(*target->data->data));
31 /* set "injection" to all 1s */
32 for(i = 0; i < source->data->length; i++)
33 source->data->data[i] = 1.0;
34
36 abs_before = XLALMeasureIntS1S2DT(x, x);
38
39 /* set injection epoch to something non-trivial */
40 XLALGPSAdd(&source->epoch, OFFSET);
41
42 /* add injection to target */
43 XLALSimAddInjectionREAL4TimeSeries(target, source, NULL);
44
46 abs_after = XLALMeasureIntS1S2DT(x, x);
48
49#if 0
50 /* dump result */
51 for(i = 0; i < target->data->length; i++) {
52 epoch = target->epoch;
53 XLALGPSAdd(&epoch, i * target->deltaT);
54 printf("%d.%09d %g\n", epoch.gpsSeconds, epoch.gpsNanoSeconds, target->data->data[i]);
55 }
56#endif
57
58 fprintf(stderr, "%s(): square integral before = %.17g, square integral after = %.17g, fractional difference = %g\n", __func__, abs_before, abs_after, fabs(abs_after - abs_before) / abs_before);
59 return fabs(abs_after - abs_before) / abs_before > REAL4THRESH;
60}
61
62
64{
65 LIGOTimeGPS epoch = {0, 0};
68 double abs_before, abs_after;
69 unsigned i;
70
71 /* zero target time series */
72 memset(target->data->data, 0, target->data->length * sizeof(*target->data->data));
73 /* set "injection" to all 1s */
74 for(i = 0; i < source->data->length; i++)
75 source->data->data[i] = 1.0;
76
77 abs_before = XLALMeasureIntS1S2DT(source, source);
78
79 /* set injection epoch to something non-trivial */
80 XLALGPSAdd(&source->epoch, OFFSET);
81
82 /* add injection to target */
83 XLALSimAddInjectionREAL8TimeSeries(target, source, NULL);
84
85 abs_after = XLALMeasureIntS1S2DT(target, target);
86
87#if 0
88 /* dump result */
89 for(i = 0; i < target->data->length; i++) {
90 epoch = target->epoch;
91 XLALGPSAdd(&epoch, i * target->deltaT);
92 printf("%d.%09d %g\n", epoch.gpsSeconds, epoch.gpsNanoSeconds, target->data->data[i]);
93 }
94#endif
95
96 fprintf(stderr, "%s(): square integral before = %.17g, square integral after = %.17g, fractional difference = %g\n", __func__, abs_before, abs_after, fabs(abs_after - abs_before) / abs_before);
97 return fabs(abs_after - abs_before) / abs_before > REAL8THRESH;
98}
99
100
101int main(int argc, char *argv[])
102{
103 (void) argc; /* silence unused parameter warning */
104 (void) argv; /* silence unused parameter warning */
106}
#define fprintf
int main(int argc, char *argv[])
#define OFFSET
static int TestXLALSimAddInjectionREAL4TimeSeries(void)
#define SIMLENGTH
#define DELTA_T
#define REAL4THRESH
#define DSTLENGTH
#define REAL8THRESH
static int TestXLALSimAddInjectionREAL8TimeSeries(void)
double i
Definition: bh_ringdown.c:118
REAL8 XLALMeasureIntS1S2DT(const REAL8TimeSeries *s1, const REAL8TimeSeries *s2)
Computes the integral of the product of two time series.
Definition: LALSimBurst.c:164
int XLALSimAddInjectionREAL4TimeSeries(REAL4TimeSeries *target, REAL4TimeSeries *h, const COMPLEX8FrequencySeries *response)
Adds a detector strain time series to detector data.
int XLALSimAddInjectionREAL8TimeSeries(REAL8TimeSeries *target, REAL8TimeSeries *h, const COMPLEX16FrequencySeries *response)
Adds a detector strain time series to detector data.
REAL4TimeSeries * XLALCreateREAL4TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
REAL8TimeSeries * XLALConvertREAL4TimeSeriesToREAL8(const REAL4TimeSeries *series)
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalDimensionlessUnit
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
x
INT4 gpsNanoSeconds
REAL4Sequence * data
LIGOTimeGPS epoch
REAL4 * data
REAL8Sequence * data
LIGOTimeGPS epoch
REAL8 * data
LIGOTimeGPS epoch
Definition: unicorn.c:20