25 #include <lal/LALStdio.h>
26 #include <lal/LALStdlib.h>
27 #include <lal/LALInspiral.h>
28 #include <lal/LALCache.h>
29 #include <lal/LALFrStream.h>
30 #include <lal/TimeFreqFFT.h>
31 #include <lal/LALDetectors.h>
32 #include <lal/AVFactories.h>
33 #include <lal/ResampleTimeSeries.h>
34 #include <lal/TimeSeries.h>
35 #include <lal/FrequencySeries.h>
36 #include <lal/Units.h>
38 #include <lal/StringInput.h>
39 #include <lal/VectorOps.h>
40 #include <lal/Random.h>
41 #include <lal/LALNoiseModels.h>
42 #include <lal/XLALError.h>
43 #include <lal/GenerateInspiral.h>
44 #include <lal/LIGOLwXMLRead.h>
45 #include <lal/SeqFactories.h>
46 #include <lal/DetectorSite.h>
47 #include <lal/GenerateInspiral.h>
48 #include <lal/GeneratePPNInspiral.h>
49 #include <lal/SimulateCoherentGW.h>
50 #include <lal/LIGOMetadataTables.h>
51 #include <lal/LIGOMetadataUtils.h>
52 #include <lal/LIGOMetadataInspiralUtils.h>
53 #include <lal/LIGOMetadataRingdownUtils.h>
54 #include <lal/LALInspiralBank.h>
55 #include <lal/FindChirp.h>
56 #include <lal/LALInspiralBank.h>
57 #include <lal/GenerateInspiral.h>
58 #include <lal/NRWaveInject.h>
59 #include <lal/GenerateInspRing.h>
61 #include <lal/LALInspiral.h>
62 #include <lal/LALSimulation.h>
63 #include <lal/LALInference.h>
64 #include <lal/LALInferenceLikelihood.h>
65 #include <lal/LALInferenceTemplate.h>
66 #include <lal/GenerateBurst.h>
67 #include <lal/LALInferenceBurstRoutines.h>
68 #include <lal/LALInferenceReadBurstData.h>
69 #include <lal/LALSimNoise.h>
71 #define LALINFERENCE_DEFAULT_FLOW "40.0"
89 REAL8 SNR=0.0,NetworkSNR=0.0;
94 REAL8 bufferLength = 2048.0;
100 char SNRpath[FILENAME_MAX+10]=
"";
102 minFlow = minFlow>thisData->
fLow ? thisData->
fLow : minFlow;
104 thisData = thisData->
next;
115 fprintf(stdout,
"WARNING: you did not give --event. Injecting event 0 of the xml table, which may not be what you want!\n");
119 snprintf(SNRpath,
sizeof(SNRpath),
"%s_snr.txt",
ppt->
value);
121 snprintf(SNRpath,
sizeof(SNRpath),
"snr.txt");
126 while(injTable){
Ninj++;injTable=injTable->
next;}
132 while(si<
event) {si++; injTable = injTable->
next;}
134 injEvent->
next = NULL;
156 char series_name[320];
157 sprintf(series_name,
"%s:injection",thisData->
name);
167 REAL8 Q, centre_frequency;
171 if ((centre_frequency + 3.0*centre_frequency/
Q)>= 1.0/(2.0*thisData->
timeData->
deltaT)){
172 XLALPrintWarning(
"WARNING: Your sample rate is too low to ensure a good analysis for a SG centered at f0=%lf and with Q=%lf. Consider increasing it to more than %lf. Exiting...\n",centre_frequency,
Q,2.0*(centre_frequency + 3.0*centre_frequency/
Q));
174 if ((centre_frequency -3.0*centre_frequency/
Q)<= thisData->
fLow){
176 "WARNING: The low frenquency tail of your SG centered at f0=%lf and with Q=%lf will lie below the low frequency cutoff. Whit your current settings and parameters the minimum f0 you can analyze without cuts is %lf.\n Continuing... \n",centre_frequency,
Q,centre_frequency -3.0*centre_frequency/
Q);
188 XLALPrintError(
"Unable to allocate memory for injection buffer\n");
208 thisData->
SNR=sqrt(SNR);
213 fprintf(stdout,
"Injected SNR in detector %s = %.1f\n",thisData->
name,thisData->
SNR);
215 sprintf(
filename,
"%s_timeInjection.dat",thisData->
name);
221 sprintf(
filename,
"%s_freqInjection.dat",thisData->
name);
232 thisData=thisData->
next;
240 NetworkSNR=sqrt(NetworkSNR);
241 fprintf(stdout,
"Network SNR of event %d = %.1e\n",
event,NetworkSNR);
288 thisData=thisData->
next;
291 FILE * snrout = fopen(SNRpath,
"w");
293 fprintf(stderr,
"Unable to open the path %s for writing SNR files\n",SNRpath);
294 fprintf(stderr,
"Error code %i: %s\n",errno,strerror(errno));
301 NetSNR+=(thisData->
SNR*thisData->
SNR);
302 thisData=thisData->
next;
306 fprintf(snrout,
"%4.2f\n",sqrt(NetSNR));
318 char SNRpath[FILENAME_MAX+16];
323 snprintf(SNRpath,
sizeof(SNRpath),
"%s_snr.txt",
ppt->
value);
325 snprintf(SNRpath,
sizeof(SNRpath),
"snr.txt");
344 fprintf(stdout,
"\n\n---\t\t ---\n");
346 fprintf(stdout,
"---\t\t ---\n\n");
350 XLALSimBurstChooseFDWaveform(&hptilde, &hctilde,
deltaF,
deltaT,inj_table->
frequency,inj_table->
q,inj_table->
duration,
f_min,
f_max,hrss_one,inj_table->
pol_ellipse_angle,inj_table->
pol_ellipse_e,extraParams,
approx);
355 XLALPrintError(
" ERROR in InjectFD(): error encountered when injecting waveform. errnum=%d\n",errnum);
360 REAL8 plainTemplateReal, plainTemplateImag;
361 REAL8 templateReal, templateImag;
367 REAL8 twopit, re, im, dre, dim, newRe, newIm;
380 while (dataPtr != NULL) {
385 inj_table->
ra, inj_table->
dec,
386 inj_table->
psi, gmst);
390 inj_table->
ra, inj_table->
dec,
397 timeshift = (injtime - instant) + timedelay;
400 Fplus*=inj_table->
hrss;
401 Fcross*=inj_table->
hrss;
402 dataPtr->
fPlus = Fplus;
406 char InjFileName[320];
407 sprintf(InjFileName,
"injection_%s.dat",dataPtr->
name);
408 FILE *outInj=fopen(InjFileName,
"w");
415 re = cos(twopit *
deltaF * lower);
416 im = -sin(twopit *
deltaF * lower);
417 for (
i=lower;
i<=upper; ++
i){
419 if (i < hptilde->
data->length) {
420 plainTemplateReal = Fplus * creal(hptilde->
data->
data[
i])
421 + Fcross * creal(hctilde->data->data[
i]);
422 plainTemplateImag = Fplus * cimag(hptilde->
data->
data[
i])
423 + Fcross * cimag(hctilde->data->data[
i]);
425 plainTemplateReal = 0.0;
426 plainTemplateImag = 0.0;
432 templateReal = (plainTemplateReal*re - plainTemplateImag*im);
433 templateImag = (plainTemplateReal*im + plainTemplateImag*re);
436 dim = -sin(twopit*
deltaF);
437 dre = -2.0*sin(0.5*twopit*
deltaF)*sin(0.5*twopit*
deltaF);
438 newRe = re + re*dre - im * dim;
439 newIm = im + re*dim + im*dre;
449 printf(
"injected SNR %.1f in IFO %s\n",sqrt(2.0*chisquared),dataPtr->
name);
450 NetSNR+=2.0*chisquared;
451 dataPtr->
SNR=sqrt(2.0*chisquared);
452 dataPtr = dataPtr->
next;
456 printf(
"injected Network SNR %.1f \n",sqrt(NetSNR));
void REPORTSTATUS(LALStatus *status)
int XLALSimBurstChooseFDWaveform(COMPLEX16FrequencySeries **hptilde, COMPLEX16FrequencySeries **hctilde, REAL8 deltaF, REAL8 deltaT, REAL8 f0, REAL8 q, REAL8 tau, REAL8 f_min, REAL8 f_max, REAL8 hrss, REAL8 polar_angle, REAL8 polar_ecc, LALSimBurstExtraParam *extraParams, BurstApproximant approximant)
int XLALGetBurstApproximantFromString(const CHAR *inString)
XLAL function to determine burst approximant from a string.
char * XLALGetStringFromBurstApproximant(BurstApproximant bapproximant)
XLAL function to determine string from approximant enum.
int XLALSimBurstImplementedFDApproximants(BurstApproximant approximant)
Checks whether the given approximant is implemented in lalsimulation's XLALSimInspiralChooseFDWavefor...
BurstApproximant
Enum that specifies the PN approximant to be used in computing the waveform.
static void PrintSNRsToFile(LALInferenceIFOData *IFOdata, char SNRpath[])
void InjectBurstFD(LALInferenceIFOData *IFOdata, SimBurst *inj_table, ProcessParamsTable *commandLine)
-----------— Inject in Frequency domain --------------—/
SimBurst * XLALSimBurstTableFromLIGOLw(const char *filename)
TimeSlide * XLALTimeSlideTableFromLIGOLw(const char *filename)
void XLALComputeDetAMResponse(double *fplus, double *fcross, const REAL4 D[3][3], const double ra, const double dec, const double psi, const double gmst)
COMPLEX16FrequencySeries * XLALCreateCOMPLEX16FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
void XLALDestroyCOMPLEX16FrequencySeries(COMPLEX16FrequencySeries *series)
void LALInferenceAddVariable(LALInferenceVariables *vars, const char *name, const void *value, LALInferenceVariableType type, LALInferenceParamVaryType vary)
Add a variable named name to vars with initial value referenced by value.
void LALInferenceClearVariables(LALInferenceVariables *vars)
Delete the variables in this structure.
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
Returns the element of the process params table with "name".
@ LALINFERENCE_PARAM_FIXED
A parameter that is cyclic, such as an angle between 0 and 2pi.
void LALInferenceBurstInjectionToVariables(SimBurst *theEventTable, LALInferenceVariables *vars)
Fill the variables passed in vars with the parameters of the injection passed in event will over-writ...
void LALInferenceInjectBurstSignal(LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
Read IFO data according to command line arguments.
int XLALResampleREAL8TimeSeries(REAL8TimeSeries *series, REAL8 dt)
REAL8 XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
int XLALREAL8TimeFreqFFT(COMPLEX16FrequencySeries *freq, const REAL8TimeSeries *tser, const REAL8FFTPlan *plan)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
const LALUnit lalStrainUnit
const LALUnit lalDimensionlessUnit
#define XLAL_ERROR_VOID(...)
int * XLALGetErrnoPtr(void)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
int XLALBurstInjectSignals(REAL8TimeSeries *h, const SimBurst *sim_burst, const TimeSlide *time_slide_table_head, const COMPLEX16FrequencySeries *response)
Structure to contain IFO data.
REAL8TimeSeries * timeData
Detector name.
LALDetector * detector
integration limits for overlap integral in F-domain
REAL8FrequencySeries * oneSidedNoisePowerSpectrum
REAL8 timeshift
Detector responses.
REAL8FFTPlan * timeToFreqFFTPlan
Padding for the above window.
REAL8Window * window
(one-sided Noise Power Spectrum)^{-1/2}
COMPLEX16FrequencySeries * freqData
What is this?
REAL8 SNR
The epoch of this observation (the time of the first sample)
struct tagLALInferenceIFOData * next
ROQ data.
REAL8 fLow
FFT plan needed for time/time-and-phase marginalisation.
The LALInferenceVariables structure to contain a set of parameters Implemented as a linked list of LA...
LALInferenceVariableItem * head
CHAR value[LIGOMETA_VALUE_MAX]
char waveform[LIGOMETA_WAVEFORM_MAX]
struct tagSimBurst * next
LIGOTimeGPS time_geocent_gps