LALInference 4.1.10.1-bf6a62b
LALInferenceReadData.c
Go to the documentation of this file.
1/*
2 * LALInferenceReadData.c: Bayesian Followup functions
3 *
4 * Copyright (C) 2009,2012 Ilya Mandel, Vivien Raymond, Christian
5 * Roever, Marc van der Sluys, John Veitch, Salvatore Vitale, and
6 * Will M. Farr
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with with program; see the file COPYING. If not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301 USA
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <errno.h>
28#include <unistd.h>
29
30#include <lal/LALStdio.h>
31#include <lal/LALStdlib.h>
32
33#include <lal/LALInspiral.h>
34#include <lal/LALCache.h>
35#include <lal/LALFrStream.h>
36#include <lal/TimeFreqFFT.h>
37#include <lal/LALDetectors.h>
38#include <lal/AVFactories.h>
39#include <lal/ResampleTimeSeries.h>
40#include <lal/Sequence.h>
41#include <lal/TimeSeries.h>
42#include <lal/FrequencySeries.h>
43#include <lal/Units.h>
44#include <lal/Date.h>
45#include <lal/StringInput.h>
46#include <lal/VectorOps.h>
47#include <lal/Random.h>
48#include <lal/LALNoiseModels.h>
49#include <lal/XLALError.h>
50#include <lal/GenerateInspiral.h>
51#include <lal/LIGOLwXMLRead.h>
52
53#include <lal/SeqFactories.h>
54#include <lal/DetectorSite.h>
55#include <lal/GenerateInspiral.h>
56#include <lal/GeneratePPNInspiral.h>
57#include <lal/SimulateCoherentGW.h>
58#include <lal/LIGOMetadataTables.h>
59#include <lal/LIGOMetadataUtils.h>
60#include <lal/LIGOMetadataInspiralUtils.h>
61#include <lal/LIGOMetadataRingdownUtils.h>
62#include <lal/LALInspiralBank.h>
63#include <lal/FindChirp.h>
64#include <lal/LALInspiralBank.h>
65#include <lal/GenerateInspiral.h>
66#include <lal/NRWaveInject.h>
67#include <lal/GenerateInspRing.h>
68#include <math.h>
69#include <lal/LALInspiral.h>
70#include <lal/LALSimulation.h>
71#include <lal/LIGOLwXMLRead.h>
72
73#include <lal/LALInference.h>
74#include <lal/LALInferenceReadData.h>
75#include <lal/LALInferenceLikelihood.h>
76#include <lal/LALInferenceTemplate.h>
77#include <lal/LALInferenceInit.h>
78#include <lal/LALSimNoise.h>
80/* LIB deps */
81#include <lal/LALInferenceBurstRoutines.h>
82
83struct fvec {
86};
87
88#define LALINFERENCE_DEFAULT_FLOW "20.0"
89
90static void LALInferenceSetGPSTrigtime(LIGOTimeGPS *GPStrig, ProcessParamsTable *commandLine);
91struct fvec *interpFromFile(char *filename, REAL8 squareinput);
92
93struct fvec *interpFromFile(char *filename, REAL8 squareinput){
94 UINT4 fileLength=0;
95 UINT4 i=0;
96 UINT4 minLength=100; /* size of initial file buffer, and also size of increment */
97 FILE *interpfile=NULL;
98 struct fvec *interp=NULL;
99 interp=XLALCalloc(minLength,sizeof(struct fvec)); /* Initialise array */
100 if(!interp) {printf("Unable to allocate memory buffer for reading interpolation file\n");}
101 fileLength=minLength;
102 REAL8 f=0.0,x=0.0;
103 interpfile = fopen(filename,"r");
104 if (interpfile==NULL){
105 printf("Unable to open file %s\n",filename);
106 abort();
107 }
108 while(2==fscanf(interpfile," %lf %lf ", &f, &x )){
109 interp[i].f=f;
110 if (squareinput) {
111 interp[i].x=x*x;
112 }
113 else {
114 interp[i].x=x;
115 }
116 i++;
117 if(i>fileLength-1){ /* Grow the array */
118 interp=XLALRealloc(interp,(fileLength+minLength)*sizeof(struct fvec));
119 fileLength+=minLength;
120 }
121 }
122 interp[i].f=0.0; interp[i].x=0.0;
123 fileLength=i+1;
124 interp=XLALRealloc(interp,fileLength*sizeof(struct fvec)); /* Resize array */
125 fclose(interpfile);
126 printf("Read %i records from %s\n",fileLength-1,filename);
127 if(fileLength-1 <1)
128 {
129 XLALPrintError("Error: read no records from %s\n",filename);
130 abort();
131 }
132 return interp;
133}
134
135REAL8 interpolate(struct fvec *fvec, REAL8 f);
137 int i=0;
138 REAL8 a=0.0; /* fractional distance between bins */
139 if(f<fvec[1].f) return(INFINITY); /* Frequency below minimum */
140 while((i==0) || (fvec[i].f<f && (fvec[i].x!=0.0 ))){i++;}; //&& fvec[i].f!=0.0)){i++;};
141 if (fvec[i].f==0.0 && fvec[i].x==0.0) /* Frequency above maximum */
142 {
143 return (INFINITY);
144 }
145 a=(fvec[i].f-f)/(fvec[i].f-fvec[i-1].f);
146 return (fvec[i-1].x*a + fvec[i].x*(1.0-a));
147}
148
149void InjectFD(LALInferenceIFOData *IFOdata, SimInspiralTable *inj_table, ProcessParamsTable *commandLine);
151
152typedef void (NoiseFunc)(LALStatus *statusPtr,REAL8 *psd,REAL8 f);
153void MetaNoiseFunc(LALStatus *status, REAL8 *psd, REAL8 f, struct fvec *interp, NoiseFunc *noisefunc);
154
155void MetaNoiseFunc(LALStatus *status, REAL8 *psd, REAL8 f, struct fvec *interp, NoiseFunc *noisefunc){
156 if(interp==NULL&&noisefunc==NULL){
157 printf("ERROR: Trying to calculate PSD with NULL inputs\n");
158 abort();
159 }
160 if(interp!=NULL && noisefunc!=NULL){
161 printf("ERROR: You have specified both an interpolation vector and a function to calculate the PSD\n");
162 abort();
163 }
164 if(noisefunc!=NULL){
165 noisefunc(status,psd,f);
166 return;
167 }
168 if(interp!=NULL){ /* Use linear interpolation of the interp vector */
169 *psd=interpolate(interp,f);
170 return;
171 }
172}
173
174
175static const LALUnit strainPerCount={0,{0,0,0,0,0,1,-1},{0,0,0,0,0,0,0}};
176
177static REAL8TimeSeries *readTseries(LALCache *cache, CHAR *channel, LIGOTimeGPS start, REAL8 length);
178static void makeWhiteData(LALInferenceIFOData *IFOdata);
179static void PrintSNRsToFile(LALInferenceIFOData *IFOdata , char SNRpath[] );
180
181
182static LALCache *GlobFramesPWD( char *ifo);
183static LALCache *GlobFramesPWD(char *ifo)
184{
185 LALCache *frGlobCache = NULL;
186
187 /* create a frame cache by globbing all *.gwf files in the pwd */
188 /* FIXME: This should really open all the files and see if the desired channel is in there */
189 char globPattern[8];
190 sprintf(globPattern,"%c-*.gwf",ifo[0]);
191 frGlobCache = XLALCacheGlob(NULL,globPattern);
192
193 /* check we globbed at least one frame file */
194 if ( ! frGlobCache->length )
195 {
196 fprintf( stderr, "error: no frame file files found\n");
197 abort();
198 }
199 CHAR ifoRegExPattern[6];
200 LALCache *frInCache=NULL;
201 /* sieve out the requested data type */
202 snprintf( ifoRegExPattern,
203 XLAL_NUM_ELEM(ifoRegExPattern), ".*%c.*",
204 ifo[0] );
205 fprintf(stderr,"GlobFramesPWD : Found unseived src files:\n");
206 for(UINT4 i=0;i<frGlobCache->length;i++)
207 fprintf(stderr,"(%s,%s,%s)\n",frGlobCache->list[i].src,frGlobCache->list[i].dsc,frGlobCache->list[i].url);
208 frInCache = XLALCacheDuplicate(frGlobCache);
209 XLALCacheSieve(frInCache, 0, 0, ifoRegExPattern, NULL, NULL);
210 if ( ! frGlobCache->length )
211 {
212 fprintf( stderr, "error: no frame file files found after sieving\n");
213 abort();
214 }
215 else
216 {
217 fprintf(stderr,"GlobFramesPWD : Sieved frames with pattern %s. Found src files:\n",ifoRegExPattern);
218 for(UINT4 i=0;i<frInCache->length;i++)
219 fprintf(stderr,"(%s,%s,%s)\n",frInCache->list[i].src,frInCache->list[i].dsc,frInCache->list[i].url);
220 }
221
222 return(frGlobCache);
223}
224
225static REAL8TimeSeries *readTseries(LALCache *cache, CHAR *channel, LIGOTimeGPS start, REAL8 length)
226{
227 /* This function attempts to read the data from the given cache file. If it failes to open the data
228 * it waits for a period and tries again, up to 5 times. This is an attempt to get around overloading
229 * of file servers when many jobs are run at the time same */
231 UINT4 max_tries=7,tries=0,delay=5;
232 memset(&status,0,sizeof(status));
233 LALFrStream *stream = NULL;
234 REAL8TimeSeries *out = NULL;
235 if(cache==NULL) fprintf(stderr,"readTseries ERROR: Received NULL pointer for channel %s\n",channel);
236 for (tries=0,delay=5;tries<max_tries;tries++,delay*=2) {
237 stream = XLALFrStreamCacheOpen( cache );
238 if(stream) break;
239 sleep(delay);
240 }
241 if(stream==NULL) {fprintf(stderr,"readTseries ERROR: Unable to open stream from frame cache file\n"); abort();}
242
243 for (tries=0,delay=5;tries<max_tries;tries++,delay*=2) {
244 out = XLALFrStreamInputREAL8TimeSeries( stream, channel, &start, length , 0 );
245 if(out) break;
246 sleep(delay);
247 }
248 if(out==NULL) fprintf(stderr,"readTseries ERROR: unable to read channel %s at times %i - %f\nCheck the specified data duration is not too long\n",channel,start.gpsSeconds,start.gpsSeconds+length);
249 XLALFrStreamClose(stream);
250 return out;
251}
252
253/**
254 * Parse the command line looking for options of the kind --ifo H1 --H1-channel H1:LDAS_STRAIN --H1-cache H1.cache --H1-flow 20.0 --H1-fhigh 4096.0 --H1-timeslide 100.0 --H1-asd asd_ascii.txt --H1-psd psd_ascii.txt ...
255 * It is necessary to use this method instead of the old method for the pipeline to work in DAX mode. Warning: do not mix options between
256 * the old and new style.
257 */
258static INT4 getDataOptionsByDetectors(ProcessParamsTable *commandLine, char ***ifos, char ***caches, char ***channels, char ***flows , char ***fhighs, char ***timeslides, char ***asds, char ***psds, UINT4 *N)
259{
260 /* Check that the input has no lists with [ifo,ifo] */
261 ProcessParamsTable *this=commandLine;
262 UINT4 i=0;
263 *caches=*ifos=*channels=*flows=*fhighs=*timeslides=*asds=*psds=NULL;
264 *N=0;
265 char tmp[128];
266 if(!this) {fprintf(stderr,"No command line arguments given!\n"); abort();}
267 /* Construct a list of IFOs */
268 for(this=commandLine;this;this=this->next)
269 {
270 if(!strcmp(this->param,"--ifo"))
271 {
272 (*N)++;
273 *ifos=XLALRealloc(*ifos,*N*sizeof(char *));
274 (*ifos)[*N-1]=XLALStringDuplicate(this->value);
275 }
276 }
277 *caches=XLALCalloc(*N,sizeof(char *));
278 *channels=XLALCalloc(*N,sizeof(char *));
279 *flows=XLALCalloc(*N,sizeof(REAL8));
280 *fhighs=XLALCalloc(*N,sizeof(REAL8));
281 *timeslides=XLALCalloc(*N,sizeof(REAL8));
282 *asds=XLALCalloc(*N,sizeof(char *));
283 *psds=XLALCalloc(*N,sizeof(char *));
284
285 int globFrames=!!LALInferenceGetProcParamVal(commandLine,"--glob-frame-data");
286
287 /* For each IFO, fetch the other options if available */
288 for(i=0;i<*N;i++)
289 {
290 /* Cache */
291 if(!globFrames){
292 sprintf(tmp,"--%s-cache",(*ifos)[i]);
293 this=LALInferenceGetProcParamVal(commandLine,tmp);
294 if(!this){fprintf(stderr,"ERROR: Must specify a cache file for %s with --%s-cache\n",(*ifos)[i],(*ifos)[i]); abort();}
295 (*caches)[i]=XLALStringDuplicate(this->value);
296 }
297
298 /* Channel */
299 sprintf(tmp,"--%s-channel",(*ifos)[i]);
300 this=LALInferenceGetProcParamVal(commandLine,tmp);
301 (*channels)[i]=XLALStringDuplicate(this?this->value:"Unknown channel");
302
303 /* flow */
304 sprintf(tmp,"--%s-flow",(*ifos)[i]);
305 this=LALInferenceGetProcParamVal(commandLine,tmp);
306 (*flows)[i]=XLALStringDuplicate(this?this->value:LALINFERENCE_DEFAULT_FLOW);
307
308 /* fhigh */
309 sprintf(tmp,"--%s-fhigh",(*ifos)[i]);
310 this=LALInferenceGetProcParamVal(commandLine,tmp);
311 (*fhighs)[i]=this?XLALStringDuplicate(this->value):NULL;
312
313 /* timeslides */
314 sprintf(tmp,"--%s-timeslide",(*ifos)[i]);
315 this=LALInferenceGetProcParamVal(commandLine,tmp);
316 (*timeslides)[i]=XLALStringDuplicate(this?this->value:"0.0");
317
318 /* ASD */
319 sprintf(tmp,"--%s-asd",(*ifos)[i]);
320 this=LALInferenceGetProcParamVal(commandLine,tmp);
321 (*asds)[i]=this?XLALStringDuplicate(this->value):NULL;
322
323 /* PSD */
324 sprintf(tmp,"--%s-psd",(*ifos)[i]);
325 this=LALInferenceGetProcParamVal(commandLine,tmp);
326 (*psds)[i]=this?XLALStringDuplicate(this->value):NULL;
327 }
328 return(1);
329}
330
331/**
332 * Parse the command line looking for options of the kind ---IFO-name value
333 * Unlike the function above, this one does not have a preset list of names to lookup, but instead uses the option "name"
334 * It is necessary to use this method instead of the old method for the pipeline to work in DAX mode. Warning: do not mix options between
335 * the old and new style.
336 * Return 0 if the number of options --IFO-name doesn't much the number of ifos, 1 otherwise. Fills in the pointer out with the values that were found.
337 */
338static INT4 getNamedDataOptionsByDetectors(ProcessParamsTable *commandLine, char ***ifos, char ***out, const char *name, UINT4 *N)
339{
340 /* Check that the input has no lists with [ifo,ifo] */
341 ProcessParamsTable *this=commandLine;
342 UINT4 i=0;
343 *out=*ifos=NULL;
344 *N=0;
345 char tmp[128];
346 if(!this) {fprintf(stderr,"No command line arguments given!\n"); abort();}
347 /* Construct a list of IFOs */
348 for(this=commandLine;this;this=this->next)
349 {
350 if(!strcmp(this->param,"--ifo"))
351 {
352 (*N)++;
353 *ifos=XLALRealloc(*ifos,*N*sizeof(char *));
354 (*ifos)[*N-1]=XLALStringDuplicate(this->value);
355 }
356 }
357 *out=XLALCalloc(*N,sizeof(char *));
358
359 UINT4 found=0;
360 /* For each IFO, fetch the other options if available */
361 for(i=0;i<*N;i++)
362 {
363 /* Channel */
364 sprintf(tmp,"--%s-%s",(*ifos)[i],name);
365 this=LALInferenceGetProcParamVal(commandLine,tmp);
366 (*out)[i]=this?XLALStringDuplicate(this->value):NULL;
367 if (this) found++;
368
369 }
370 if (found==*N)
371 return(1);
372 else
373 return 0;
374}
375
377
379 memset(&status,0,sizeof(status));
380 UINT4 Nifo=0,i,j;
381 LALInferenceIFOData *thisData=IFOdata;
382 UINT4 q=0;
383 UINT4 event=0;
384 ProcessParamsTable *procparam=NULL,*ppt=NULL;
385 SimInspiralTable *injTable=NULL;
386 //ProcessParamsTable *pptdatadump=NULL;
387 LIGOTimeGPS GPStrig;
388 while(thisData){
389 thisData=thisData->next;
390 Nifo++;
391 }
392
393 procparam=LALInferenceGetProcParamVal(commandLine,"--inj");
394 if(procparam){
395 injTable = XLALSimInspiralTableFromLIGOLw(procparam->value);
396 if(!injTable){
397 fprintf(stderr,"Unable to open injection file(LALInferenceReadData) %s\n",procparam->value);
398 abort();
399 }
400 procparam=LALInferenceGetProcParamVal(commandLine,"--event");
401 if(procparam) {
402 event=atoi(procparam->value);
403 while(q<event) {q++; injTable=injTable->next;}
404 }
405 else if ((procparam=LALInferenceGetProcParamVal(commandLine,"--event-id")))
406 {
407 while(injTable)
408 {
409 if(injTable->simulation_id == atol(procparam->value)) break;
410 else injTable=injTable->next;
411 }
412 if(!injTable){
413 fprintf(stderr,"Error, cannot find simulation id %s in injection file\n",procparam->value);
414 abort();
415 }
416 }
417 }
418
419 if(LALInferenceGetProcParamVal(commandLine,"--trigtime")){
420 procparam=LALInferenceGetProcParamVal(commandLine,"--trigtime");
421 XLALStrToGPS(&GPStrig,procparam->value,NULL);
422 }
423 else{
424 if(injTable) memcpy(&GPStrig,&(injTable->geocent_end_time),sizeof(GPStrig));
425 else {
426 fprintf(stderr,"+++ Error: No trigger time specifed and no injection given \n");
427 abort();
428 }
429 }
430
431 if (LALInferenceGetProcParamVal(commandLine, "--data-dump")) {
432 //pptdatadump=LALInferenceGetProcParamVal(commandLine,"--data-dump");
433 const UINT4 nameLength=FILENAME_MAX+50;
434 char filename[nameLength];
435 FILE *out;
436
437 for (i=0;i<Nifo;i++) {
438
439 ppt=LALInferenceGetProcParamVal(commandLine,"--outfile");
440 if(ppt) {
441 if((int)nameLength<=snprintf(filename, nameLength, "%s%s-timeDataWithInjection.dat", ppt->value, IFOdata[i].name))
442 XLAL_ERROR_VOID(XLAL_EINVAL, "Output filename too long!");
443 }
444 //else if(strcmp(pptdatadump->value,"")) {
445 // snprintf(filename, nameLength, "%s/%s-timeDataWithInjection.dat", pptdatadump->value, IFOdata[i].name);
446 //}
447 else
448 snprintf(filename, nameLength, "%.3f_%s-timeDataWithInjection.dat", GPStrig.gpsSeconds+1e-9*GPStrig.gpsNanoSeconds, IFOdata[i].name);
449 out = fopen(filename, "w");
450 if(!out){
451 fprintf(stderr,"Unable to open the path %s for writing time data with injection files\n",filename);
452 abort();
453 }
454 for (j = 0; j < IFOdata[i].timeData->data->length; j++) {
455 REAL8 t = XLALGPSGetREAL8(&(IFOdata[i].timeData->epoch)) +
456 j * IFOdata[i].timeData->deltaT;
457 REAL8 d = IFOdata[i].timeData->data->data[j];
458
459 fprintf(out, "%.6f %g\n", t, d);
460 }
461 fclose(out);
462
463 ppt=LALInferenceGetProcParamVal(commandLine,"--outfile");
464 if(ppt) {
465 snprintf(filename, nameLength, "%s%s-freqDataWithInjection.dat", ppt->value, IFOdata[i].name) ;
466 }
467 //else if(strcmp(pptdatadump->value,"")) {
468 // snprintf(filename, nameLength, "%s/%s-freqDataWithInjection.dat", pptdatadump->value, IFOdata[i].name);
469 //}
470 else
471 snprintf(filename, nameLength, "%.3f_%s-freqDataWithInjection.dat", GPStrig.gpsSeconds+1e-9*GPStrig.gpsNanoSeconds, IFOdata[i].name);
472 out = fopen(filename, "w");
473 if(!out){
474 fprintf(stderr,"Unable to open the path %s for writing freq data with injection files\n",filename);
475 abort();
476 }
477 for (j = 0; j < IFOdata[i].freqData->data->length; j++) {
478 REAL8 f = IFOdata[i].freqData->deltaF * j;
479 REAL8 dre = creal(IFOdata[i].freqData->data->data[j]);
480 REAL8 dim = cimag(IFOdata[i].freqData->data->data[j]);
481
482 fprintf(out, "%10.10g %10.10g %10.10g\n", f, dre, dim);
483 }
484 fclose(out);
485
486 }
487
488 }
489
490}
491
492#define USAGE "\
493 ----------------------------------------------\n\
494 --- Data Parameters --------------------------\n\
495 ----------------------------------------------\n\
496 Options for reading/generating data. User should specify which interferometers\n\
497 to use and their data source using the following options. The data source\n\
498 can be either a LFS cache file (generated by gw_data_find) with channel name\n\
499 (e.g. --H1-cache H1.cache --H1-channel H1:DCS-CALIB-STRAIN_C02 )\n\
500 or internally-generated gaussian noise with a given detector PSD model\n\
501 (e.g. --H1-cache LALSimAdLIGO --dataseed 1234)\n\
502 or by searching for frame files in the local directory\n\
503 (e.g. --glob-frame-data --H1-channel H1:DCS-CALIB-STRAIN_C02)\n\
504 \n\
505 Additional noise curves for simulated data can be specified by providing\n\
506 their PSD or ASD as a text file. See detailed options below.\n\
507 \n\
508 --ifo IFO1 [--ifo IFO2 ...] IFOs can be H1,L1,V1\n\
509 --IFO1-cache cache1 Cache files \n\
510 [--IFO2-cache2 cache2 ...] lal PSDs: LAL{Ad}LIGO, LALVirgo\n\
511 lalsimuation PSDs: LALSim{Ad}LIGO, LALSim{Ad}Virgo\n\
512 interpolate from file: interp:asd_file.txt\n\
513 --psdstart GPStime GPS start time of PSD estimation data\n\
514 --psdlength length Length of PSD estimation data in seconds\n\
515 --seglen length Length of segments for PSD estimation and analysis in seconds\n\
516 (--glob-frame-data) Will search for frame files containing data in the PWD.\n\
517 Filenames must begin with the IFO's 1-letter code, e.g. H-*.gwf\n\
518 (--dont-dump-extras) If given, won't save PSD and SNR files\n\
519 (--dump-geocenter-pols) If given, print out the TD/FD h_plus and h_cross polarisations\n\
520 (--trigtime GPStime) GPS time of the trigger to analyse\n\
521 (optional when using --margtime or --margtimephi)\n\
522 (--segment-start) GPS time of the start of the segment\n\
523 (optional with --trigtime,\n\
524 default: seglen-2 s before --trigtime)\n\
525 (--srate rate) Downsample data to rate in Hz (4096.0,)\n\
526 (--padding PAD [sec] Override default 0.4 seconds padding\n\
527 (--injectionsrate rate) Downsample injection signal to rate in Hz (--srate)\n\
528 (--IFO1-flow freq1 Specify lower frequency cutoff for overlap integral (20.0)\n\
529 [--IFO2-flow freq2 ...])\n\
530 (--IFO1-fhigh freq1 Specify higher frequency cutoff for overlap integral (Nyquist\n\
531 [--IFO2-fhigh freq2 ...]) freq 0.5*srate)\n\
532 (--IFO1-channel chan1 Specify channel names when reading cache files\n\
533 [--IFO2-channel chan2 ...])\n\
534 (--IFO1-asd asd1-ascii.txt Read in ASD from ascii file. This is not equivalent \n\
535 [--IFO2-asd asd2-ascii.txt ...]) to using --IFO1-cache interp:asd_file.txt since the former\n\
536 won't use the ascii ASD to generate fake noise. \n\
537 (--IFO1-psd psd1-ascii.txt Read in PSD from ascii file. This is not equivalent \n\
538 [--IFO2-psd psd2-ascii.txt ...]) to using --IFO1-cache interp:asd_file.txt since the former\n\
539 won't use the ascii PSD to generate fake noise. \n\
540 (--dataseed number) Specify random seed to use when generating data\n\
541 (--lalinspiralinjection) Enables injections via the LALInspiral package\n\
542 (--inj-fref) Reference frequency of parameters in injection XML (default 100Hz)\n\
543 (--inj-lambda1) value of lambda1 to be injected, LALSimulation only (0)\n\
544 (--inj-lambda2) value of lambda2 to be injected, LALSimulation only (0)\n\
545 (--inj-lambdaT value of lambdaT to be injected (0)\n\
546 (--inj-dlambdaT value of dlambdaT to be injected (0)\n\
547 (--inj-logp1) value of logp1 to be injected\n\
548 (--inj-gamma1) value of gamma1 to be injected\n\
549 (--inj-gamma2) value of gamma2 to be injected\n\
550 (--inj-gamma3) value of gamma3 to be injected\n\
551 (--inj-SDgamma0) value of SDgamma0 to be injected (0)\n\
552 (--inj-SDgamma1) value of SDgamma1 to be injected (0)\n\
553 (--inj-SDgamma2) value of SDgamma2 to be injected (0)\n\
554 (--inj-SDgamma3) value of SDgamma3 to be injected (0)\n\
555 (--inj-spinOrder PNorder) Specify twice the injection PN order (e.g. 5 <==> 2.5PN)\n\
556 of spin effects effects to use, only for LALSimulation\n\
557 (default: -1 <==> Use all spin effects).\n\
558 (--inj-tidalOrder PNorder) Specify twice the injection PN order (e.g. 10 <==> 5PN)\n\
559 of tidal effects to use, only for LALSimulation\n\
560 (default: -1 <==> Use all tidal effects).\n\
561 (--inj-spin-frame FRAME Specify injection spin frame: choice of total-j, orbital-l, view.\n\
562 (Default = OrbitalL).\n\
563 (--inj-numreldata FileName) Location of NR data file for the injection of NR waveforms (with NR_hdf5 in injection XML file).\n\
564 (--0noise) Sets the noise realisation to be identically zero\n\
565 (for the fake caches above only)\n\
566 \n"
567
569/* Read in the data and store it in a LALInferenceIFOData structure */
570{
572 INT4 dataseed=0;
573 memset(&status,0,sizeof(status));
574 ProcessParamsTable *procparam=NULL,*ppt=NULL;
575 //ProcessParamsTable *pptdatadump=NULL;
576 LALInferenceIFOData *headIFO=NULL,*IFOdata=NULL;
577 REAL8 SampleRate=4096.0,SegmentLength=0;
578 if(LALInferenceGetProcParamVal(commandLine,"--srate")) SampleRate=atof(LALInferenceGetProcParamVal(commandLine,"--srate")->value);
579 REAL8 defaultFLow = atof(LALINFERENCE_DEFAULT_FLOW);
580 int nSegs=0;
581 size_t seglen=0;
582 REAL8TimeSeries *PSDtimeSeries=NULL;
583 REAL8 padding=0.4;//Default was 1.0 second. However for The Event the Common Inputs specify a Tukey parameter of 0.1, so 0.4 second of padding for 8 seconds of data.
584 UINT4 Ncache=0,Nifo=0,Nchannel=0,NfLow=0,NfHigh=0;
585 UINT4 i,j;
586 //int FakeFlag=0; - set but not used
587 char strainname[]="LSC-STRAIN";
588 //typedef void (NoiseFunc)(LALStatus *statusPtr,REAL8 *psd,REAL8 f);
589 NoiseFunc *PSD=NULL;
590 REAL8 scalefactor=1;
591 RandomParams *datarandparam;
592 int globFrames=0; // 0 = no, 1 = will search for frames in PWD
593 char **channels=NULL;
594 char **caches=NULL;
595 char **asds=NULL;
596 char **psds=NULL;
597 char **IFOnames=NULL;
598 char **fLows=NULL,**fHighs=NULL;
599 char **timeslides=NULL;
600 UINT4 Ntimeslides=0;
601 LIGOTimeGPS GPSstart,GPStrig,segStart;
602 REAL8 PSDdatalength=0;
603 REAL8 AIGOang=0.0; //orientation angle for the proposed Australian detector.
604 procparam=LALInferenceGetProcParamVal(commandLine,"--aigoang");
605 if(!procparam) procparam=LALInferenceGetProcParamVal(commandLine,"--AIGOang");
606 if(procparam)
607 AIGOang=atof(procparam->value)*LAL_PI/180.0;
608
609 struct fvec *interp;
610 int interpFlag=0;
611 REAL8 asdFlag=0;
612
613 if(LALInferenceGetProcParamVal(commandLine,"--glob-frame-data")) globFrames=1;
614
615 /* Check if the new style command line arguments are used */
616 INT4 dataOpts=getDataOptionsByDetectors(commandLine, &IFOnames, &caches, &channels, &fLows, &fHighs, &timeslides, &asds, &psds, &Nifo);
617 /* Check for options if not given in the new style */
618 if(!dataOpts){
619 if(!(globFrames||LALInferenceGetProcParamVal(commandLine,"--cache"))||!(LALInferenceGetProcParamVal(commandLine,"--IFO")||LALInferenceGetProcParamVal(commandLine,"--ifo")))
620 {fprintf(stderr,USAGE); return(NULL);}
621 if(LALInferenceGetProcParamVal(commandLine,"--channel")){
622 LALInferenceParseCharacterOptionString(LALInferenceGetProcParamVal(commandLine,"--channel")->value,&channels,&Nchannel);
623 }
624 LALInferenceParseCharacterOptionString(LALInferenceGetProcParamVal(commandLine,"--cache")->value,&caches,&Ncache);
625 ppt=LALInferenceGetProcParamVal(commandLine,"--ifo");
627
628 ppt=LALInferenceGetProcParamVal(commandLine,"--flow");
629 if(!ppt) ppt=LALInferenceGetProcParamVal(commandLine,"--fLow");
630 if(ppt){
632 }
633 ppt=LALInferenceGetProcParamVal(commandLine,"--fhigh");
634 if(!ppt) ppt=LALInferenceGetProcParamVal(commandLine,"--fHigh");
635 if(ppt){
637 }
638
639 if((ppt=LALInferenceGetProcParamVal(commandLine,"--timeslide"))) LALInferenceParseCharacterOptionString(ppt->value,&timeslides,&Ntimeslides);
640 if(Nifo!=Ncache) {fprintf(stderr,"ERROR: Must specify equal number of IFOs and Cache files\n"); abort();}
641 if(Nchannel!=0 && Nchannel!=Nifo) {fprintf(stderr,"ERROR: Please specify a channel for all caches, or omit to use the defaults\n"); abort();}
642 }
643 else
644 {
645 NfHigh=Ntimeslides=Ncache=Nchannel=NfLow=Nifo;
646
647 }
648 /* Check for remaining required options */
649 if(!LALInferenceGetProcParamVal(commandLine,"--seglen"))
650 {fprintf(stderr,USAGE); return(NULL);}
651
652 if(LALInferenceGetProcParamVal(commandLine,"--dataseed")){
653 procparam=LALInferenceGetProcParamVal(commandLine,"--dataseed");
654 dataseed=atoi(procparam->value);
655 }
656
657 IFOdata=headIFO=XLALCalloc(sizeof(LALInferenceIFOData),Nifo);
658 if(!IFOdata) XLAL_ERROR_NULL(XLAL_ENOMEM);
659
660 procparam=LALInferenceGetProcParamVal(commandLine,"--psdstart");
661 if (procparam) {
662 XLALStrToGPS(&GPSstart,procparam->value,NULL);
663 if(status.statusCode) REPORTSTATUS(&status);
664 } else
665 XLALINT8NSToGPS(&GPSstart, 0);
666
667 /*Set trigtime in GPStrig using either inj file or --trigtime*/
668 LALInferenceSetGPSTrigtime(&GPStrig,commandLine);
669
670 if(status.statusCode) REPORTSTATUS(&status);
671
672 SegmentLength=atof(LALInferenceGetProcParamVal(commandLine,"--seglen")->value);
673 seglen=(size_t)(SegmentLength*SampleRate);
674
675 ppt=LALInferenceGetProcParamVal(commandLine,"--psdlength");
676 if(ppt) {
677 PSDdatalength=atof(ppt->value);
678 nSegs=(int)floor(PSDdatalength/SegmentLength);
679 }
680
681 CHAR df_argument_name[262];
682 REAL8 dof;
683
684 for(i=0;i<Nifo;i++) {
685 IFOdata[i].fLow=fLows?atof(fLows[i]):defaultFLow;
686 if(fHighs) IFOdata[i].fHigh=fHighs[i]?atof(fHighs[i]):(SampleRate/2.0-(1.0/SegmentLength));
687 else IFOdata[i].fHigh=(SampleRate/2.0-(1.0/SegmentLength));
688 strncpy(IFOdata[i].name, IFOnames[i], DETNAMELEN-1);
689 IFOdata[i].name[DETNAMELEN-1] = 0;
690
691 dof=4.0 / M_PI * nSegs; /* Degrees of freedom parameter */
692 sprintf(df_argument_name,"--dof-%s",IFOdata[i].name);
693 if((ppt=LALInferenceGetProcParamVal(commandLine,df_argument_name)))
694 dof=atof(ppt->value);
695
696 IFOdata[i].STDOF = dof;
697 XLALPrintInfo("Detector %s will run with %g DOF if Student's T likelihood used.\n",
698 IFOdata[i].name, IFOdata[i].STDOF);
699 }
700
701 /* Only allocate this array if there weren't channels read in from the command line */
702 if(!dataOpts && !Nchannel) channels=XLALCalloc(Nifo,sizeof(char *));
703 for(i=0;i<Nifo;i++) {
704 if(!dataOpts && !Nchannel) channels[i]=XLALMalloc(VARNAME_MAX);
705 IFOdata[i].detector=XLALCalloc(1,sizeof(LALDetector));
706
707 if(!strcmp(IFOnames[i],"H1")) {
709 if(!Nchannel) sprintf((channels[i]),"H1:%s",strainname); continue;}
710 if(!strcmp(IFOnames[i],"H2")) {
712 if(!Nchannel) sprintf((channels[i]),"H2:%s",strainname); continue;}
713 if(!strcmp(IFOnames[i],"LLO")||!strcmp(IFOnames[i],"L1")) {
715 if(!Nchannel) sprintf((channels[i]),"L1:%s",strainname); continue;}
716 if(!strcmp(IFOnames[i],"V1")||!strcmp(IFOnames[i],"VIRGO")) {
718 if(!Nchannel) sprintf((channels[i]),"V1:h_16384Hz"); continue;}
719 if(!strcmp(IFOnames[i],"GEO")||!strcmp(IFOnames[i],"G1")) {
721 if(!Nchannel) sprintf((channels[i]),"G1:DER_DATA_H"); continue;}
722
723 if(!strcmp(IFOnames[i],"E1")){
725 if(!Nchannel) sprintf((channels[i]),"E1:STRAIN"); continue;}
726 if(!strcmp(IFOnames[i],"E2")){
728 if(!Nchannel) sprintf((channels[i]),"E2:STRAIN"); continue;}
729 if(!strcmp(IFOnames[i],"E3")){
731 if(!Nchannel) sprintf((channels[i]),"E3:STRAIN"); continue;}
732 if(!strcmp(IFOnames[i],"K1")){
734 if(!Nchannel) sprintf((channels[i]),"K1:STRAIN"); continue;}
735 if(!strcmp(IFOnames[i],"I1")){
737 if(!Nchannel) sprintf((channels[i]),"I1:STRAIN"); continue;}
738 if(!strcmp(IFOnames[i],"A1")||!strcmp(IFOnames[i],"LIGOSouth")){
739 /* Construct a detector at AIGO with 4k arms */
740 LALFrDetector LIGOSouthFr;
741 sprintf(LIGOSouthFr.name,"LIGO-South");
742 sprintf(LIGOSouthFr.prefix,"A1");
743 /* Location of the AIGO detector vertex is */
744 /* 31d21'27.56" S, 115d42'50.34"E */
745 LIGOSouthFr.vertexLatitudeRadians = - (31. + 21./60. + 27.56/3600.)*LAL_PI/180.0;
746 LIGOSouthFr.vertexLongitudeRadians = (115. + 42./60. + 50.34/3600.)*LAL_PI/180.0;
747 LIGOSouthFr.vertexElevation=0.0;
748 LIGOSouthFr.xArmAltitudeRadians=0.0;
749 LIGOSouthFr.xArmAzimuthRadians=AIGOang+LAL_PI/2.;
750 LIGOSouthFr.yArmAltitudeRadians=0.0;
751 LIGOSouthFr.yArmAzimuthRadians=AIGOang;
752 LIGOSouthFr.xArmMidpoint=2000.;
753 LIGOSouthFr.yArmMidpoint=2000.;
754 IFOdata[i].detector=XLALMalloc(sizeof(LALDetector));
755 memset(IFOdata[i].detector,0,sizeof(LALDetector));
757 printf("Created LIGO South detector, location: %lf, %lf, %lf\n",IFOdata[i].detector->location[0],IFOdata[i].detector->location[1],IFOdata[i].detector->location[2]);
758 printf("Detector tensor:\n");
759 for(int jdx=0;jdx<3;jdx++){
760 for(j=0;j<3;j++) printf("%f ",IFOdata[i].detector->response[jdx][j]);
761 printf("\n");
762 }
763 continue;
764 }
765 fprintf(stderr,"Unknown interferometer %s. Valid codes: H1 H2 L1 V1 GEO A1 K1 I1 E1 E2 E3 HM1 HM2 EM1 EM2\n",IFOnames[i]); abort();
766 }
767
768 /* Set up FFT structures and window */
769 for (i=0;i<Nifo;i++){
770 /* Create FFT plans (flag 1 to measure performance) */
771 IFOdata[i].timeToFreqFFTPlan = XLALCreateForwardREAL8FFTPlan((UINT4) seglen, 1 );
772 if(!IFOdata[i].timeToFreqFFTPlan) XLAL_ERROR_NULL(XLAL_ENOMEM);
773 IFOdata[i].freqToTimeFFTPlan = XLALCreateReverseREAL8FFTPlan((UINT4) seglen, 1 );
774 if(!IFOdata[i].freqToTimeFFTPlan) XLAL_ERROR_NULL(XLAL_ENOMEM);
775 IFOdata[i].margFFTPlan = XLALCreateReverseREAL8FFTPlan((UINT4) seglen, 1);
776 if(!IFOdata[i].margFFTPlan) XLAL_ERROR_NULL(XLAL_ENOMEM);
777 /* Setup windows */
778 ppt=LALInferenceGetProcParamVal(commandLine,"--padding");
779 if (ppt){
780 padding=atof(ppt->value);
781 fprintf(stdout,"Using %lf seconds of padding for IFO %s \n",padding, IFOdata[i].name);
782 }
783 if ((REAL8)2.0*padding*SampleRate/(REAL8)seglen <0.0 ||(REAL8)2.0*padding*SampleRate/(REAL8)seglen >1 ){
784 fprintf(stderr,"Padding is negative or 2*padding is bigger than the whole segment. Consider reducing it using --padding or increase --seglen. Exiting\n");
785 abort();
786 }
787 IFOdata[i].padding=padding;
788 IFOdata[i].window=XLALCreateTukeyREAL8Window(seglen,(REAL8)2.0*padding*SampleRate/(REAL8)seglen);
789 if(!IFOdata[i].window) XLAL_ERROR_NULL(XLAL_EFUNC);
790 }
791
792 if(!(ppt=LALInferenceGetProcParamVal(commandLine,"--segment-start")))
793 {
794 /* Trigger time = 2 seconds before end of segment (was 1 second, but Common Inputs for The Events are -6 +2*/
795 memcpy(&segStart,&GPStrig,sizeof(LIGOTimeGPS));
796 REAL8 offset=SegmentLength-2.;
797 /* If we are using a burst approximant, put at the center */
798 if ((ppt=LALInferenceGetProcParamVal(commandLine,"--approx"))){
799 if (XLALCheckBurstApproximantFromString(ppt->value)) offset=SegmentLength/2.;
800 }
801 XLALGPSAdd(&segStart,-offset);
802 }
803 else
804 {
805 /* Segment starts at given time */
806 REAL8 segstartR8 = atof(ppt->value);
807 XLALGPSSetREAL8(&segStart,segstartR8);
808 }
809
810
811 /* Read the PSD data */
812 for(i=0;i<Nifo;i++) {
813 memcpy(&(IFOdata[i].epoch),&segStart,sizeof(LIGOTimeGPS));
814 /* Check to see if an interpolation file is specified */
815 interpFlag=0;
816 interp=NULL;
817 if( (globFrames)?0:strstr(caches[i],"interp:")==caches[i]){
818 /* Extract the file name */
819 char *interpfilename=&(caches[i][7]);
820 printf("Looking for ASD interpolation file %s\n",interpfilename);
821 interpFlag=1;
822 asdFlag=1;
823 interp=interpFromFile(interpfilename, asdFlag);
824 }
825 /* Check if fake data is requested */
826 if( (globFrames)?0:(interpFlag || (!(strcmp(caches[i],"LALLIGO") && strcmp(caches[i],"LALVirgo") && strcmp(caches[i],"LALGEO") && strcmp(caches[i],"LALEGO") && strcmp(caches[i],"LALSimLIGO") && strcmp(caches[i],"LALSimAdLIGO") && strcmp(caches[i],"LALSimVirgo") && strcmp(caches[i],"LALSimAdVirgo") && strcmp(caches[i],"LALAdLIGO")))))
827 {
828 if (!LALInferenceGetProcParamVal(commandLine,"--dataseed")){
829 fprintf(stderr,"Error: You need to specify a dataseed when generating data with --dataseed <number>.\n\
830 (--dataseed 0 uses a non-reproducible number from the system clock, and no parallel run is then possible.)\n" );
831 abort();
832 }
833 /* Offset the seed in a way that depends uniquely on the IFO name */
834 int ifo_salt=0;
835 ifo_salt+=(int)IFOnames[i][0]+(int)IFOnames[i][1];
836 datarandparam=XLALCreateRandomParams(dataseed?dataseed+(int)ifo_salt:dataseed);
837 if(!datarandparam) XLAL_ERROR_NULL(XLAL_EFUNC);
838 IFOdata[i].oneSidedNoisePowerSpectrum=(REAL8FrequencySeries *)
839 XLALCreateREAL8FrequencySeries("spectrum",&GPSstart,0.0,
840 (REAL8)(SampleRate)/seglen,&lalDimensionlessUnit,seglen/2 +1);
841 if(!IFOdata[i].oneSidedNoisePowerSpectrum) XLAL_ERROR_NULL(XLAL_EFUNC);
842
843 int LALSimPsd=0;
844 /* Selection of the noise curve */
845 if(!strcmp(caches[i],"LALLIGO")) {PSD = &LALLIGOIPsd; scalefactor=9E-46;}
846 if(!strcmp(caches[i],"LALVirgo")) {PSD = &LALVIRGOPsd; scalefactor=1.0;}
847 if(!strcmp(caches[i],"LALGEO")) {PSD = &LALGEOPsd; scalefactor=1E-46;}
848 if(!strcmp(caches[i],"LALEGO")) {PSD = &LALEGOPsd; scalefactor=1.0;}
849 if(!strcmp(caches[i],"LALAdLIGO")) {PSD = &LALAdvLIGOPsd; scalefactor = 1E-49;}
850 if(!strcmp(caches[i],"LALSimLIGO")) {XLALSimNoisePSD(IFOdata[i].oneSidedNoisePowerSpectrum,IFOdata[i].fLow,XLALSimNoisePSDiLIGOSRD ) ; LALSimPsd=1;}
851 if(!strcmp(caches[i],"LALSimVirgo")) {XLALSimNoisePSD(IFOdata[i].oneSidedNoisePowerSpectrum,IFOdata[i].fLow,XLALSimNoisePSDVirgo ); LALSimPsd=1;}
852 if(!strcmp(caches[i],"LALSimAdLIGO")) {XLALSimNoisePSDaLIGODesignSensitivityT1800044(IFOdata[i].oneSidedNoisePowerSpectrum,IFOdata[i].fLow) ;LALSimPsd=1;}
853 if(!strcmp(caches[i],"LALSimAdVirgo")) {XLALSimNoisePSD(IFOdata[i].oneSidedNoisePowerSpectrum,IFOdata[i].fLow,XLALSimNoisePSDAdvVirgo) ;LALSimPsd=1;}
854 if(interpFlag) {PSD=NULL; scalefactor=1.0;}
855 if(PSD==NULL && !(interpFlag|| LALSimPsd)) {fprintf(stderr,"Error: unknown simulated PSD: %s\n",caches[i]); abort();}
856
857 if(LALSimPsd==0){
858 for(j=0;j<IFOdata[i].oneSidedNoisePowerSpectrum->data->length;j++)
859 {
860 MetaNoiseFunc(&status,&(IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]),j*IFOdata[i].oneSidedNoisePowerSpectrum->deltaF,interp,PSD);
861 IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]*=scalefactor;
862 }
863 }
864
865 IFOdata[i].freqData = (COMPLEX16FrequencySeries *)XLALCreateCOMPLEX16FrequencySeries("stilde",&segStart,0.0,IFOdata[i].oneSidedNoisePowerSpectrum->deltaF,&lalDimensionlessUnit,seglen/2 +1);
866 if(!IFOdata[i].freqData) XLAL_ERROR_NULL(XLAL_EFUNC);
867
868 /* Create the fake data */
869 int j_Lo = (int) IFOdata[i].fLow/IFOdata[i].freqData->deltaF;
870 if(LALInferenceGetProcParamVal(commandLine,"--0noise")){
871 for(j=j_Lo;j<IFOdata[i].freqData->data->length;j++){
872 IFOdata[i].freqData->data->data[j] = 0.0;
873 }
874 } else {
875 for(j=j_Lo;j<IFOdata[i].freqData->data->length;j++){
876 IFOdata[i].freqData->data->data[j] = crect(
877 XLALNormalDeviate(datarandparam)*(0.5*sqrt(IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]/IFOdata[i].freqData->deltaF)),
878 XLALNormalDeviate(datarandparam)*(0.5*sqrt(IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]/IFOdata[i].freqData->deltaF))
879 );
880 }
881 }
882 IFOdata[i].freqData->data->data[0] = 0;
883 const char timename[]="timeData";
884 IFOdata[i].timeData=(REAL8TimeSeries *)XLALCreateREAL8TimeSeries(timename,&segStart,0.0,(REAL8)1.0/SampleRate,&lalDimensionlessUnit,(size_t)seglen);
885 if(!IFOdata[i].timeData) XLAL_ERROR_NULL(XLAL_EFUNC);
886 XLALREAL8FreqTimeFFT(IFOdata[i].timeData,IFOdata[i].freqData,IFOdata[i].freqToTimeFFTPlan);
887 if(*XLALGetErrnoPtr()) printf("XLErr: %s\n",XLALErrorString(*XLALGetErrnoPtr()));
888 XLALDestroyRandomParams(datarandparam);
889 }
890 else{ /* Not using fake data, load the data from a cache file */
891
892 LALCache *cache=NULL;
893 if(!globFrames)
894 {
895 cache = XLALCacheImport( caches[i] );
896 int err;
897 err = *XLALGetErrnoPtr();
898 if(cache==NULL) {fprintf(stderr,"ERROR: Unable to import cache file \"%s\",\n XLALError: \"%s\".\n",caches[i], XLALErrorString(err)); abort();}
899 }
900 else
901 {
902 printf("Looking for frames for %s in PWD\n",IFOnames[i]);
903 cache= GlobFramesPWD(IFOnames[i]);
904
905 }
906 if(!cache) {fprintf(stderr,"ERROR: Cannot find any frame data!\n"); abort();}
907 if ((!((psds[i])==NULL)) && (!((asds[i])==NULL))) {fprintf(stderr,"ERROR: Cannot provide both ASD and PSD file from command line!\n"); abort();}
908 if (!((asds)==NULL || (asds[i])==NULL)){
909 interp=NULL;
910 asdFlag=1;
911 char *interpfilename=&(asds[i][0]);
912 fprintf(stderr,"Reading ASD for %s using %s\n",IFOnames[i],interpfilename);
913 printf("Looking for ASD file %s for PSD interpolation\n",interpfilename);
914 interp=interpFromFile(interpfilename, asdFlag);
915 IFOdata[i].oneSidedNoisePowerSpectrum=(REAL8FrequencySeries *)
916 XLALCreateREAL8FrequencySeries("spectrum",&GPSstart,0.0,
917 (REAL8)(SampleRate)/seglen,&lalDimensionlessUnit,seglen/2 +1);
918 if(!IFOdata[i].oneSidedNoisePowerSpectrum) XLAL_ERROR_NULL(XLAL_EFUNC);
919 for(j=0;j<IFOdata[i].oneSidedNoisePowerSpectrum->data->length;j++)
920 {
921 MetaNoiseFunc(&status,&(IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]),j*IFOdata[i].oneSidedNoisePowerSpectrum->deltaF,interp,NULL);
922 //fprintf(stdout,"%lf\n",IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]);
923 }
924 }else if(!((psds)==NULL || (psds[i])==NULL)){
925 interp=NULL;
926 asdFlag=0;
927 char *interpfilename=&(psds[i][0]);
928 fprintf(stderr,"Reading PSD for %s using %s\n",IFOnames[i],interpfilename);
929 printf("Looking for PSD file %s for PSD interpolation\n",interpfilename);
930 interp=interpFromFile(interpfilename, asdFlag);
931 IFOdata[i].oneSidedNoisePowerSpectrum=(REAL8FrequencySeries *)
932 XLALCreateREAL8FrequencySeries("spectrum",&GPSstart,0.0,
933 (REAL8)(SampleRate)/seglen,&lalDimensionlessUnit,seglen/2 +1);
934 if(!IFOdata[i].oneSidedNoisePowerSpectrum) XLAL_ERROR_NULL(XLAL_EFUNC);
935 for(j=0;j<IFOdata[i].oneSidedNoisePowerSpectrum->data->length;j++)
936 {
937 MetaNoiseFunc(&status,&(IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]),j*IFOdata[i].oneSidedNoisePowerSpectrum->deltaF,interp,NULL);
938 //fprintf(stdout,"%lf\n",IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]);
939 }
940 }else{
941 /* Make sure required PSD arguments were provided */
942 if(!LALInferenceGetProcParamVal(commandLine,"--psdstart") ||
943 !LALInferenceGetProcParamVal(commandLine,"--psdlength"))
944 {fprintf(stderr,USAGE); return(NULL);}
945
946 fprintf(stderr,"Estimating PSD for %s using %i segments of %i samples (%lfs)\n",IFOnames[i],nSegs,(int)seglen,SegmentLength);
947 LIGOTimeGPS trueGPSstart=GPSstart;
948 if(Ntimeslides) {
949 REAL4 deltaT=-atof(timeslides[i]);
950 XLALGPSAdd(&GPSstart, deltaT);
951 fprintf(stderr,"Slid PSD estimation of %s by %f s from %10.10lf to %10.10lf\n",IFOnames[i],deltaT,trueGPSstart.gpsSeconds+1e-9*trueGPSstart.gpsNanoSeconds,GPSstart.gpsSeconds+1e-9*GPSstart.gpsNanoSeconds);
952 }
953 PSDtimeSeries=readTseries(cache,channels[i],GPSstart,PSDdatalength);
954 GPSstart=trueGPSstart;
955 if(!PSDtimeSeries) {XLALPrintError("Error reading PSD data for %s\n",IFOnames[i]); abort();}
956 XLALResampleREAL8TimeSeries(PSDtimeSeries,1.0/SampleRate);
957 PSDtimeSeries=(REAL8TimeSeries *)XLALShrinkREAL8TimeSeries(PSDtimeSeries,(size_t) 0, (size_t) seglen*nSegs);
958 if(!PSDtimeSeries) {
959 fprintf(stderr,"ERROR while estimating PSD for %s\n",IFOnames[i]);
961 }
962 IFOdata[i].oneSidedNoisePowerSpectrum=(REAL8FrequencySeries *)XLALCreateREAL8FrequencySeries("spectrum",&PSDtimeSeries->epoch,0.0,(REAL8)(SampleRate)/seglen,&lalDimensionlessUnit,seglen/2 +1);
963 if(!IFOdata[i].oneSidedNoisePowerSpectrum) XLAL_ERROR_NULL(XLAL_EFUNC);
964 if (LALInferenceGetProcParamVal(commandLine, "--PSDwelch"))
965 XLALREAL8AverageSpectrumWelch(IFOdata[i].oneSidedNoisePowerSpectrum ,PSDtimeSeries, seglen, (UINT4)seglen, IFOdata[i].window, IFOdata[i].timeToFreqFFTPlan);
966 else
967 XLALREAL8AverageSpectrumMedian(IFOdata[i].oneSidedNoisePowerSpectrum ,PSDtimeSeries, seglen, (UINT4)seglen, IFOdata[i].window, IFOdata[i].timeToFreqFFTPlan);
968
969 if(LALInferenceGetProcParamVal(commandLine, "--binFit")) {
970
971 LIGOTimeGPS GPStime=segStart;
972
973 const UINT4 nameLength=256;
974 char filename[nameLength];
975
976 snprintf(filename, nameLength, "%s-BinFitLines.dat", IFOdata[i].name);
977
978 printf("Running PSD bin fitting... ");
979 LALInferenceAverageSpectrumBinFit(IFOdata[i].oneSidedNoisePowerSpectrum ,PSDtimeSeries, seglen, (UINT4)seglen, IFOdata[i].window, IFOdata[i].timeToFreqFFTPlan,filename,GPStime);
980 printf("completed!\n");
981 }
982
983 if (LALInferenceGetProcParamVal(commandLine, "--chisquaredlines")){
984
985 double deltaF = IFOdata[i].oneSidedNoisePowerSpectrum->deltaF;
986 int lengthF = IFOdata[i].oneSidedNoisePowerSpectrum->data->length;
987
988 REAL8 *pvalues;
989 pvalues = XLALMalloc( lengthF * sizeof( *pvalues ) );
990
991 printf("Running chi-squared tests... ");
992 LALInferenceRemoveLinesChiSquared(IFOdata[i].oneSidedNoisePowerSpectrum,PSDtimeSeries, seglen, (UINT4)seglen, IFOdata[i].window, IFOdata[i].timeToFreqFFTPlan,pvalues);
993 printf("completed!\n");
994
995 const UINT4 nameLength=256;
996 char filename[nameLength];
997 FILE *out;
998
999 double lines_width;
1000 ppt = LALInferenceGetProcParamVal(commandLine, "--chisquaredlinesWidth");
1001 if(ppt) lines_width = atof(ppt->value);
1002 else lines_width = deltaF;
1003
1004 double lines_threshold;
1005 ppt = LALInferenceGetProcParamVal(commandLine, "--chisquaredlinesThreshold");
1006 if(ppt) lines_threshold = atof(ppt->value);
1007 else lines_threshold = 2*pow(10.0,-14.0);
1008
1009 printf("Using chi squared threshold of %g\n",lines_threshold);
1010
1011 snprintf(filename, nameLength, "%s-ChiSquaredLines.dat", IFOdata[i].name);
1012 out = fopen(filename, "w");
1013 for (int k = 0; k < lengthF; ++k ) {
1014 if (pvalues[k] < lines_threshold) {
1015 fprintf(out,"%g %g\n",((double) k) * deltaF,lines_width);
1016 }
1017 }
1018 fclose(out);
1019
1020 snprintf(filename, nameLength, "%s-ChiSquaredLines-pvalues.dat", IFOdata[i].name);
1021 out = fopen(filename, "w");
1022 for (int k = 0; k < lengthF; ++k ) {
1023 fprintf(out,"%g %g\n",((double) k) * deltaF,pvalues[k]);
1024 }
1025 fclose(out);
1026
1027 }
1028
1029 if (LALInferenceGetProcParamVal(commandLine, "--KSlines")){
1030
1031 double deltaF = IFOdata[i].oneSidedNoisePowerSpectrum->deltaF;
1032 int lengthF = IFOdata[i].oneSidedNoisePowerSpectrum->data->length;
1033
1034 REAL8 *pvalues;
1035 pvalues = XLALMalloc( lengthF * sizeof( *pvalues ) );
1036
1037 printf("Running KS tests... ");
1038 LALInferenceRemoveLinesKS(IFOdata[i].oneSidedNoisePowerSpectrum,PSDtimeSeries, seglen, (UINT4)seglen, IFOdata[i].window, IFOdata[i].timeToFreqFFTPlan,pvalues);
1039 printf("completed!\n");
1040
1041 const UINT4 nameLength=256;
1042 char filename[nameLength];
1043 FILE *out;
1044
1045 double lines_width;
1046 ppt = LALInferenceGetProcParamVal(commandLine, "--KSlinesWidth");
1047 if(ppt) lines_width = atof(ppt->value);
1048 else lines_width = deltaF;
1049
1050 double lines_threshold;
1051 ppt = LALInferenceGetProcParamVal(commandLine, "--KSlinesThreshold");
1052 if(ppt) lines_threshold = atof(ppt->value);
1053 else lines_threshold = 0.134558;
1054
1055 printf("Using KS threshold of %g\n",lines_threshold);
1056
1057 snprintf(filename, nameLength, "%s-KSLines.dat", IFOdata[i].name);
1058 out = fopen(filename, "w");
1059 for (int k = 0; k < lengthF; ++k ) {
1060 if (pvalues[k] < lines_threshold) {
1061 fprintf(out,"%g %g\n",((double) k) * deltaF,lines_width);
1062 }
1063 }
1064 fclose(out);
1065
1066 snprintf(filename, nameLength, "%s-KSLines-pvalues.dat", IFOdata[i].name);
1067 out = fopen(filename, "w");
1068 for (int k = 0; k < lengthF; ++k ) {
1069 fprintf(out,"%g %g\n",((double) k) * deltaF,pvalues[k]);
1070 }
1071 fclose(out);
1072
1073 }
1074
1075 if (LALInferenceGetProcParamVal(commandLine, "--powerlawlines")){
1076
1077 double deltaF = IFOdata[i].oneSidedNoisePowerSpectrum->deltaF;
1078 int lengthF = IFOdata[i].oneSidedNoisePowerSpectrum->data->length;
1079
1080 REAL8 *pvalues;
1081 pvalues = XLALMalloc( lengthF * sizeof( *pvalues ) );
1082
1083 printf("Running power law tests... ");
1084 LALInferenceRemoveLinesPowerLaw(IFOdata[i].oneSidedNoisePowerSpectrum,PSDtimeSeries, seglen, (UINT4)seglen, IFOdata[i].window, IFOdata[i].timeToFreqFFTPlan,pvalues);
1085 printf("completed!\n");
1086
1087 const UINT4 nameLength=256;
1088 char filename[nameLength];
1089 FILE *out;
1090
1091 double lines_width;
1092 ppt = LALInferenceGetProcParamVal(commandLine, "--powerlawlinesWidth");
1093 if(ppt) lines_width = atof(ppt->value);
1094 else lines_width = deltaF;
1095
1096 double lines_threshold;
1097 ppt = LALInferenceGetProcParamVal(commandLine, "--powerlawlinesThreshold");
1098 if(ppt) lines_threshold = atof(ppt->value);
1099 else lines_threshold = 0.7197370;
1100
1101 printf("Using power law threshold of %g\n",lines_threshold);
1102
1103 snprintf(filename, nameLength, "%s-PowerLawLines.dat", IFOdata[i].name);
1104 out = fopen(filename, "w");
1105 for (int k = 0; k < lengthF; ++k ) {
1106 if (pvalues[k] < lines_threshold) {
1107 fprintf(out,"%g %g\n",((double) k) * deltaF,lines_width);
1108 }
1109 }
1110 fclose(out);
1111
1112 snprintf(filename, nameLength, "%s-PowerLawLines-pvalues.dat", IFOdata[i].name);
1113 out = fopen(filename, "w");
1114 for (int k = 0; k < lengthF; ++k ) {
1115 fprintf(out,"%g %g\n",((double) k) * deltaF,pvalues[k]);
1116 }
1117 fclose(out);
1118
1119 }
1120
1121 if (LALInferenceGetProcParamVal(commandLine, "--xcorrbands")){
1122
1123 int lengthF = IFOdata[i].oneSidedNoisePowerSpectrum->data->length;
1124
1125 REAL8 *pvalues;
1126 pvalues = XLALMalloc( lengthF * sizeof( *pvalues ) );
1127
1128 const UINT4 nameLength=256;
1129 char filename[nameLength];
1130 FILE *out;
1131
1132 snprintf(filename, nameLength, "%s-XCorrVals.dat", IFOdata[i].name);
1133
1134 printf("Running xcorr tests... ");
1135 LALInferenceXCorrBands(IFOdata[i].oneSidedNoisePowerSpectrum,PSDtimeSeries, seglen, (UINT4)seglen, IFOdata[i].window, IFOdata[i].timeToFreqFFTPlan,pvalues,filename);
1136 printf("completed!\n");
1137
1138 snprintf(filename, nameLength, "%s-XCorrBands.dat", IFOdata[i].name);
1139 out = fopen(filename, "w");
1140 fprintf(out,"%g %g\n",10.0,75.0);
1141 fprintf(out,"%g %g\n",16.0,40.0);
1142 fprintf(out,"%g %g\n",40.0,330.0);
1143 fclose(out);
1144
1145 }
1146
1147 XLALDestroyREAL8TimeSeries(PSDtimeSeries);
1148 }
1149
1150 /* Read the data segment */
1151 LIGOTimeGPS truesegstart=segStart;
1152 if(Ntimeslides) {
1153 REAL4 deltaT=-atof(timeslides[i]);
1154 XLALGPSAdd(&segStart, deltaT);
1155 fprintf(stderr,"Slid %s by %f s from %10.10lf to %10.10lf\n",IFOnames[i],deltaT,truesegstart.gpsSeconds+1e-9*truesegstart.gpsNanoSeconds,segStart.gpsSeconds+1e-9*segStart.gpsNanoSeconds);
1156 }
1157 IFOdata[i].timeData=readTseries(cache,channels[i],segStart,SegmentLength);
1158 segStart=truesegstart;
1159 if(Ntimeslides) IFOdata[i].timeData->epoch=truesegstart;
1160
1161 if(!IFOdata[i].timeData) {
1162 XLALPrintError("Error reading segment data for %s at %i\n",IFOnames[i],segStart.gpsSeconds);
1164 }
1165 XLALResampleREAL8TimeSeries(IFOdata[i].timeData,1.0/SampleRate);
1166 if(!IFOdata[i].timeData) {XLALPrintError("Error reading segment data for %s\n",IFOnames[i]); XLAL_ERROR_NULL(XLAL_EFUNC);}
1167 IFOdata[i].freqData=(COMPLEX16FrequencySeries *)XLALCreateCOMPLEX16FrequencySeries("freqData",&(IFOdata[i].timeData->epoch),0.0,1.0/SegmentLength,&lalDimensionlessUnit,seglen/2+1);
1168 if(!IFOdata[i].freqData) XLAL_ERROR_NULL(XLAL_EFUNC);
1169 IFOdata[i].windowedTimeData=(REAL8TimeSeries *)XLALCreateREAL8TimeSeries("windowed time data",&(IFOdata[i].timeData->epoch),0.0,1.0/SampleRate,&lalDimensionlessUnit,seglen);
1170 if(!IFOdata[i].windowedTimeData) XLAL_ERROR_NULL(XLAL_EFUNC);
1171 XLALDDVectorMultiply(IFOdata[i].windowedTimeData->data,IFOdata[i].timeData->data,IFOdata[i].window->data);
1172 XLALREAL8TimeFreqFFT(IFOdata[i].freqData,IFOdata[i].windowedTimeData,IFOdata[i].timeToFreqFFTPlan);
1173
1174 for(j=0;j<IFOdata[i].freqData->data->length;j++){
1175 IFOdata[i].freqData->data->data[j] /= sqrt(IFOdata[i].window->sumofsquares / IFOdata[i].window->data->length);
1176 IFOdata[i].windowedTimeData->data->data[j] /= sqrt(IFOdata[i].window->sumofsquares / IFOdata[i].window->data->length);
1177 }
1178
1179 XLALDestroyCache(cache); // Clean up cache
1180 } /* End of data reading process */
1181
1182 makeWhiteData(&(IFOdata[i]));
1183
1184 /* Store ASD of noise spectrum to whiten glitch model */
1185 IFOdata[i].noiseASD=(REAL8FrequencySeries *)XLALCreateREAL8FrequencySeries("asd",&GPSstart,0.0,(REAL8)(SampleRate)/seglen,&lalDimensionlessUnit,seglen/2 +1);
1186 for(j=0;j<IFOdata[i].oneSidedNoisePowerSpectrum->data->length;j++)
1187 IFOdata[i].noiseASD->data->data[j]=sqrt(IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]);
1188 /* Save to file the PSDs so that they can be used in the PP pages */
1189 const UINT4 nameLength=FILENAME_MAX+100;
1190 char filename[nameLength];
1191 FILE *out;
1192 ppt=LALInferenceGetProcParamVal(commandLine,"--dont-dump-extras");
1193 if (!ppt){
1194 ppt=LALInferenceGetProcParamVal(commandLine,"--outfile");
1195 if(ppt) {
1196 snprintf(filename, nameLength, "%s%s-PSD.dat", ppt->value, IFOdata[i].name);
1197 }
1198 else
1199 snprintf(filename, nameLength, "%.3f_%s-PSD.dat",GPStrig.gpsSeconds+1e-9*GPStrig.gpsNanoSeconds, IFOdata[i].name);
1200
1201 out = fopen(filename, "w");
1202 if(!out){
1203 fprintf(stderr,"Unable to open the path %s for writing PSD files\n",filename);
1204 abort();
1205 }
1206 for (j = 0; j < IFOdata[i].oneSidedNoisePowerSpectrum->data->length; j++) {
1207 REAL8 f = IFOdata[i].oneSidedNoisePowerSpectrum->deltaF*j;
1208 REAL8 psd = IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j];
1209
1210 fprintf(out, "%10.10g %10.10g\n", f, psd);
1211 }
1212 fclose(out);
1213 }
1214 if (LALInferenceGetProcParamVal(commandLine, "--data-dump")) {
1215 //pptdatadump=LALInferenceGetProcParamVal(commandLine,"--data-dump");
1216
1217 ppt=LALInferenceGetProcParamVal(commandLine,"--outfile");
1218
1219 if(ppt) {
1220 snprintf(filename, nameLength, "%s%s-timeData.dat", ppt->value, IFOdata[i].name);
1221 }
1222 //else if(strcmp(pptdatadump->value,"")) {
1223 // snprintf(filename, nameLength, "%s/%s-timeData.dat", pptdatadump->value, IFOdata[i].name);
1224 //}
1225 else
1226 snprintf(filename, nameLength, "%.3f_%s-timeData.dat",GPStrig.gpsSeconds+1e-9*GPStrig.gpsNanoSeconds, IFOdata[i].name);
1227 out = fopen(filename, "w");
1228 if(!out){
1229 fprintf(stderr,"Unable to open the path %s for writing time data files\n",filename);
1230 abort();
1231 }
1232 for (j = 0; j < IFOdata[i].timeData->data->length; j++) {
1233 REAL8 t = XLALGPSGetREAL8(&(IFOdata[i].timeData->epoch)) +
1234 j * IFOdata[i].timeData->deltaT;
1235 REAL8 d = IFOdata[i].timeData->data->data[j];
1236
1237 fprintf(out, "%.6f %g\n", t, d);
1238 }
1239 fclose(out);
1240
1241 ppt=LALInferenceGetProcParamVal(commandLine,"--outfile");
1242 if(ppt) {
1243 snprintf(filename, nameLength, "%s%s-freqData.dat", ppt->value, IFOdata[i].name);
1244 }
1245 //else if(strcmp(pptdatadump->value,"")) {
1246 // snprintf(filename, nameLength, "%s/%s-freqData.dat", pptdatadump->value, IFOdata[i].name);
1247 //}
1248 else
1249 snprintf(filename, nameLength, "%.3f_%s-freqData.dat",GPStrig.gpsSeconds+1e-9*GPStrig.gpsNanoSeconds, IFOdata[i].name);
1250 out = fopen(filename, "w");
1251 if(!out){
1252 fprintf(stderr,"Unable to open the path %s for writing freq data files\n",filename);
1253 abort();
1254 }
1255 for (j = 0; j < IFOdata[i].freqData->data->length; j++) {
1256 REAL8 f = IFOdata[i].freqData->deltaF * j;
1257 REAL8 dre = creal(IFOdata[i].freqData->data->data[j]);
1258 REAL8 dim = cimag(IFOdata[i].freqData->data->data[j]);
1259
1260 fprintf(out, "%10.10g %10.10g %10.10g\n", f, dre, dim);
1261 }
1262 fclose(out);
1263
1264 ppt=LALInferenceGetProcParamVal(commandLine,"--outfile");
1265 if(ppt) {
1266 snprintf(filename, nameLength, "%s%s-ASD.dat", ppt->value, IFOdata[i].name);
1267 }
1268 else
1269 snprintf(filename, nameLength, "%.3f_%s-ASD.dat",GPStrig.gpsSeconds+1e-9*GPStrig.gpsNanoSeconds, IFOdata[i].name);
1270 out = fopen(filename, "w");
1271 if(!out){
1272 fprintf(stderr,"Unable to open the path %s for writing freq ASD files\n",filename);
1273 abort();
1274 }
1275 for (j = 0; j < IFOdata[i].oneSidedNoisePowerSpectrum->data->length; j++) {
1276 REAL8 f = IFOdata[i].oneSidedNoisePowerSpectrum->deltaF*j;
1277 REAL8 asd = sqrt(IFOdata[i].oneSidedNoisePowerSpectrum->data->data[j]);
1278
1279 fprintf(out, "%10.10g %10.10g\n", f, asd);
1280 }
1281 fclose(out);
1282
1283 }
1284 }
1285
1286 for (i=0;i<Nifo;i++) IFOdata[i].SNR=0.0; //SNR of the injection ONLY IF INJECTION. Set to 0.0 by default.
1287
1288 for (i=0;i<Nifo-1;i++) IFOdata[i].next=&(IFOdata[i+1]);
1289
1290 for(i=0;i<Nifo;i++) {
1291 if(channels) if(channels[i]) XLALFree(channels[i]);
1292 if(caches) if(caches[i]) XLALFree(caches[i]);
1293 if(IFOnames) if(IFOnames[i]) XLALFree(IFOnames[i]);
1294 if(fLows) if(fLows[i]) XLALFree(fLows[i]);
1295 if(fHighs) if(fHighs[i]) XLALFree(fHighs[i]);
1296 }
1297 if(channels) XLALFree(channels);
1298 if(caches) XLALFree(caches);
1299 if(IFOnames) XLALFree(IFOnames);
1300 if(fLows) XLALFree(fLows);
1301 if(fHighs) XLALFree(fHighs);
1302
1303 if (LALInferenceGetProcParamVal(commandLine, "--roqtime_steps")){
1304
1305 LALInferenceSetupROQdata(IFOdata, commandLine);
1306 fprintf(stderr, "done LALInferenceSetupROQdata\n");
1307
1308 }
1309
1310
1311 return headIFO;
1312}
1313
1314static void makeWhiteData(LALInferenceIFOData *IFOdata) {
1315 REAL8 deltaF = IFOdata->freqData->deltaF;
1316 REAL8 deltaT = IFOdata->timeData->deltaT;
1317
1318 IFOdata->whiteFreqData =
1319 XLALCreateCOMPLEX16FrequencySeries("whitened frequency data",
1320 &(IFOdata->freqData->epoch),
1321 0.0,
1322 deltaF,
1324 IFOdata->freqData->data->length);
1326 IFOdata->whiteTimeData =
1327 XLALCreateREAL8TimeSeries("whitened time data",
1328 &(IFOdata->timeData->epoch),
1329 0.0,
1330 deltaT,
1332 IFOdata->timeData->data->length);
1334
1335 REAL8 iLow = IFOdata->fLow / deltaF;
1336 REAL8 iHighDefaultCut = 0.95 * IFOdata->freqData->data->length;
1337 REAL8 iHighFromFHigh = IFOdata->fHigh / deltaF;
1338 REAL8 iHigh = (iHighDefaultCut < iHighFromFHigh ? iHighDefaultCut : iHighFromFHigh);
1339 REAL8 windowSquareSum = 0.0;
1340
1341 UINT4 i;
1342
1343 for (i = 0; i < IFOdata->freqData->data->length; i++) {
1344 IFOdata->whiteFreqData->data->data[i] = IFOdata->freqData->data->data[i] / IFOdata->oneSidedNoisePowerSpectrum->data->data[i];
1345
1346 if (i == 0) {
1347 /* Cut off the average trend in the data. */
1348 IFOdata->whiteFreqData->data->data[i] = 0.0;
1349 }
1350 if (i <= iLow) {
1351 /* Need to taper to implement the fLow cutoff. Tukey window
1352 that starts at zero, and reaches 100% at fLow. */
1353 REAL8 weight = 0.5*(1.0 + cos(M_PI*(i-iLow)/iLow)); /* Starts at -Pi, runs to zero at iLow. */
1354
1355 IFOdata->whiteFreqData->data->data[i] *= weight;
1356
1357 windowSquareSum += weight*weight;
1358 } else if (i >= iHigh) {
1359 /* Also taper at high freq end, Tukey window that starts at 100%
1360 at fHigh, then drops to zero at Nyquist. Except that we
1361 always taper at least 5% of the data at high freq to avoid a
1362 sharp edge in freq space there. */
1363 REAL8 NWind = IFOdata->whiteFreqData->data->length - iHigh;
1364 REAL8 weight = 0.5*(1.0 + cos(M_PI*(i-iHigh)/NWind)); /* Starts at 0, runs to Pi at i = length */
1365
1366 IFOdata->whiteFreqData->data->data[i] *= weight;
1367
1368 windowSquareSum += weight*weight;
1369 } else {
1370 windowSquareSum += 1.0;
1371 }
1372 }
1373
1374 REAL8 norm = sqrt(IFOdata->whiteFreqData->data->length / windowSquareSum);
1375 for (i = 0; i < IFOdata->whiteFreqData->data->length; i++) {
1376 IFOdata->whiteFreqData->data->data[i] *= norm;
1377 }
1378
1380}
1381
1383{
1385 memset(&status,0,sizeof(status));
1386 SimInspiralTable *injTable=NULL;
1387 SimInspiralTable *injEvent=NULL;
1388 UINT4 event=0;
1389 UINT4 i=0,j=0;
1390 REAL8 responseScale=1.0;
1391 LIGOTimeGPS injstart;
1392 REAL8 SNR=0,NetworkSNR=0;
1393 DetectorResponse det;
1394 memset(&injstart,0,sizeof(LIGOTimeGPS));
1395 COMPLEX16FrequencySeries *injF=NULL;
1396 FILE *rawWaveform=NULL;
1397 ProcessParamsTable *ppt=NULL;
1398 REAL8 bufferLength = 2048.0; /* Default length of buffer for injections (seconds) */
1399 UINT4 bufferN=0;
1400 LIGOTimeGPS bufferStart;
1401
1402 LALInferenceIFOData *thisData=IFOdata->next;
1403 REAL8 minFlow=IFOdata->fLow;
1404 REAL8 MindeltaT=IFOdata->timeData->deltaT;
1405 REAL8 InjSampleRate=1.0/MindeltaT;
1406 REAL4TimeSeries *injectionBuffer=NULL;
1407 REAL8 padding=0.4; //default, set in LALInferenceReadData()
1408 char SNRpath[FILENAME_MAX+50]="";
1409 int flipped_masses=0;
1410
1411 while(thisData){
1412 minFlow = minFlow>thisData->fLow ? thisData->fLow : minFlow;
1413 MindeltaT = MindeltaT>thisData->timeData->deltaT ? thisData->timeData->deltaT : MindeltaT;
1414 thisData = thisData->next;
1415 }
1416 thisData=IFOdata;
1417
1418 if(!LALInferenceGetProcParamVal(commandLine,"--inj")) {fprintf(stdout,"No injection file specified, not injecting\n"); return;}
1419 if(LALInferenceGetProcParamVal(commandLine,"--event")){
1420 event= atoi(LALInferenceGetProcParamVal(commandLine,"--event")->value);
1421 fprintf(stdout,"Injecting event %d\n",event);
1422 }
1423
1424 ppt = LALInferenceGetProcParamVal(commandLine,"--outfile");
1425 if (ppt)
1426 sprintf(SNRpath, "%s_snr.txt", ppt->value);
1427 else
1428 sprintf(SNRpath, "snr.txt");
1429
1430 injTable=XLALSimInspiralTableFromLIGOLw(LALInferenceGetProcParamVal(commandLine,"--inj")->value);
1431 if(!injTable){
1432 fprintf(stderr,"Error reading event %d from %s\n",event,LALInferenceGetProcParamVal(commandLine,"--inj")->value);
1433 abort();
1434 }
1435 while(i<event) {i++; injTable = injTable->next;} /* Select event */
1436 injEvent = injTable;
1437 injEvent->next = NULL;
1438 Approximant injapprox;
1439 injapprox = XLALGetApproximantFromString(injTable->waveform);
1440 if( (int) injapprox == XLAL_FAILURE)
1441 ABORTXLAL(&status);
1442 printf("Injecting approximant %i: %s\n", injapprox, injTable->waveform);
1444
1445 /* Check for frequency domain injection. All aproximants supported by XLALSimInspiralImplementedFDApproximants will work.
1446 * CAVEAT: FD spinning approximants will refer the spin to the lower frequency as given in the xml table. Templates instead will refer it to the lower cutoff of the likelihood integral. This means *different* values of spin will be recovered if one doesn't pay attention! */
1448 {
1449 InjectFD(IFOdata, injTable, commandLine);
1450 LALInferencePrintDataWithInjection(IFOdata,commandLine);
1451 return;
1452 }
1453 flipped_masses = enforce_m1_larger_m2(injEvent);
1454 /* Begin loop over interferometers */
1455 while(thisData){
1456 Approximant approximant; /* Get approximant value */
1458 if( (int) approximant == XLAL_FAILURE)
1459 ABORTXLAL(&status);
1460
1461 InjSampleRate=1.0/thisData->timeData->deltaT;
1462 if(LALInferenceGetProcParamVal(commandLine,"--injectionsrate")) InjSampleRate=atof(LALInferenceGetProcParamVal(commandLine,"--injectionsrate")->value);
1463 if(approximant == NumRelNinja2 && InjSampleRate != 16384) {
1464 fprintf(stderr, "WARNING: NINJA2 injections only work with 16384 Hz sampling rates. Generating injection in %s at this rate, then downsample to the run's sampling rate.\n", thisData->name);
1465 InjSampleRate = 16384;
1466 }
1467
1468 memset(&det,0,sizeof(det));
1469 det.site=thisData->detector;
1471 0.0,
1472 thisData->freqData->deltaF,
1474 thisData->freqData->data->length);
1475
1476 for(i=0;i<resp->data->length;i++) {resp->data->data[i] = 1.0;}
1477 /* Originally created for injecting into DARM-ERR, so transfer function was needed.
1478 But since we are injecting into h(t), the transfer function from h(t) to h(t) is 1.*/
1479
1480 /* We need a long buffer to inject into so that FindChirpInjectSignals() works properly
1481 for low mass systems. Use 100 seconds here */
1482 bufferN = (UINT4) (bufferLength*InjSampleRate);// /thisData->timeData->deltaT);
1483 memcpy(&bufferStart,&thisData->timeData->epoch,sizeof(LIGOTimeGPS));
1484 XLALGPSAdd(&bufferStart,(REAL8) thisData->timeData->data->length * thisData->timeData->deltaT);
1485 XLALGPSAdd(&bufferStart,-bufferLength);
1487 &bufferStart, 0.0, 1.0/InjSampleRate,//thisData->timeData->deltaT,
1488 &lalADCCountUnit, bufferN);
1490 &thisData->timeData->epoch,
1491 0.0,
1492 thisData->timeData->deltaT,
1493 //&lalDimensionlessUnit,
1495 thisData->timeData->data->length);
1496 if(!inj8Wave) XLAL_ERROR_VOID(XLAL_EFUNC);
1497 /* This marks the sample in which the real segment starts, within the buffer */
1498 for(i=0;i<injectionBuffer->data->length;i++) injectionBuffer->data->data[i]=0.0;
1499 for(i=0;i<inj8Wave->data->length;i++) inj8Wave->data->data[i]=0.0;
1500 INT4 realStartSample=(INT4)((thisData->timeData->epoch.gpsSeconds - injectionBuffer->epoch.gpsSeconds)/thisData->timeData->deltaT);
1501 realStartSample+=(INT4)((thisData->timeData->epoch.gpsNanoSeconds - injectionBuffer->epoch.gpsNanoSeconds)*1e-9/thisData->timeData->deltaT);
1502
1503 if(LALInferenceGetProcParamVal(commandLine,"--lalinspiralinjection")){
1504 if ( approximant == NumRelNinja2) {
1505 XLALSimInjectNinjaSignals(injectionBuffer, thisData->name, 1./responseScale, injEvent);
1506 } else {
1507 /* Use this custom version for extra sites - not currently maintained */
1508 /* Normal find chirp simulation cannot handle the extra sites */
1509 LALFindChirpInjectSignals (&status,injectionBuffer,injEvent,resp);
1510 }
1511 printf("Using LALInspiral for injection\n");
1512 XLALResampleREAL4TimeSeries(injectionBuffer,thisData->timeData->deltaT); //downsample to analysis sampling rate.
1513 if(status.statusCode) REPORTSTATUS(&status);
1515
1516 if ( approximant != NumRelNinja2 ) {
1517 /* Checking the lenght of the injection waveform with respect of thisData->timeData->data->length */
1519 PPNParamStruc ppnParams;
1520 memset( &waveform, 0, sizeof(CoherentGW) );
1521 memset( &ppnParams, 0, sizeof(PPNParamStruc) );
1522 ppnParams.deltaT = 1.0/InjSampleRate;//thisData->timeData->deltaT;
1523 ppnParams.lengthIn = 0;
1524 ppnParams.ppn = NULL;
1525 unsigned lengthTest = 0;
1526
1527 LALGenerateInspiral(&status, &waveform, injEvent, &ppnParams ); //Recompute the waveform just to get access to ppnParams.tc and waveform.h->data->length or waveform.phi->data->length
1528 if(status.statusCode) REPORTSTATUS(&status);
1529
1530 if(waveform.h){
1531 lengthTest = waveform.h->data->length*(thisData->timeData->deltaT*InjSampleRate);
1532 }
1533 if(waveform.phi){
1535 lengthTest = waveform.phi->data->length;
1536 }
1537
1538
1539 if(lengthTest>thisData->timeData->data->length-(UINT4)ceil((2.0*padding+2.0)/thisData->timeData->deltaT)){
1540 fprintf(stderr, "WARNING: waveform length = %u is longer than thisData->timeData->data->length = %d minus the window width = %d and the 2.0 seconds after tc (total of %d points available).\n", lengthTest, thisData->timeData->data->length, (INT4)ceil((2.0*padding)/thisData->timeData->deltaT) , thisData->timeData->data->length-(INT4)ceil((2.0*padding+2.0)/thisData->timeData->deltaT));
1541 fprintf(stderr, "The waveform injected is %f seconds long. Consider increasing the %f seconds segment length (--seglen) to be greater than %f. (in %s, line %d)\n",ppnParams.tc , thisData->timeData->data->length * thisData->timeData->deltaT, ppnParams.tc + 2.0*padding + 2.0, __FILE__, __LINE__);
1542 }
1543 if(ppnParams.tc>bufferLength){
1544 fprintf(stderr, "ERROR: The waveform injected is %f seconds long and the buffer for FindChirpInjectSignal is %f seconds long. The end of the waveform will be cut ! (in %s, line %d)\n",ppnParams.tc , bufferLength, __FILE__, __LINE__);
1545 abort();
1546 }
1547 }
1548
1549 /* Now we cut the injection buffer down to match the time domain wave size */
1550 injectionBuffer=(REAL4TimeSeries *)XLALCutREAL4TimeSeries(injectionBuffer,realStartSample,thisData->timeData->data->length);
1551 if (!injectionBuffer) XLAL_ERROR_VOID(XLAL_EFUNC);
1552 if(status.statusCode) REPORTSTATUS(&status);
1553 for(i=0;i<injectionBuffer->data->length;i++) inj8Wave->data->data[i]=(REAL8)injectionBuffer->data->data[i];
1554 }else{
1555 printf("Using LALSimulation for injection\n");
1556 REAL8TimeSeries *hplus=NULL; /**< +-polarization waveform */
1557 REAL8TimeSeries *hcross=NULL; /**< x-polarization waveform */
1558 REAL8TimeSeries *signalvecREAL8=NULL;
1559 LALPNOrder order; /* Order of the model */
1560 INT4 amporder=0; /* Amplitude order of the model */
1561
1562 order = XLALGetOrderFromString(injEvent->waveform);
1563 if ( (int) order == XLAL_FAILURE)
1564 ABORTXLAL(&status);
1565 amporder = injEvent->amp_order;
1566 //if(amporder<0) amporder=0;
1567 /* FIXME - tidal lambda's and interactionFlag are just set to command line values here.
1568 * They should be added to injEvent and set to appropriate values
1569 */
1570
1571 // Inject (lambda1,lambda2)
1572 REAL8 lambda1 = 0.;
1573 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambda1")) {
1574 lambda1= atof(LALInferenceGetProcParamVal(commandLine,"--inj-lambda1")->value);
1575 }
1576 REAL8 lambda2 = 0.;
1577 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambda2")) {
1578 lambda2= atof(LALInferenceGetProcParamVal(commandLine,"--inj-lambda2")->value);
1579 }
1580 if(flipped_masses)
1581 {
1582 /* Having previously flipped the masses so m1>m2, also flip lambdas */
1583 REAL8 lambda_tmp = lambda1;
1584 lambda1 = lambda2;
1585 lambda2 = lambda_tmp;
1586 fprintf(stdout,"Flipping lambdas since masses are flipped\n");
1587 }
1588 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambda1")) {
1589 fprintf(stdout,"Injection lambda1 set to %f\n",lambda1);
1590 }
1591 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambda2")) {
1592 fprintf(stdout,"Injection lambda1 set to %f\n",lambda1);
1593 }
1594
1595 /* Inject amplitude nonGR params
1596 Add inj-damp21 = *desired value* or inj-damp33 = *desired value* to the *.ini
1597 file in order to inject a signal with non-zero values for these parameters
1598 */
1599
1600 REAL8 damp21 = 0.;
1601 if(LALInferenceGetProcParamVal(commandLine,"--inj-damp21")){
1602 damp21 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-damp21")->value);
1603 fprintf(stdout,"Injection nonGR 21 amplitude set to %f\n",damp21);
1604 }
1605
1606 REAL8 damp33 = 0.;
1607 if(LALInferenceGetProcParamVal(commandLine,"--inj-damp33")){
1608 damp33 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-damp33")->value);
1609 fprintf(stdout,"Injection nonGR 33 amplitude set to %f\n",damp33);
1610 }
1611
1612 // Inject (lambdaT,dLambdaT)
1613 REAL8 lambdaT = 0.;
1614 REAL8 dLambdaT = 0.;
1615 REAL8 m1=injEvent->mass1;
1616 REAL8 m2=injEvent->mass2;
1617 REAL8 Mt=m1+m2;
1618 REAL8 eta=m1*m2/(Mt*Mt);
1619 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambdaT")&&LALInferenceGetProcParamVal(commandLine,"--inj-dLambdaT")) {
1620 lambdaT= atof(LALInferenceGetProcParamVal(commandLine,"--inj-lambdaT")->value);
1621 dLambdaT= atof(LALInferenceGetProcParamVal(commandLine,"--inj-dLambdaT")->value);
1623 fprintf(stdout,"Injection lambdaT set to %f\n",lambdaT);
1624 fprintf(stdout,"Injection dLambdaT set to %f\n",dLambdaT);
1625 fprintf(stdout,"lambda1 set to %f\n",lambda1);
1626 fprintf(stdout,"lambda2 set to %f\n",lambda2);
1627 }
1628
1629 // Inject 4-piece polytrope eos
1630 REAL8 logp1=0.0;
1631 REAL8 gamma1=0.0;
1632 REAL8 gamma2=0.0;
1633 REAL8 gamma3=0.0;
1634 if(LALInferenceGetProcParamVal(commandLine,"--inj-logp1")&&LALInferenceGetProcParamVal(commandLine,"--inj-gamma1")&&LALInferenceGetProcParamVal(commandLine,"--inj-gamma2")&&LALInferenceGetProcParamVal(commandLine,"--inj-gamma3")){
1635 logp1= atof(LALInferenceGetProcParamVal(commandLine,"--inj-logp1")->value);
1636 gamma1= atof(LALInferenceGetProcParamVal(commandLine,"--inj-gamma1")->value);
1637 gamma2= atof(LALInferenceGetProcParamVal(commandLine,"--inj-gamma2")->value);
1638 gamma3= atof(LALInferenceGetProcParamVal(commandLine,"--inj-gamma3")->value);
1639 // Find lambda1,2(m1,2|eos)
1640 LALInferenceLogp1GammasMasses2Lambdas(logp1, gamma1, gamma2, gamma3, m1, m2, &lambda1, &lambda2);
1641 fprintf(stdout,"Injection logp1 set to %f\n",logp1);
1642 fprintf(stdout,"Injection gamma1 set to %f\n",gamma1);
1643 fprintf(stdout,"Injection gamma2 set to %f\n",gamma2);
1644 fprintf(stdout,"Injection gamma3 set to %f\n",gamma3);
1645 fprintf(stdout,"lambda1 set to %f\n",lambda1);
1646 fprintf(stdout,"lambda2 set to %f\n",lambda2);
1647
1648 /*
1649 For when tagSimInspiralTable is updated
1650 to include EOS params
1651
1652 injEvent->logp1= logp1;
1653 injEvent->gamma1= gamma1;
1654 injEvent->gamma2= gamma2;
1655 injEvent->gamma3= gamma3;
1656 */
1657 }
1658
1659 // Inject 4-coef. spectral eos
1660 REAL8 SDgamma0=0.0;
1661 REAL8 SDgamma1=0.0;
1662 REAL8 SDgamma2=0.0;
1663 REAL8 SDgamma3=0.0;
1664 if(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma0") && LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma1") && LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma2") && LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma3")){
1665 SDgamma0= atof(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma0")->value);
1666 SDgamma1= atof(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma1")->value);
1667 SDgamma2= atof(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma2")->value);
1668 SDgamma3= atof(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma3")->value);
1669 REAL8 gamma[]={SDgamma0,SDgamma1,SDgamma2,SDgamma3};
1671 fprintf(stdout,"Injection SDgamma0 set to %lf\n",SDgamma0);
1672 fprintf(stdout,"Injection SDgamma1 set to %lf\n",SDgamma1);
1673 fprintf(stdout,"Injection SDgamma2 set to %lf\n",SDgamma2);
1674 fprintf(stdout,"Injection SDgamma3 set to %lf\n",SDgamma3);
1675 fprintf(stdout,"lambda1 set to %f\n",lambda1);
1676 fprintf(stdout,"lambda2 set to %f\n",lambda2);
1677 }
1678
1679
1680 REAL8 fref = 100.;
1681 if(LALInferenceGetProcParamVal(commandLine,"--inj-fref")) {
1682 fref = atoi(LALInferenceGetProcParamVal(commandLine,"--inj-fref")->value);
1683 }
1684
1685 LALDict *LALpars=XLALCreateDict();
1686
1687 /* Inject deviation from GR */
1688 /* Inspiral Coefficients */
1689 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchiMinus2")){
1690 REAL8 dchi_minus2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchiMinus2")->value);
1692
1693 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchiMinus1")){
1694 REAL8 dchi_minus1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchiMinus1")->value);
1696
1697 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi0")){
1698 REAL8 dchi0 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi0")->value);
1700 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi1")){
1701 REAL8 dchi1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi1")->value);
1703 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi2")){
1704 REAL8 dchi2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi2")->value);
1706 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi3")){
1707 REAL8 dchi3 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi3")->value);
1709 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi4")){
1710 REAL8 dchi4 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi4")->value);
1712 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi5")){
1713 REAL8 dchi5 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi5l")->value);
1715 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi5l")){
1716 REAL8 dchi5l = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi5l")->value);
1718 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi6")){
1719 REAL8 dchi6 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi6")->value);
1721 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi6l")){
1722 REAL8 dchi6l = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi6l")->value);
1724 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi7")){
1725 REAL8 dchi7 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi7")->value);
1727
1728 /* PhenomD Intermediate */
1729 if (LALInferenceGetProcParamVal(commandLine,"--inj-dbeta1")){
1730 REAL8 nongr_dbeta1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dbeta1")->value);
1731 XLALSimInspiralWaveformParamsInsertNonGRDBeta1(LALpars, nongr_dbeta1);}
1732 if (LALInferenceGetProcParamVal(commandLine,"--inj-dbeta2")){
1733 REAL8 nongr_dbeta2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dbeta2")->value);
1734 XLALSimInspiralWaveformParamsInsertNonGRDBeta2(LALpars, nongr_dbeta2);}
1735 if (LALInferenceGetProcParamVal(commandLine,"--inj-dbeta3")){
1736 REAL8 nongr_dbeta3 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dbeta3")->value);
1737 XLALSimInspiralWaveformParamsInsertNonGRDBeta3(LALpars, nongr_dbeta3);}
1738
1739 /* PhenomX Intermediate */
1740 if (LALInferenceGetProcParamVal(commandLine,"--inj-db1")){
1741 REAL8 nongr_db1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-db1")->value);
1743 if (LALInferenceGetProcParamVal(commandLine,"--inj-db2")){
1744 REAL8 nongr_db2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-db2")->value);
1746 if (LALInferenceGetProcParamVal(commandLine,"--inj-db3")){
1747 REAL8 nongr_db3 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-db3")->value);
1749 if (LALInferenceGetProcParamVal(commandLine,"--inj-db4")){
1750 REAL8 nongr_db4 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-db4")->value);
1752
1753 /* PhenomD Merger-Ringdown */
1754 if (LALInferenceGetProcParamVal(commandLine,"--inj-dalpha1")){
1755 REAL8 nongr_dalpha1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dalpha1")->value);
1756 XLALSimInspiralWaveformParamsInsertNonGRDAlpha1(LALpars, nongr_dalpha1);}
1757 if (LALInferenceGetProcParamVal(commandLine,"--inj-dalpha2")){
1758 REAL8 nongr_dalpha2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dalpha2")->value);
1759 XLALSimInspiralWaveformParamsInsertNonGRDAlpha2(LALpars, nongr_dalpha2);}
1760 if (LALInferenceGetProcParamVal(commandLine,"--inj-dalpha3")){
1761 REAL8 nongr_dalpha3 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dalpha3")->value);
1762 XLALSimInspiralWaveformParamsInsertNonGRDAlpha3(LALpars, nongr_dalpha3);}
1763
1764 /* PhenomX Merger-Ringdown */
1765 if (LALInferenceGetProcParamVal(commandLine,"--inj-dc1")){
1766 REAL8 nongr_dc1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dc1")->value);
1768 if (LALInferenceGetProcParamVal(commandLine,"--inj-dc2")){
1769 REAL8 nongr_dc2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dc2")->value);
1771 if (LALInferenceGetProcParamVal(commandLine,"--inj-dc4")){
1772 REAL8 nongr_dc4 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dc4")->value);
1774 if (LALInferenceGetProcParamVal(commandLine,"--inj-dcl")){
1775 REAL8 nongr_dcl = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dcl")->value);
1777
1778
1779 /* Set the spin-frame convention */
1780
1782 if(LALInferenceGetProcParamVal(commandLine,"--inj-spinOrder")) {
1783 spinO = atoi(LALInferenceGetProcParamVal(commandLine,"--inj-spinOrder")->value);
1785 }
1787 if(LALInferenceGetProcParamVal(commandLine,"--inj-tidalOrder")) {
1788 tideO = atoi(LALInferenceGetProcParamVal(commandLine,"--inj-tidalOrder")->value);
1790 }
1791
1793 if((ppt=LALInferenceGetProcParamVal(commandLine,"--inj-spin-frame"))) {
1795 }
1796 XLALSimInspiralWaveformParamsInsertFrameAxis(LALpars,(int) frameAxis);
1797
1798 if((ppt=LALInferenceGetProcParamVal(commandLine,"--inj-numreldata"))) {
1800 fprintf(stdout,"Injection will use %s.\n",ppt->value);
1801 }
1802 else if (strlen(injEvent->numrel_data) > 0) {
1804 }
1805
1806 /* Print a line with information about approximant, amporder, phaseorder, tide order and spin order */
1807 fprintf(stdout,"Injection will run using Approximant %i (%s), phase order %i, amp order %i, spin order %i, tidal order %i, in the time domain with a reference frequency of %f.\n",approximant,XLALSimInspiralGetStringFromApproximant(approximant),order,amporder,(int) spinO, (int) tideO, (float) fref);
1808
1809 /* ChooseWaveform starts the (2,2) mode of the waveform at the given minimum frequency. We want the highest order contribution to start at the f_lower of the injection file */
1811 printf("Injecting with f_min = %f.\n", f_min);
1812
1817
1818 /* Insert damp21 or damp33 values given in the *.ini file in LALpars dictionary
1819 to pass them to the waveform generator. The damp21 and damp33 values are printed
1820 in the *.out file just as a check */
1821
1824 fprintf(stdout,"Injected damp21 and damp33 are %f and %f\n",damp21,damp33);
1825
1826 XLALSimInspiralChooseTDWaveform(&hplus, &hcross, injEvent->mass1*LAL_MSUN_SI, injEvent->mass2*LAL_MSUN_SI,
1827 injEvent->spin1x, injEvent->spin1y, injEvent->spin1z,
1828 injEvent->spin2x, injEvent->spin2y, injEvent->spin2z,
1829 injEvent->distance*LAL_PC_SI * 1.0e6, injEvent->inclination,
1830 injEvent->coa_phase, 0., 0., 0.,
1831 1.0/InjSampleRate, f_min, fref,
1832 LALpars, approximant);
1833 XLALDestroyDict(LALpars);
1834
1835 if(!hplus || !hcross) {
1836 fprintf(stderr,"Error: XLALSimInspiralChooseWaveform() failed to produce waveform.\n");
1837 abort();
1838 }
1840 XLALResampleREAL8TimeSeries(hcross,thisData->timeData->deltaT);
1841 /* XLALSimInspiralChooseTDWaveform always ends the waveform at t=0 */
1842 /* So we can adjust the epoch so that the end time is as desired */
1843 XLALGPSAddGPS(&(hplus->epoch), &(injEvent->geocent_end_time));
1844 XLALGPSAddGPS(&(hcross->epoch), &(injEvent->geocent_end_time));
1845
1846 if((ppt=LALInferenceGetProcParamVal(commandLine,"--dump-geocenter-pols"))) {
1847
1848 fprintf(stdout,"Dump injected TimeDomain h_plus and h_cross at geocenter (for IFO %s)\n", thisData->name);
1849
1850 char filename[320];
1851 sprintf(filename,"%s_TD_geocenter_pols.dat",thisData->name);
1852
1853 FILE* file=fopen(filename, "w");
1854 if(!file){
1855 fprintf(stderr,"Unable to open the path %s for writing injected TimeDomain h_plus and h_cross at geocenter\n",filename);
1856 abort();
1857 }
1858
1859 for(j=0; j<hplus->data->length; j++){
1860 fprintf(file, "%.6f %g %g \n", XLALGPSGetREAL8(&hplus->epoch) + hplus->deltaT*j, hplus->data->data[j], hcross->data->data[j]);
1861 }
1862 fclose(file);
1863 }
1864
1865 signalvecREAL8=XLALSimDetectorStrainREAL8TimeSeries(hplus, hcross, injEvent->longitude, injEvent->latitude, injEvent->polarization, det.site);
1866 if (!signalvecREAL8) XLAL_ERROR_VOID(XLAL_EFUNC);
1867
1868 for(i=0;i<signalvecREAL8->data->length;i++){
1869 if(isnan(signalvecREAL8->data->data[i])) signalvecREAL8->data->data[i]=0.0;
1870 }
1871
1872 if(signalvecREAL8->data->length > thisData->timeData->data->length-(UINT4)ceil((2.0*padding+2.0)/thisData->timeData->deltaT)){
1873 fprintf(stderr, "WARNING: waveform length = %u is longer than thisData->timeData->data->length = %d minus the window width = %d and the 2.0 seconds after tc (total of %d points available).\n", signalvecREAL8->data->length, thisData->timeData->data->length, (INT4)ceil((2.0*padding)/thisData->timeData->deltaT) , thisData->timeData->data->length-(INT4)ceil((2.0*padding+2.0)/thisData->timeData->deltaT));
1874 fprintf(stderr, "The waveform injected is %f seconds long. Consider increasing the %f seconds segment length (--seglen) to be greater than %f. (in %s, line %d)\n",signalvecREAL8->data->length * thisData->timeData->deltaT , thisData->timeData->data->length * thisData->timeData->deltaT, signalvecREAL8->data->length * thisData->timeData->deltaT + 2.0*padding + 2.0, __FILE__, __LINE__);
1875 }
1876
1877 XLALSimAddInjectionREAL8TimeSeries(inj8Wave, signalvecREAL8, NULL);
1878
1879 if ( hplus ) XLALDestroyREAL8TimeSeries(hplus);
1880 if ( hcross ) XLALDestroyREAL8TimeSeries(hcross);
1881
1882 }
1883 XLALDestroyREAL4TimeSeries(injectionBuffer);
1885 &thisData->timeData->epoch,
1886 0.0,
1887 thisData->freqData->deltaF,
1889 thisData->freqData->data->length);
1890 if(!injF) {
1891 XLALPrintError("Unable to allocate memory for injection buffer\n");
1893 }
1894 /* Window the data */
1895 REAL4 WinNorm = sqrt(thisData->window->sumofsquares/thisData->window->data->length);
1896 for(j=0;j<inj8Wave->data->length;j++) inj8Wave->data->data[j]*=thisData->window->data->data[j]; /* /WinNorm; */ /* Window normalisation applied only in freq domain */
1897 XLALREAL8TimeFreqFFT(injF,inj8Wave,thisData->timeToFreqFFTPlan);
1898 if(thisData->oneSidedNoisePowerSpectrum){
1899 for(SNR=0.0,j=thisData->fLow/injF->deltaF;j<thisData->fHigh/injF->deltaF;j++){
1900 SNR += pow(creal(injF->data->data[j]), 2.0)/thisData->oneSidedNoisePowerSpectrum->data->data[j];
1901 SNR += pow(cimag(injF->data->data[j]), 2.0)/thisData->oneSidedNoisePowerSpectrum->data->data[j];
1902 }
1903 SNR*=4.0*injF->deltaF;
1904 }
1905 thisData->SNR=sqrt(SNR);
1906 NetworkSNR+=SNR;
1907
1908 /* Actually inject the waveform */
1909 for(j=0;j<inj8Wave->data->length;j++) thisData->timeData->data->data[j]+=inj8Wave->data->data[j];
1910 fprintf(stdout,"Injected SNR in detector %s = %g\n",thisData->name,thisData->SNR);
1911 char filename[320];
1912 sprintf(filename,"%s_timeInjection.dat",thisData->name);
1913 FILE* file=fopen(filename, "w");
1914 for(j=0;j<inj8Wave->data->length;j++){
1915 fprintf(file, "%.6f\t%lg\n", XLALGPSGetREAL8(&thisData->timeData->epoch) + thisData->timeData->deltaT*j, inj8Wave->data->data[j]);
1916 }
1917 fclose(file);
1918 sprintf(filename,"%s_freqInjection.dat",thisData->name);
1919 file=fopen(filename, "w");
1920 for(j=0;j<injF->data->length;j++){
1921 thisData->freqData->data->data[j] += injF->data->data[j] / WinNorm;
1922 fprintf(file, "%lg %lg \t %lg\n", thisData->freqData->deltaF*j, creal(injF->data->data[j]), cimag(injF->data->data[j]));
1923 }
1924 fclose(file);
1925
1928 thisData=thisData->next;
1929 }
1930 ppt=LALInferenceGetProcParamVal(commandLine,"--dont-dump-extras");
1931 if (!ppt){
1932 PrintSNRsToFile(IFOdata , SNRpath);
1933 }
1934 NetworkSNR=sqrt(NetworkSNR);
1935 fprintf(stdout,"Network SNR of event %d = %g\n",event,NetworkSNR);
1936
1937 /* Output waveform raw h-plus mode */
1938 if( (ppt=LALInferenceGetProcParamVal(commandLine,"--rawwaveform")) )
1939 {
1940 rawWaveform=fopen(ppt->value,"w");
1941 bufferN = (UINT4) (bufferLength/IFOdata->timeData->deltaT);
1942 memcpy(&bufferStart,&IFOdata->timeData->epoch,sizeof(LIGOTimeGPS));
1943 XLALGPSAdd(&bufferStart,(REAL8) IFOdata->timeData->data->length * IFOdata->timeData->deltaT);
1944 XLALGPSAdd(&bufferStart,-bufferLength);
1946 if(!resp) XLAL_ERROR_VOID(XLAL_EFUNC);
1947 injectionBuffer=(REAL4TimeSeries *)XLALCreateREAL4TimeSeries("None",&bufferStart, 0.0, IFOdata->timeData->deltaT,&lalADCCountUnit, bufferN);
1948 if(!injectionBuffer) XLAL_ERROR_VOID(XLAL_EFUNC);
1949 /* This marks the sample in which the real segment starts, within the buffer */
1950 INT4 realStartSample=(INT4)((IFOdata->timeData->epoch.gpsSeconds - injectionBuffer->epoch.gpsSeconds)/IFOdata->timeData->deltaT);
1951 realStartSample+=(INT4)((IFOdata->timeData->epoch.gpsNanoSeconds - injectionBuffer->epoch.gpsNanoSeconds)*1e-9/IFOdata->timeData->deltaT);
1952 LALFindChirpInjectSignals(&status,injectionBuffer,injEvent,resp);
1953 if(status.statusCode) REPORTSTATUS(&status);
1955 injectionBuffer=(REAL4TimeSeries *)XLALCutREAL4TimeSeries(injectionBuffer,realStartSample,IFOdata->timeData->data->length);
1956 for(j=0;j<injectionBuffer->data->length;j++) fprintf(rawWaveform,"%.6f\t%g\n", XLALGPSGetREAL8(&IFOdata->timeData->epoch) + IFOdata->timeData->deltaT*j, injectionBuffer->data->data[j]);
1957 fclose(rawWaveform);
1958 XLALDestroyREAL4TimeSeries(injectionBuffer);
1959 }
1960
1961 LALInferencePrintDataWithInjection(IFOdata,commandLine);
1962
1963 return;
1964}
1965
1966
1967void InjectFD(LALInferenceIFOData *IFOdata, SimInspiralTable *inj_table, ProcessParamsTable *commandLine)
1968///*-------------- Inject in Frequency domain -----------------*/
1969{
1970 /* Inject a gravitational wave into the data in the frequency domain */
1972 memset(&status,0,sizeof(LALStatus));
1973 INT4 errnum;
1974 char SNRpath[FILENAME_MAX+50];
1975 ProcessParamsTable *ppt=NULL;
1976 int flipped_masses=0;
1977 LALInferenceIFOData *dataPtr;
1978
1979 ppt = LALInferenceGetProcParamVal(commandLine,"--outfile");
1980 if (ppt)
1981 sprintf(SNRpath, "%s_snr.txt", ppt->value);
1982 else
1983 sprintf(SNRpath, "snr.txt");
1984
1986 if( (int) approximant == XLAL_FAILURE)
1987 ABORTXLAL(&status);
1988
1989 LALPNOrder phase_order = XLALGetOrderFromString(inj_table->waveform);
1990 if ( (int) phase_order == XLAL_FAILURE)
1991 ABORTXLAL(&status);
1992
1993 LALPNOrder amp_order = (LALPNOrder) inj_table->amp_order;
1994
1995 flipped_masses = enforce_m1_larger_m2(inj_table);
1996
1997 REAL8 injtime=0.0;
1998 injtime=(REAL8) inj_table->geocent_end_time.gpsSeconds + (REAL8) inj_table->geocent_end_time.gpsNanoSeconds*1.0e-9;
1999
2000 // Inject (lambda1,lambda2)
2001 REAL8 lambda1 = 0.;
2002 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambda1")) {
2003 lambda1= atof(LALInferenceGetProcParamVal(commandLine,"--inj-lambda1")->value);
2004 }
2005 REAL8 lambda2 = 0.;
2006 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambda2")) {
2007 lambda2= atof(LALInferenceGetProcParamVal(commandLine,"--inj-lambda2")->value);
2008 }
2009 if(flipped_masses) /* If flipped masses, also flip lambda */
2010 {
2011 REAL8 lambda_tmp=lambda1;
2013 lambda2=lambda_tmp;
2014 fprintf(stdout,"Flipping lambdas since masses are flipped\n");
2015 }
2016 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambda1")) {
2017 fprintf(stdout,"Injection lambda1 set to %f\n",lambda1);
2018 }
2019 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambda2")) {
2020 fprintf(stdout,"Injection lambda2 set to %f\n",lambda2);
2021 }
2022
2023 /* Inject amplitude nonGR params
2024 Add inj-damp21 = *desired value* or inj-damp33 = *desired value* to the *.ini
2025 file in order to inject a signal with non-zero values for these parameters */
2026
2027 REAL8 damp21 = 0.;
2028 if(LALInferenceGetProcParamVal(commandLine,"--inj-damp21")){
2029 damp21 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-damp21")->value);
2030 fprintf(stdout,"Injection nonGR 21 amplitude set to %f\n",damp21);
2031 }
2032
2033 REAL8 damp33 = 0.;
2034 if(LALInferenceGetProcParamVal(commandLine,"--inj-damp33")){
2035 damp33 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-damp33")->value);
2036 fprintf(stdout,"Injection nonGR 33 amplitude set to %f\n",damp33);
2037 }
2038
2039 // Inject (lambdaT,dLambdaT)
2040 REAL8 lambdaT = 0.;
2041 REAL8 dLambdaT = 0.;
2042 if(LALInferenceGetProcParamVal(commandLine,"--inj-lambdaT")&&LALInferenceGetProcParamVal(commandLine,"--inj-dLambdaT")) {
2043 lambdaT= atof(LALInferenceGetProcParamVal(commandLine,"--inj-lambdaT")->value);
2044 dLambdaT= atof(LALInferenceGetProcParamVal(commandLine,"--inj-dLambdaT")->value);
2045 // Find lambda1,2(LambdaT,dLambdaT,eta)
2046 LALInferenceLambdaTsEta2Lambdas(lambdaT, dLambdaT, inj_table->eta, &lambda1, &lambda2);
2047 fprintf(stdout,"Injection lambdaT set to %f\n",lambdaT);
2048 fprintf(stdout,"Injection dLambdaT set to %f\n",dLambdaT);
2049 fprintf(stdout,"lambda1 set to %f\n",lambda1);
2050 fprintf(stdout,"lambda2 set to %f\n",lambda2);
2051 }
2052
2053 // Inject 4-piece polytrope eos
2054 REAL8 logp1=0.0;
2055 REAL8 gamma1=0.0;
2056 REAL8 gamma2=0.0;
2057 REAL8 gamma3=0.0;
2058 if(LALInferenceGetProcParamVal(commandLine,"--inj-logp1")&&LALInferenceGetProcParamVal(commandLine,"--inj-gamma1")&&LALInferenceGetProcParamVal(commandLine,"--inj-gamma2")&&LALInferenceGetProcParamVal(commandLine,"--inj-gamma3")){
2059 logp1= atof(LALInferenceGetProcParamVal(commandLine,"--inj-logp1")->value);
2060 gamma1= atof(LALInferenceGetProcParamVal(commandLine,"--inj-gamma1")->value);
2061 gamma2= atof(LALInferenceGetProcParamVal(commandLine,"--inj-gamma2")->value);
2062 gamma3= atof(LALInferenceGetProcParamVal(commandLine,"--inj-gamma3")->value);
2063 // Find lambda1,2(m1,2|eos)
2064 LALInferenceLogp1GammasMasses2Lambdas(logp1, gamma1, gamma2, gamma3, inj_table->mass1, inj_table->mass2, &lambda1, &lambda2);
2065 fprintf(stdout,"Injection logp1 set to %f\n",logp1);
2066 fprintf(stdout,"Injection gamma1 set to %f\n",gamma1);
2067 fprintf(stdout,"Injection gamma2 set to %f\n",gamma2);
2068 fprintf(stdout,"Injection gamma3 set to %f\n",gamma3);
2069 fprintf(stdout,"lambda1 set to %f\n",lambda1);
2070 fprintf(stdout,"lambda2 set to %f\n",lambda2);
2071
2072 /*
2073 For when tagSimInspiralTable is updated
2074 to include EOS params
2075
2076 injEvent->logp1= logp1;
2077 injEvent->gamma1= gamma1;
2078 injEvent->gamma2= gamma2;
2079 injEvent->gamma3= gamma3;
2080 */
2081 }
2082
2083 // Inject 4-coef. spectral eos
2084 REAL8 SDgamma0=0.0;
2085 REAL8 SDgamma1=0.0;
2086 REAL8 SDgamma2=0.0;
2087 REAL8 SDgamma3=0.0;
2088 if(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma0") && LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma1") && LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma2") && LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma3")){
2089 SDgamma0= atof(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma0")->value);
2090 SDgamma1= atof(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma1")->value);
2091 SDgamma2= atof(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma2")->value);
2092 SDgamma3= atof(LALInferenceGetProcParamVal(commandLine,"--inj-SDgamma3")->value);
2093 REAL8 gamma[]={SDgamma0,SDgamma1,SDgamma2,SDgamma3};
2095 fprintf(stdout,"Injection SDgamma0 set to %lf\n",SDgamma0);
2096 fprintf(stdout,"Injection SDgamma1 set to %lf\n",SDgamma1);
2097 fprintf(stdout,"Injection SDgamma2 set to %lf\n",SDgamma2);
2098 fprintf(stdout,"Injection SDgamma3 set to %lf\n",SDgamma3);
2099 fprintf(stdout,"lambda1 set to %f\n",lambda1);
2100 fprintf(stdout,"lambda2 set to %f\n",lambda2);
2101 }
2102
2103
2104 /* FIXME: One also need to code the same manipulations done to f_max in LALInferenceTemplateXLALSimInspiralChooseWaveform line 856 circa*/
2105
2106 /* Set up LAL dictionary */
2107 LALDict* LALpars=XLALCreateDict();
2108
2109 // Inject deviation from GR
2110 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchiMinus2")){
2111 REAL8 dchi_minus2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchiMinus2")->value);
2113
2114 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchiMinus1")){
2115 REAL8 dchi_minus1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchiMinus1")->value);
2117
2118 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi0")){
2119 REAL8 dchi0 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi0")->value);
2121
2122 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi1")){
2123 REAL8 dchi1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi1")->value);
2125
2126 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi2")){
2127 REAL8 dchi2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi2")->value);
2129
2130 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi3")){
2131 REAL8 dchi3 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi3")->value);
2133
2134 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi4")){
2135 REAL8 dchi4 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi4")->value);
2137
2138 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi5")){
2139 REAL8 dchi5 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi5")->value);
2141
2142 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi5l")){
2143 REAL8 dchi5l = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi5l")->value);
2145
2146 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi6")){
2147 REAL8 dchi6 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi6")->value);
2149
2150 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi6l")){
2151 REAL8 dchi6l = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi6l")->value);
2153
2154 if (LALInferenceGetProcParamVal(commandLine,"--inj-dchi7")){
2155 REAL8 dchi7 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dchi7")->value);
2157
2158 if (LALInferenceGetProcParamVal(commandLine,"--inj-db1")){
2159 REAL8 nongr_db1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-db1")->value);
2161
2162 if (LALInferenceGetProcParamVal(commandLine,"--inj-db2")){
2163 REAL8 nongr_db2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-db2")->value);
2165
2166 if (LALInferenceGetProcParamVal(commandLine,"--inj-db3")){
2167 REAL8 nongr_db3 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-db3")->value);
2169
2170 if (LALInferenceGetProcParamVal(commandLine,"--inj-db4")){
2171 REAL8 nongr_db4 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-db4")->value);
2173
2174 if (LALInferenceGetProcParamVal(commandLine,"--inj-dc1")){
2175 REAL8 nongr_dc1 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dc1")->value);
2177
2178 if (LALInferenceGetProcParamVal(commandLine,"--inj-dc2")){
2179 REAL8 nongr_dc2 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dc2")->value);
2181
2182 if (LALInferenceGetProcParamVal(commandLine,"--inj-dc4")){
2183 REAL8 nongr_dc4 = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dc4")->value);
2185
2186 if (LALInferenceGetProcParamVal(commandLine,"--inj-dcl")){
2187 REAL8 nongr_dcl = atof(LALInferenceGetProcParamVal(commandLine,"--inj-dcl")->value);
2189
2190
2191 /* Set the spin-frame convention */
2192 ppt = LALInferenceGetProcParamVal(commandLine,"--inj-spin-frame");
2193 if(ppt) {
2194 if (!strcmp(ppt->value, "view"))
2196 else if (!strcmp(ppt->value, "orbital-l"))
2198 else if (!strcmp(ppt->value, "total-j"))
2200 }
2201
2203 if(LALInferenceGetProcParamVal(commandLine, "--inj-spinOrder")) {
2204 spinO = atoi(LALInferenceGetProcParamVal(commandLine, "--inj-spinOrder")->value);
2206 }
2207
2209 if(LALInferenceGetProcParamVal(commandLine, "--inj-tidalOrder")) {
2210 tideO = atoi(LALInferenceGetProcParamVal(commandLine, "--inj-tidalOrder")->value);
2212 }
2213
2214 REAL8 deltaT = IFOdata->timeData->deltaT;
2215 REAL8 deltaF = IFOdata->freqData->deltaF;
2216
2217 REAL8 f_min = XLALSimInspiralfLow2fStart(inj_table->f_lower, amp_order, approximant);
2218 REAL8 f_max = 0.0;
2219
2220 REAL8 fref = 100.;
2221 if(LALInferenceGetProcParamVal(commandLine,"--inj-fref")) {
2222 fref = atoi(LALInferenceGetProcParamVal(commandLine,"--inj-fref")->value);
2223 }
2224
2225 if (approximant == TaylorF2)
2226 f_max = 0.0; /* this will stop at ISCO */
2227 else{
2228 /* get the max f_max as done in Template. Has to do this since I cannot access LALInferenceModel here*/
2229 dataPtr=IFOdata;
2230 while(dataPtr){
2231 if(dataPtr->fHigh>f_max) f_max=dataPtr->fHigh;
2232 dataPtr=dataPtr->next;
2233 }
2234 }
2235 /* Print a line with information about approximant, amp_order, phaseorder, tide order and spin order */
2236 fprintf(stdout,"\n\n---\t\t ---\n");
2237 fprintf(stdout,"Injection will run using Approximant %i (%s), phase order %i, amp order %i, spin order %i, tidal order %i, in the frequency domain.\n",approximant,XLALSimInspiralGetStringFromApproximant(approximant),phase_order,amp_order,(int) spinO,(int) tideO);
2238 fprintf(stdout,"---\t\t ---\n\n");
2239
2240 COMPLEX16FrequencySeries *hptilde=NULL, *hctilde=NULL;
2241
2246
2247 /* Insert damp21 or damp33 values given in the *.ini file in LALpars dictionary
2248 to pass them to the waveform generator. The damp21 and damp33 values are printed
2249 in the *.out file just as a check */
2250
2253 fprintf(stdout,"Injected damp21 and damp33 are %f and %f\n",damp21,damp33);
2254
2255 XLALSimInspiralChooseFDWaveform(&hptilde, &hctilde, inj_table->mass1*LAL_MSUN_SI, inj_table->mass2*LAL_MSUN_SI,
2256 inj_table->spin1x, inj_table->spin1y, inj_table->spin1z,
2257 inj_table->spin2x, inj_table->spin2y, inj_table->spin2z,
2258 inj_table->distance*LAL_PC_SI * 1.0e6, inj_table->inclination,
2259 inj_table->coa_phase, 0., 0., 0., deltaF, f_min, f_max, fref,
2260 LALpars, approximant);
2261 XLALDestroyDict(LALpars);
2262
2263 /* Fail if injection waveform generation was not successful */
2264 errnum = *XLALGetErrnoPtr();
2265 if (errnum != XLAL_SUCCESS) {
2266 XLALPrintError(" ERROR in InjectFD(): error encountered when injecting waveform. errnum=%d\n",errnum);
2267 abort();
2268 }
2269
2270 if((ppt=LALInferenceGetProcParamVal(commandLine,"--dump-geocenter-pols"))) {
2271 fprintf(stdout,"Dump injected FreqDomain h_plus and h_cross at geocenter (for IFO %s)\n", IFOdata->name);
2272 char filename[320];
2273 sprintf(filename,"%s_FD_geocenter_pols.dat",IFOdata->name);
2274 FILE* file=fopen(filename, "w");
2275 if(!file){
2276 fprintf(stderr,"Unable to open the path %s for writing injected FreqDomain h_plus and h_cross\n",filename);
2277 abort();
2278 }
2279 UINT4 j;
2280 for(j=0; j<hptilde->data->length; j++){
2281 fprintf(file, "%10.10g %10.10g %10.10g %10.10g %10.10g\n", deltaF*j,
2282 creal(hptilde->data->data[j]), cimag(hptilde->data->data[j]),
2283 creal(hctilde->data->data[j]), cimag(hctilde->data->data[j]));
2284 }
2285 fclose(file);
2286 }
2287
2288 REAL8 Fplus, Fcross;
2289 REAL8 plainTemplateReal, plainTemplateImag;
2290 REAL8 templateReal, templateImag;
2291 LIGOTimeGPS GPSlal;
2292 REAL8 gmst;
2293 REAL8 chisquared;
2294 REAL8 timedelay; /* time delay b/w iterferometer & geocenter w.r.t. sky location */
2295 REAL8 timeshift; /* time shift (not necessarily same as above) */
2296 REAL8 twopit, re, im, dre, dim, newRe, newIm;
2297 UINT4 i, lower, upper;
2298
2299 REAL8 temp=0.0;
2300 REAL8 NetSNR=0.0;
2301
2302 /* figure out GMST: */
2303 XLALGPSSetREAL8(&GPSlal, injtime);
2304 gmst=XLALGreenwichMeanSiderealTime(&GPSlal);
2305
2306 /* loop over data (different interferometers): */
2307 dataPtr = IFOdata;
2308
2309 while (dataPtr != NULL) {
2310 /*-- WF to inject is now in hptilde and hctilde. --*/
2311 /* determine beam pattern response (Fplus and Fcross) for given Ifo: */
2312 XLALComputeDetAMResponse(&Fplus, &Fcross,
2313 (const REAL4(*)[3])dataPtr->detector->response,
2314 inj_table->longitude, inj_table->latitude,
2315 inj_table->polarization, gmst);
2316
2317 /* signal arrival time (relative to geocenter); */
2318 timedelay = XLALTimeDelayFromEarthCenter(dataPtr->detector->location,
2319 inj_table->longitude, inj_table->latitude,
2320 &GPSlal);
2321
2322 /* (negative timedelay means signal arrives earlier at Ifo than at geocenter, etc.) */
2323 /* amount by which to time-shift template (not necessarily same as above "timedelay"): */
2324 REAL8 instant = dataPtr->timeData->epoch.gpsSeconds + 1e-9*dataPtr->timeData->epoch.gpsNanoSeconds;
2325
2326 timeshift = (injtime - instant) + timedelay;
2327 twopit = LAL_TWOPI * (timeshift);
2328
2329 dataPtr->fPlus = Fplus;
2330 dataPtr->fCross = Fcross;
2331 dataPtr->timeshift = timeshift;
2332
2333 char InjFileName[320];
2334 sprintf(InjFileName,"injection_%s.dat",dataPtr->name);
2335 FILE *outInj=fopen(InjFileName,"w");
2336
2337 /* determine frequency range & loop over frequency bins: */
2338 lower = (UINT4)ceil(dataPtr->fLow / deltaF);
2339 upper = (UINT4)floor(dataPtr->fHigh / deltaF);
2340 chisquared = 0.0;
2341
2342 re = cos(twopit * deltaF * lower);
2343 im = -sin(twopit * deltaF * lower);
2344
2345 /* When analysing TD data, FD templates need to be amplified by the window power loss factor */
2346 double windowFactor;
2347 windowFactor=sqrt(dataPtr->window->data->length/dataPtr->window->sumofsquares);
2348
2349 for (i=lower; i<=upper; ++i){
2350 /* derive template (involving location/orientation parameters) from given plus/cross waveforms: */
2351 if (i < hptilde->data->length) {
2352 plainTemplateReal = Fplus * creal(hptilde->data->data[i])
2353 + Fcross * creal(hctilde->data->data[i]);
2354 plainTemplateImag = Fplus * cimag(hptilde->data->data[i])
2355 + Fcross * cimag(hctilde->data->data[i]);
2356 } else {
2357 plainTemplateReal = 0.0;
2358 plainTemplateImag = 0.0;
2359 }
2360
2361 /* do time-shifting... */
2362 /* (also un-do 1/deltaT scaling): */
2363 /* real & imag parts of exp(-2*pi*i*f*deltaT): */
2364 templateReal = (plainTemplateReal*re - plainTemplateImag*im);
2365 templateImag = (plainTemplateReal*im + plainTemplateImag*re);
2366
2367 /* apply windowing factor */
2368 templateReal *= ((REAL8) windowFactor);
2369 templateImag *= ((REAL8) windowFactor);
2370
2371 /* Incremental values, using cos(theta) - 1 = -2*sin(theta/2)^2 */
2372 dim = -sin(twopit*deltaF);
2373 dre = -2.0*sin(0.5*twopit*deltaF)*sin(0.5*twopit*deltaF);
2374 newRe = re + re*dre - im * dim;
2375 newIm = im + re*dim + im*dre;
2376 re = newRe;
2377 im = newIm;
2378
2379 fprintf(outInj,"%lf %e %e %e\n",i*deltaF ,templateReal,templateImag,1.0/dataPtr->oneSidedNoisePowerSpectrum->data->data[i]);
2380 dataPtr->freqData->data->data[i] += crect( templateReal, templateImag );
2381
2382 temp = ((2.0/( deltaT*(double) dataPtr->timeData->data->length) * (templateReal*templateReal+templateImag*templateImag)) / dataPtr->oneSidedNoisePowerSpectrum->data->data[i]);
2383 chisquared += temp;
2384 }
2385 printf("injected SNR %.1f in IFO %s\n",sqrt(2.0*chisquared),dataPtr->name);
2386 NetSNR+=2.0*chisquared;
2387 dataPtr->SNR=sqrt(2.0*chisquared);
2388 dataPtr = dataPtr->next;
2389
2390 fclose(outInj);
2391 }
2392 printf("injected Network SNR %.1f \n",sqrt(NetSNR));
2393 ppt=LALInferenceGetProcParamVal(commandLine,"--dont-dump-extras");
2394 if (!ppt){
2395 PrintSNRsToFile(IFOdata , SNRpath);
2396 }
2399}
2400
2401static void PrintSNRsToFile(LALInferenceIFOData *IFOdata , char SNRpath[] ){
2402 REAL8 NetSNR=0.0;
2403 LALInferenceIFOData *thisData=IFOdata;
2404 int nIFO=0;
2405
2406 while(thisData){
2407 thisData=thisData->next;
2408 nIFO++;
2409 }
2410 FILE * snrout = fopen(SNRpath,"w");
2411 if(!snrout){
2412 fprintf(stderr,"Unable to open the path %s for writing SNR files\n",SNRpath);
2413 fprintf(stderr,"Error code %i: %s\n",errno,strerror(errno));
2414 abort();
2415 }
2416 thisData=IFOdata;
2417 while(thisData){
2418 fprintf(snrout,"%s:\t %4.2f\n",thisData->name,thisData->SNR);
2419 nIFO++;
2420 NetSNR+=(thisData->SNR*thisData->SNR);
2421 thisData=thisData->next;
2422 }
2423 if (nIFO>1){
2424 fprintf(snrout,"Network:\t");
2425 fprintf(snrout,"%4.2f\n",sqrt(NetSNR));
2426 }
2427 fclose(snrout);
2428}
2429
2430/**
2431* Fill the variables passed in vars with the parameters of the injection passed in event
2432* will over-write and destroy any existing parameters. Param vary type will be fixed
2433*/
2435{
2436 //UINT4 spinCheck=0;
2437 if(!vars) {
2438 XLALPrintError("Encountered NULL variables pointer");
2440 }
2441 enforce_m1_larger_m2(theEventTable);
2442 REAL8 q = theEventTable->mass2 / theEventTable->mass1;
2443 if (q > 1.0) q = 1.0/q;
2444
2445 REAL8 psi = theEventTable->polarization;
2446 if (psi>=M_PI) psi -= M_PI;
2447
2448 REAL8 injGPSTime = XLALGPSGetREAL8(&(theEventTable->geocent_end_time));
2449
2450 REAL8 dist = theEventTable->distance;
2451 //REAL8 cosinclination = cos(theEventTable->inclination);
2452 REAL8 phase = theEventTable->coa_phase;
2453 REAL8 dec = theEventTable->latitude;
2454 REAL8 ra = theEventTable->longitude;
2455
2456 Approximant injapprox = XLALGetApproximantFromString(theEventTable->waveform);
2457 LALPNOrder order = XLALGetOrderFromString(theEventTable->waveform);
2458
2459 REAL8 m1=theEventTable->mass1;
2460 REAL8 m2=theEventTable->mass2;
2461 REAL8 chirpmass = theEventTable->mchirp;
2462
2465 if (LALInferenceCheckVariable(vars,"distance"))
2467 else if (LALInferenceCheckVariable(vars,"logdistance")){
2468 REAL8 logdistance=log(dist);
2469 LALInferenceAddVariable(vars, "logdistance", &logdistance, LALINFERENCE_REAL8_t, LALINFERENCE_PARAM_FIXED);
2470 }
2473
2474 /* Those will work even if the user is working with the detector-frame variables because SKY_FRAME is set
2475 to zero while calculating the injected logL in LALInferencePrintInjectionSample */
2479
2480
2481 LALInferenceAddVariable(vars, "LAL_APPROXIMANT", &injapprox, LALINFERENCE_UINT4_t, LALINFERENCE_PARAM_FIXED);
2483 LALInferenceAddVariable(vars, "LAL_AMPORDER", &(theEventTable->amp_order), LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
2484
2485 REAL8 thetaJN,phiJL,theta1,theta2,phi12,chi1,chi2;
2486 /* Convert cartesian spin coordinates to system-frame variables*/
2487
2488 /* This fref is --inj-fref, which has been set previously by LALInferencePrintInjectionSample
2489 I don't call it inj_fref since LALInferenceTemplate looks for fref, and that is what will be called to calculate
2490 the logL at injval
2491 */
2492 REAL8 fref=100.0;
2493 if (LALInferenceCheckVariable(vars,"f_ref"))
2494 fref= *(REAL8*) LALInferenceGetVariable(vars,"f_ref");
2495
2496 XLALSimInspiralTransformPrecessingWvf2PE(&thetaJN,&phiJL,&theta1,&theta2,&phi12,&chi1,&chi2,theEventTable->inclination,theEventTable->spin1x,theEventTable->spin1y,theEventTable->spin1z, theEventTable->spin2x, theEventTable->spin2y, theEventTable->spin2z,m1,m2,fref,phase);
2497
2498 if (LALInferenceCheckVariable(vars,"a_spin1"))
2500 if (LALInferenceCheckVariable(vars,"a_spin2"))
2502 if (LALInferenceCheckVariable(vars,"tilt_spin1"))
2504 if (LALInferenceCheckVariable(vars,"tilt_spin2"))
2506 if (LALInferenceCheckVariable(vars,"phi_jl"))
2508 if (LALInferenceCheckVariable(vars,"phi12"))
2510 REAL8 costhetajn=cos(thetaJN);
2511 LALInferenceAddVariable(vars, "costheta_jn", &costhetajn, LALINFERENCE_REAL8_t, LALINFERENCE_PARAM_FIXED);
2512
2513}
2514
2516 int errnum=0;
2517 char *fname=NULL;
2518 char defaultname[]="injection_params.dat";
2519 FILE *outfile=NULL;
2520
2521 /* check if the --inj argument has been passed */
2523 if (!ppt)
2524 return(NULL);
2525
2526 SimInspiralTable *injTable=NULL, *theEventTable=NULL;
2528 if (LALInferenceGetProcParamVal(runState->commandLine, "--roqtime_steps")){
2529 LALInferenceSetupROQmodel(model, runState->commandLine);
2530 fprintf(stderr, "done LALInferenceSetupROQmodel\n");
2531 } else {
2532 model->roq_flag=0;
2533 }
2535 LALInferenceCopyVariables(model->params, injparams);
2536
2538
2539 ppt = LALInferenceGetProcParamVal(runState->commandLine, "--outfile");
2540 if (ppt) {
2541 fname = XLALCalloc((strlen(ppt->value)+255)*sizeof(char),1);
2542 sprintf(fname,"%s.injection",ppt->value);
2543 }
2544 else
2545 fname = defaultname;
2546
2547 ppt = LALInferenceGetProcParamVal(runState->commandLine, "--event");
2548 if (ppt) {
2549 UINT4 event = atoi(ppt->value);
2550 UINT4 i;
2551 theEventTable = injTable;
2552 for (i = 0; i < event; i++) {
2553 theEventTable = theEventTable->next;
2554 }
2555 theEventTable->next = NULL;
2556 } else {
2557 theEventTable=injTable;
2558 theEventTable->next = NULL;
2559 }
2560
2561 LALPNOrder *order = LALInferenceGetVariable(injparams, "LAL_PNORDER");
2562 Approximant *approx = LALInferenceGetVariable(injparams, "LAL_APPROXIMANT");
2563
2564 if (!(approx && order)){
2565 fprintf(stdout,"Unable to print injection sample: No approximant/PN order set\n");
2566 return(NULL);
2567 }
2568
2569 REAL8 fref = 100.;
2570 if(LALInferenceGetProcParamVal(runState->commandLine,"--inj-fref")) {
2571 fref = atoi(LALInferenceGetProcParamVal(runState->commandLine,"--inj-fref")->value);
2572 }
2574
2575 UINT4 azero=0;
2576 LALInferenceAddVariable(injparams,"SKY_FRAME",(void *)&azero,LALINFERENCE_REAL8_t,LALINFERENCE_PARAM_OUTPUT);
2577 /* remove eventual SKY FRAME vars since they will contain garbage*/
2578 if (LALInferenceCheckVariable(injparams,"t0"))
2579 LALInferenceRemoveVariable(injparams,"t0");
2580 if (LALInferenceCheckVariable(injparams,"cosalpha"))
2581 LALInferenceRemoveVariable(injparams,"cosalpha");
2582 if (LALInferenceCheckVariable(injparams,"azimuth"))
2583 LALInferenceRemoveVariable(injparams,"azimuth");
2584
2585 /* Fill named variables */
2586 LALInferenceInjectionToVariables(theEventTable, injparams);
2587
2588 REAL8 injPrior = runState->prior(runState, injparams, model);
2590 REAL8 injL=0.;
2591 if ( (int) *approx == XLALGetApproximantFromString(theEventTable->waveform)){
2592 XLAL_TRY(injL = runState->likelihood(injparams, runState->data, model), errnum);
2593 if(errnum){
2594 fprintf(stderr,"ERROR: Cannot print injection sample. Received error code %s\n",XLALErrorString(errnum));
2595 }
2596 }
2598 REAL8 logZnoise=LALInferenceNullLogLikelihood(runState->data);
2599 REAL8 tmp2=injL-logZnoise;
2600 LALInferenceAddVariable(injparams,"deltalogL",(void *)&tmp2,LALINFERENCE_REAL8_t,LALINFERENCE_PARAM_OUTPUT);
2601
2602 LALInferenceIFOData *data=runState->data;
2603 while(data) {
2604 char tmpName[320];
2605 REAL8 tmp=model->loglikelihood - data->nullloglikelihood;
2606 sprintf(tmpName,"deltalogl%s",data->name);
2608 data=data->next;
2609 }
2610
2611 /* Save to file */
2612 outfile=fopen(fname,"w");
2613 if(!outfile) {fprintf(stderr,"ERROR: Unable to open file %s for injection saving\n",fname); abort();}
2616 fprintf(outfile,"\n");
2617 LALInferencePrintSample(outfile, injparams);
2618
2619 fclose(outfile);
2620 //LALInferenceClearVariables(injparams);
2621 return(injparams);
2622}
2623
2625 /* Template generator assumes m1>=m2 thus we must enfore the same convention while injecting, otherwise spin2 will be assigned to mass1
2626 * We also shift the phase by pi to be sure the same WF in injected
2627 * Returns: 1 if masses were flipped
2628 */
2629 REAL8 m1,m2,tmp;
2630 m1=injEvent->mass1;
2631 m2=injEvent->mass2;
2632
2633 if (m1>=m2) return(0);
2634 else{
2635 fprintf(stdout, "Injtable has m1<m2. Flipping masses and spins in injection. Shifting phase by pi. \n");
2636 tmp=m1;
2637 injEvent->mass1=injEvent->mass2;
2638 injEvent->mass2=tmp;
2639 tmp=injEvent->spin1x;
2640 injEvent->spin1x=injEvent->spin2x;
2641 injEvent->spin2x=tmp;
2642 tmp=injEvent->spin1y;
2643 injEvent->spin1y=injEvent->spin2y;
2644 injEvent->spin2y=tmp;
2645 tmp=injEvent->spin1z;
2646 injEvent->spin1z=injEvent->spin2z;
2647 injEvent->spin2z=tmp;
2648 injEvent->coa_phase=injEvent->coa_phase+LAL_PI;
2649 return(1);
2650 }
2651}
2652
2654
2656 memset(&status,0,sizeof(status));
2657 UINT4 q=0;
2658 UINT4 event=0;
2659 ProcessParamsTable *procparam=NULL,*ppt=NULL;
2660 SimInspiralTable *injTable=NULL;
2661 FILE *tempfp;
2662 unsigned int n_basis_linear=0, n_basis_quadratic=0, n_samples=0, time_steps=0;
2663 int errsave;
2664
2665 LIGOTimeGPS GPStrig;
2666 REAL8 endtime=0.0;
2667
2668 model->roq = XLALMalloc(sizeof(LALInferenceROQModel));
2669 model->roq_flag = 1;
2670 procparam=LALInferenceGetProcParamVal(commandLine,"--inj");
2671 if(procparam){
2672 injTable = XLALSimInspiralTableFromLIGOLw(procparam->value);
2673 if(!injTable){
2674 fprintf(stderr,"Unable to open injection file(LALInferenceReadData) %s\n",procparam->value);
2675 abort();
2676 }
2677 procparam=LALInferenceGetProcParamVal(commandLine,"--event");
2678 if(procparam) {
2679 event=atoi(procparam->value);
2680 while(q<event) {q++; injTable=injTable->next;}
2681 }
2682 else if ((procparam=LALInferenceGetProcParamVal(commandLine,"--event-id")))
2683 {
2684 while(injTable)
2685 {
2686 if(injTable->simulation_id == atol(procparam->value)) break;
2687 else injTable=injTable->next;
2688 }
2689 if(!injTable){
2690 fprintf(stderr,"Error, cannot find simulation id %s in injection file\n",procparam->value);
2691 abort();
2692 }
2693 }
2694 }
2695
2696 if(LALInferenceGetProcParamVal(commandLine,"--trigtime")){
2697 procparam=LALInferenceGetProcParamVal(commandLine,"--trigtime");
2698 XLALStrToGPS(&GPStrig,procparam->value,NULL);
2699 }
2700 else{
2701 if(injTable) memcpy(&GPStrig,&(injTable->geocent_end_time),sizeof(GPStrig));
2702 else {
2703 fprintf(stderr,">>> Error: No trigger time specifed and no injection given \n");
2704 abort();
2705 }
2706 }
2707
2708 endtime=XLALGPSGetREAL8(&GPStrig);
2709
2710 if(LALInferenceGetProcParamVal(commandLine,"--roqtime_steps")){
2711 ppt=LALInferenceGetProcParamVal(commandLine,"--roqtime_steps");
2712 tempfp = fopen (ppt->value,"r");
2713 if (tempfp == NULL){
2714 errsave = errno;
2715 fprintf(stderr, "Error: cannot find file %s \n", ppt->value);
2716 fprintf(stderr, "Error code %i: %s\n", errsave, strerror(errsave));
2717 abort();
2718 }
2719 fscanf(tempfp, "%u", &time_steps);
2720 fscanf(tempfp, "%u", &n_basis_linear);
2721 fscanf(tempfp, "%u", &n_basis_quadratic);
2722 fscanf(tempfp, "%u", &n_samples);
2723 fclose(tempfp);
2724 fprintf(stderr, "loaded --roqtime_steps\n");
2725 }
2726
2727
2728 model->roq->frequencyNodesLinear = XLALCreateREAL8Sequence(n_basis_linear);
2729 model->roq->frequencyNodesQuadratic = XLALCreateREAL8Sequence(n_basis_quadratic);
2730
2731 model->roq->trigtime = endtime;
2732
2733 model->roq->frequencyNodesLinear = XLALCreateREAL8Sequence(n_basis_linear);
2734 model->roq->frequencyNodesQuadratic = XLALCreateREAL8Sequence(n_basis_quadratic);
2735 model->roq->calFactorLinear = XLALCreateCOMPLEX16Sequence(model->roq->frequencyNodesLinear->length);
2736 model->roq->calFactorQuadratic = XLALCreateCOMPLEX16Sequence(model->roq->frequencyNodesQuadratic->length);
2737
2738 if(LALInferenceGetProcParamVal(commandLine,"--roqnodesLinear")){
2739 ppt=LALInferenceGetProcParamVal(commandLine,"--roqnodesLinear");
2740
2741 model->roq->nodesFileLinear = fopen(ppt->value, "rb");
2742 if (!(model->roq->nodesFileLinear)) {
2743 errsave = errno;
2744 fprintf(stderr, "Error: cannot find file %s \n", ppt->value);
2745 fprintf(stderr, "Error code %i: %s\n", errsave, strerror(errsave));
2746 abort();
2747 } // check file exists
2748 fprintf(stderr, "read model->roq->frequencyNodesLinear");
2749
2750 for(unsigned int linsize = 0; linsize < n_basis_linear; linsize++){
2751 fread(&(model->roq->frequencyNodesLinear->data[linsize]), sizeof(REAL8), 1, model->roq->nodesFileLinear);
2752 }
2753 fclose(model->roq->nodesFileLinear);
2754 model->roq->nodesFileLinear = NULL;
2755 fprintf(stderr, "loaded --roqnodesLinear\n");
2756 }
2757
2758 if(LALInferenceGetProcParamVal(commandLine,"--roqnodesQuadratic")){
2759 ppt=LALInferenceGetProcParamVal(commandLine,"--roqnodesQuadratic");
2760 model->roq->nodesFileQuadratic = fopen(ppt->value, "rb");
2761 if (!(model->roq->nodesFileQuadratic)) {
2762 errsave = errno;
2763 fprintf(stderr, "Error: cannot find file %s \n", ppt->value);
2764 fprintf(stderr, "Error code %i: %s\n", errsave, strerror(errsave));
2765 abort();
2766 } // check file exists
2767
2768 for(unsigned int quadsize = 0; quadsize < n_basis_quadratic; quadsize++){
2769 fread(&(model->roq->frequencyNodesQuadratic->data[quadsize]), sizeof(REAL8), 1, model->roq->nodesFileQuadratic);
2770 }
2771 fclose(model->roq->nodesFileQuadratic);
2772 model->roq->nodesFileQuadratic = NULL;
2773 fprintf(stderr, "loaded --roqnodesQuadratic\n");
2774
2775
2776
2777 }
2778}
2779
2782 memset(&status,0,sizeof(status));
2783 LALInferenceIFOData *thisData=IFOdata;
2784 UINT4 q=0;
2785 UINT4 event=0;
2786 ProcessParamsTable *procparam=NULL,*ppt=NULL;
2787 SimInspiralTable *injTable=NULL;
2788 unsigned int n_basis_linear, n_basis_quadratic, n_samples, time_steps;
2789 float dt=0.1;
2790 //REAL8 timeMin=0.0,timeMax=0.0;
2791 FILE *tempfp;
2792 char tmp[320];
2793 int errsave;
2794
2795 procparam=LALInferenceGetProcParamVal(commandLine,"--inj");
2796 if(procparam) {
2797 injTable = XLALSimInspiralTableFromLIGOLw(procparam->value);
2798 if (!injTable) {
2799 fprintf(stderr,"Unable to open injection file(LALInferenceReadData) %s\n",procparam->value);
2800 abort();
2801 }
2802 procparam=LALInferenceGetProcParamVal(commandLine,"--event");
2803 if (procparam) {
2804 event=atoi(procparam->value);
2805 while(q<event) {
2806 q++;
2807 injTable=injTable->next;
2808 }
2809 } else if ((procparam=LALInferenceGetProcParamVal(commandLine,"--event-id"))) {
2810 while (injTable) {
2811 if (injTable->simulation_id == atol(procparam->value)) {
2812 break;
2813 } else {
2814 injTable=injTable->next;
2815 }
2816 }
2817 if (!injTable) {
2818 fprintf(stderr, "Error, cannot find simulation id %s in injection file\n", procparam->value);
2819 abort();
2820 }
2821 }
2822 }
2823
2824 ppt=LALInferenceGetProcParamVal(commandLine,"--dt");
2825 if(ppt){
2826 dt=atof(ppt->value);
2827 }
2828
2829 if (LALInferenceGetProcParamVal(commandLine,"--roqtime_steps")) {
2830 ppt = LALInferenceGetProcParamVal(commandLine,"--roqtime_steps");
2831 tempfp = fopen (ppt->value,"r");
2832 if (tempfp == NULL){
2833 errsave = errno;
2834 fprintf(stderr, "Error: cannot find file %s \n", ppt->value);
2835 fprintf(stderr, "Error code %i: %s\n", errsave, strerror(errsave));
2836 abort();
2837 }
2838 fscanf(tempfp, "%u", &time_steps);
2839 fscanf(tempfp, "%u", &n_basis_linear);
2840 fscanf(tempfp, "%u", &n_basis_quadratic);
2841 fscanf(tempfp, "%u", &n_samples);
2842 fclose(tempfp);
2843 fprintf(stderr, "loaded --roqtime_steps\n");
2844 }
2845
2846
2847 thisData=IFOdata;
2848 while (thisData) {
2849 thisData->roq = XLALMalloc(sizeof(LALInferenceROQData));
2850
2851 thisData->roq->weights_linear = XLALMalloc(n_basis_linear*sizeof(LALInferenceROQSplineWeights));
2852
2853 sprintf(tmp, "--%s-roqweightsLinear", thisData->name);
2854 ppt = LALInferenceGetProcParamVal(commandLine,tmp);
2855
2856 thisData->roq->weightsFileLinear = fopen(ppt->value, "rb");
2857 if (thisData->roq->weightsFileLinear == NULL){
2858 errsave = errno;
2859 fprintf(stderr, "Error: cannot find file %s \n", ppt->value);
2860 fprintf(stderr, "Error code %i: %s\n", errsave, strerror(errsave));
2861 abort();
2862 }
2863 thisData->roq->weightsLinear = (double complex*)malloc(n_basis_linear*time_steps*(sizeof(double complex)));
2864
2865 //0.045 comes from the diameter of the earth in light seconds: the maximum time-delay between earth-based observatories
2866 thisData->roq->time_weights_width = 2*dt + 2*0.045;
2867 thisData->roq->time_step_size = thisData->roq->time_weights_width/time_steps;
2868 thisData->roq->n_time_steps = time_steps;
2869
2870
2871 fprintf(stderr, "basis_size = %d\n", n_basis_linear);
2872 fprintf(stderr, "time steps = %d\n", time_steps);
2873
2874 double *tmp_real_weight = malloc(time_steps*(sizeof(double)));
2875 double *tmp_imag_weight = malloc(time_steps*(sizeof(double)));
2876
2877 double *tmp_tcs = malloc(time_steps*(sizeof(double)));
2878
2879 sprintf(tmp, "--roq-times");
2880 ppt = LALInferenceGetProcParamVal(commandLine,tmp);
2881
2882 FILE *tcFile = fopen(ppt->value, "rb");
2883 if (tcFile == NULL) {
2884 errsave = errno;
2885 fprintf(stderr, "Error: cannot find file %s \n", ppt->value);
2886 fprintf(stderr, "Error code %i: %s\n", errsave, strerror(errsave));
2887 abort();
2888 }
2889
2890 for(unsigned int gg=0;gg < time_steps; gg++){
2891 fread(&(tmp_tcs[gg]), sizeof(double), 1, tcFile);
2892 }
2893
2894 for(unsigned int ii=0; ii<n_basis_linear;ii++){
2895 for(unsigned int jj=0; jj<time_steps;jj++){
2896 fread(&(thisData->roq->weightsLinear[ii*time_steps + jj]), sizeof(double complex), 1, thisData->roq->weightsFileLinear);
2897 tmp_real_weight[jj] = creal(thisData->roq->weightsLinear[ii*time_steps + jj]);
2898 tmp_imag_weight[jj] = cimag(thisData->roq->weightsLinear[ii*time_steps + jj]);
2899 }
2900 //gsl_interp_accel is not thread-safe, and each OpenMP thread will need its
2901 //own gsl_interp_accel object.
2902 thisData->roq->weights_linear[ii].acc_real_weight_linear = NULL;
2903 thisData->roq->weights_linear[ii].acc_imag_weight_linear = NULL;
2904
2905 thisData->roq->weights_linear[ii].spline_real_weight_linear = gsl_spline_alloc (gsl_interp_cspline, time_steps);
2906 gsl_spline_init(thisData->roq->weights_linear[ii].spline_real_weight_linear, tmp_tcs, tmp_real_weight, time_steps);
2907
2908 thisData->roq->weights_linear[ii].spline_imag_weight_linear = gsl_spline_alloc (gsl_interp_cspline, time_steps);
2909 gsl_spline_init(thisData->roq->weights_linear[ii].spline_imag_weight_linear, tmp_tcs, tmp_imag_weight, time_steps);
2910 }
2911 fclose(thisData->roq->weightsFileLinear);
2912 thisData->roq->weightsFileLinear = NULL;
2913 fclose(tcFile);
2914
2915 sprintf(tmp, "--%s-roqweightsQuadratic", thisData->name);
2916 ppt = LALInferenceGetProcParamVal(commandLine,tmp);
2917 thisData->roq->weightsQuadratic = (double*)malloc(n_basis_quadratic*sizeof(double));
2918 thisData->roq->weightsFileQuadratic = fopen(ppt->value, "rb");
2919 if (thisData->roq->weightsFileQuadratic == NULL){
2920 errsave = errno;
2921 fprintf(stderr, "Error: cannot find file %s \n", ppt->value);
2922 fprintf(stderr, "Error code %i: %s\n", errsave, strerror(errsave));
2923 abort();
2924 }
2925 for(unsigned int ii=0; ii<n_basis_quadratic;ii++){
2926 fread(&(thisData->roq->weightsQuadratic[ii]), sizeof(double), 1, thisData->roq->weightsFileQuadratic);
2927 }
2928 fclose(thisData->roq->weightsFileQuadratic);
2929 thisData->roq->weightsFileQuadratic = NULL;
2930 fprintf(stderr, "loaded %s ROQ weights\n", thisData->name);
2931 thisData = thisData->next;
2932 }
2933}
2934
2936
2937 ProcessParamsTable *procparam;
2938 SimInspiralTable *inspiralTable=NULL;
2939 SimBurst *burstTable=NULL;
2940 UINT4 event=0;
2941 UINT4 q=0;
2943 memset(&status,0,sizeof(LALStatus));
2944
2945 /* First check if trigtime has been given as an option */
2946 if(LALInferenceGetProcParamVal(commandLine,"--trigtime")){
2947 procparam=LALInferenceGetProcParamVal(commandLine,"--trigtime");
2948 XLALStrToGPS(GPStrig,procparam->value,NULL);
2949 fprintf(stdout,"Set trigtime to %.10f\n",GPStrig->gpsSeconds+1.0e-9 * GPStrig->gpsNanoSeconds);
2950 return;
2951
2952 }
2953 else{
2954 /* If not check if we have an injtable passed with --inj */
2955
2956 if(LALInferenceGetProcParamVal(commandLine,"--injXML"))
2957 {
2958 XLALPrintError("ERROR: --injXML option is deprecated. Use --inj and update your scripts\n");
2959 abort();
2960 }
2961 if((procparam=LALInferenceGetProcParamVal(commandLine,"--inj"))){
2962 fprintf(stdout,"Checking if the xml table is an inspiral table... \n");
2963 /* Check if it is a SimInspiralTable */
2964 inspiralTable = XLALSimInspiralTableFromLIGOLw(procparam->value);
2965
2966 if (inspiralTable){
2967 procparam=LALInferenceGetProcParamVal(commandLine,"--event");
2968 if(procparam) {
2969 event=atoi(procparam->value);
2970 while(q<event) {q++; inspiralTable=inspiralTable->next;}
2971 }
2972 else if ((procparam=LALInferenceGetProcParamVal(commandLine,"--event-id")))
2973 {
2974 while(inspiralTable)
2975 {
2976 if(inspiralTable->simulation_id == atol(procparam->value)) break;
2977 else inspiralTable=inspiralTable->next;
2978 }
2979 if(!inspiralTable){
2980 fprintf(stderr,"Error, cannot find simulation id %s in injection file\n",procparam->value);
2981 abort();
2982 }
2983 }
2984 else
2985 fprintf(stdout,"You did not provide an event number with the injtable. Using event 0 which may not be what you want!!!!!\n");
2986 memcpy(GPStrig,&(inspiralTable->geocent_end_time),sizeof(LIGOTimeGPS));
2987 printf("Set inspiral injtime %.10f\n",inspiralTable->geocent_end_time.gpsSeconds+1.0e-9* inspiralTable->geocent_end_time.gpsNanoSeconds);
2988 return;
2989 }
2990 }
2991 else if((procparam=LALInferenceGetProcParamVal(commandLine,"--binj"))){
2992 /* Check if it is a SimBurst table */
2993 fprintf(stdout,"Checking if the xml table is a burst table... \n");
2994 burstTable=XLALSimBurstTableFromLIGOLw(procparam->value);
2995 if(burstTable){
2996 procparam=LALInferenceGetProcParamVal(commandLine,"--event");
2997 if(procparam) {
2998 event=atoi(procparam->value);
2999 while(q<event) {q++; burstTable=burstTable->next;}
3000 }
3001 else if ((procparam=LALInferenceGetProcParamVal(commandLine,"--event-id")))
3002 {
3003 fprintf(stderr,"Error, SimBurst tables do not currently support event_id tags \n");
3004 abort();
3005 }
3006 else
3007 fprintf(stdout,"You did not provide an event number with the injtable. Using event 0 which may not be what you want!!!!!\n");
3008 memcpy(GPStrig,&(burstTable->time_geocent_gps),sizeof(LIGOTimeGPS));
3009 fprintf(stdout,"Set trigtime from burstable to %.10f\n",GPStrig->gpsSeconds+1.0e-9 * GPStrig->gpsNanoSeconds);
3010 return;
3011 }
3012 }
3013 else if(!LALInferenceGetProcParamVal(commandLine,"--segment-start")){
3014 XLALPrintError("Error: No trigger time specifed and no injection given \n");
3015 //XLAL_ERROR_NULL(XLAL_EINVAL);
3016 abort();
3017 }
3018
3019 }
3020}
3021
3023
3024 /* Read time domain WF present in an mdc frame file, FFT it and inject into the frequency domain stream */
3025
3026 char mdcname[]="GW";
3027 char **mdc_caches=NULL;
3028 char **mdc_channels=NULL;
3029 ProcessParamsTable * ppt=commandLine;
3030
3031 UINT4 nIFO=0;
3032 int i=0;
3033 UINT4 j=0;
3034 LALInferenceIFOData *data=IFOdata;
3035 REAL8 prefactor =1.0;
3036 ppt=LALInferenceGetProcParamVal(commandLine,"--mdc-prefactor");
3037 if (ppt){
3038
3039 prefactor=atof(ppt->value);
3040 fprintf(stdout,"Using prefactor=%f to scale the MDC injection\n",prefactor);
3041 }
3042
3043 ppt=LALInferenceGetProcParamVal(commandLine,"--inj");
3044 if (ppt){
3045
3046 fprintf(stderr,"You cannot use both injfile (--inj) and MDCs (--inject_from_mdc) Exiting... \n");
3047 abort();
3048
3049 }
3050 ppt=LALInferenceGetProcParamVal(commandLine,"--binj");
3051 if (ppt){
3052
3053 fprintf(stderr,"You cannot use both injfile (--binj) and MDCs (--inject_from_mdc) Exiting... \n");
3054 abort();
3055
3056 }
3057
3058 REAL8 tmp=0.0;
3059 REAL8 net_snr=0.0;
3060 while (data) {nIFO++; data=data->next;}
3061 UINT4 Nmdc=0,Nchannel=0;
3062
3063 char mdc_caches_name[] = "injcache";
3064 char mdc_channels_name[] = "injchannel";
3065 char **IFOnames=NULL;
3066 INT4 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&mdc_caches ,mdc_caches_name, &Nmdc);
3067 if (!rlceops){
3068 fprintf(stderr,"Must provide a --IFO-injcache option for each IFO if --inject_from_mdc is given\n");
3069 abort();
3070 }
3071
3072 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&mdc_channels ,mdc_channels_name, &Nchannel);
3073 if (!rlceops){
3074 fprintf(stdout,"WARNING: You did not provide the name(s) of channel(s) to use with the injection mdc. Using the default which may not be what you want!\n");
3075 mdc_channels= malloc((nIFO+1)*sizeof(char*));
3076 data=IFOdata;
3077 i=0;
3078 while (data){
3079 mdc_channels[i] = malloc(512*sizeof(char));
3080 if(!strcmp(data->name,"H1")) {
3081 sprintf(mdc_channels[i],"H1:%s-H",mdcname);}
3082 else if(!strcmp(data->name,"L1")) {
3083 sprintf(mdc_channels[i],"L1:%s-H",mdcname); }
3084 else if(!strcmp(data->name,"V1")) {
3085 sprintf(mdc_channels[i],"V1:%s-16K",mdcname);}
3086 data=data->next;
3087 i++;
3088
3089 }
3090 }
3091
3092 LIGOTimeGPS epoch=IFOdata->timeData->epoch;
3093 REAL8 deltaT=IFOdata->timeData->deltaT ;
3094 int seglen=IFOdata->timeData->data->length;
3095 REAL8 SampleRate=4096.0,SegmentLength=0.0;
3096 if(LALInferenceGetProcParamVal(commandLine,"--srate")) SampleRate=atof(LALInferenceGetProcParamVal(commandLine,"--srate")->value);
3097 SegmentLength=(REAL8) seglen/SampleRate;
3098
3099 REAL8TimeSeries * timeData=NULL;
3102
3103 if(!injF) {
3104 XLALPrintError("Unable to allocate memory for injection buffer\n");
3106 }
3107
3108 REAL4 WinNorm = sqrt(IFOdata->window->sumofsquares/IFOdata->window->data->length);
3109
3110 data=IFOdata;
3111 i=0;
3112 UINT4 lower = (UINT4)ceil(data->fLow / injF->deltaF);
3113 UINT4 upper = (UINT4)floor(data->fHigh /injF-> deltaF);
3114 //FIXME CHECK WNORM
3115 /* Inject into FD data stream and calculate optimal SNR */
3116 while(data){
3117 tmp=0.0;
3118 LALCache *mdc_cache=NULL;
3119 mdc_cache = XLALCacheImport(mdc_caches[i] );
3120
3121 /* Read MDC frame */
3122 timeData=readTseries(mdc_cache,mdc_channels[i],epoch,SegmentLength);
3123 /* downsample */
3124 XLALResampleREAL8TimeSeries(timeData,1.0/SampleRate);
3125 /* window timeData and store it in windTimeData */
3126 XLALDDVectorMultiply(windTimeData->data,timeData->data,IFOdata->window->data);
3127
3128 /*for(j=0;j< timeData->data->length;j++)
3129 fprintf(out,"%lf %10.10e %10.10e %10.10e \n",epoch.gpsSeconds + j*deltaT,data->timeData->data->data[j],data->timeData->data->data[j]+timeData->data->data[j],timeData->data->data[j]);
3130 fclose(out);
3131 */
3132
3133 /* set the whole seq to 0 */
3134 for(j=0;j<injF->data->length;j++) injF->data->data[j]=0.0;
3135
3136 /* FFT */
3137 XLALREAL8TimeFreqFFT(injF,windTimeData,IFOdata->timeToFreqFFTPlan);
3138
3139
3140 for(j=lower;j<upper;j++){
3141 windTimeData->data->data[j] /= sqrt(data->window->sumofsquares / data->window->data->length);
3142 /* Add data in freq stream */
3143 data->freqData->data->data[j]+=crect(prefactor *creal(injF->data->data[j])/WinNorm,prefactor *cimag(injF->data->data[j])/WinNorm);
3144 tmp+= prefactor*prefactor*(creal(injF ->data->data[j])*creal(injF ->data->data[j])+cimag(injF ->data->data[j])*cimag(injF ->data->data[j]))/data->oneSidedNoisePowerSpectrum->data->data[j];
3145 }
3146
3147 tmp*=2.*injF->deltaF;
3148 printf("Injected SNR %.3f in IFO %s from MDC \n",sqrt(2*tmp),data->name);
3149 data->SNR=sqrt(2*tmp);
3150 net_snr+=2*tmp;
3151 i++;
3152 data=data->next;
3153 }
3154 printf("Injected network SNR %.3f from MDC\n",sqrt(net_snr));
3155
3156 char SNRpath[FILENAME_MAX+100];
3157 ppt=LALInferenceGetProcParamVal(commandLine,"--outfile");
3158 if(!ppt){
3159 fprintf(stderr,"Must specify --outfile <filename.dat>\n");
3160 abort();
3161 }
3162 char *outfile=ppt->value;
3163 snprintf(SNRpath,sizeof(SNRpath),"%s_snr.txt",outfile);
3164 ppt=LALInferenceGetProcParamVal(commandLine,"--dont-dump-extras");
3165 if (!ppt){
3166 PrintSNRsToFile(IFOdata , SNRpath);
3167 }
3168 return ;
3169
3170}
int XLALStrToGPS(LIGOTimeGPS *t, const char *nptr, char **endptr)
LALDetectorIndexE1DIFF
LALDetectorIndexE2DIFF
LALDetectorIndexE3DIFF
LALDetectorIndexLLODIFF
LALDetectorIndexGEO600DIFF
LALDetectorIndexKAGRADIFF
LALDetectorIndexVIRGODIFF
LALDetectorIndexLHODIFF
LALDetectorIndexLIODIFF
void LALFindChirpInjectSignals(LALStatus *status, REAL4TimeSeries *chan, SimInspiralTable *events, COMPLEX8FrequencySeries *resp)
void XLALDestroyDict(LALDict *dict)
LALDict * XLALCreateDict(void)
void REPORTSTATUS(LALStatus *status)
int XLALCheckBurstApproximantFromString(const CHAR *inString)
LALInferenceModel * LALInferenceInitCBCModel(LALInferenceRunState *state)
Initialise state variables needed for LALInferenceNest or LALInferenceMCMC to run on a CBC signal.
static REAL8 norm(const REAL8 x[3])
void InjectFD(LALInferenceIFOData *IFOdata, SimInspiralTable *inj_table, ProcessParamsTable *commandLine)
-----------— Inject in Frequency domain --------------—‍/
static void makeWhiteData(LALInferenceIFOData *IFOdata)
static INT4 getNamedDataOptionsByDetectors(ProcessParamsTable *commandLine, char ***ifos, char ***out, const char *name, UINT4 *N)
Parse the command line looking for options of the kind —IFO-name value Unlike the function above,...
void LALInferenceInjectInspiralSignal(LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
void MetaNoiseFunc(LALStatus *status, REAL8 *psd, REAL8 f, struct fvec *interp, NoiseFunc *noisefunc)
struct fvec * interpFromFile(char *filename, REAL8 squareinput)
void() NoiseFunc(LALStatus *statusPtr, REAL8 *psd, REAL8 f)
#define USAGE
#define LALINFERENCE_DEFAULT_FLOW
int enforce_m1_larger_m2(SimInspiralTable *injEvent)
static const LALUnit strainPerCount
static void LALInferencePrintDataWithInjection(LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
static INT4 getDataOptionsByDetectors(ProcessParamsTable *commandLine, char ***ifos, char ***caches, char ***channels, char ***flows, char ***fhighs, char ***timeslides, char ***asds, char ***psds, UINT4 *N)
Parse the command line looking for options of the kind –ifo H1 –H1-channel H1:LDAS_STRAIN –H1-cache H...
static void PrintSNRsToFile(LALInferenceIFOData *IFOdata, char SNRpath[])
static LALCache * GlobFramesPWD(char *ifo)
static REAL8TimeSeries * readTseries(LALCache *cache, CHAR *channel, LIGOTimeGPS start, REAL8 length)
static void LALInferenceSetGPSTrigtime(LIGOTimeGPS *GPStrig, ProcessParamsTable *commandLine)
REAL8 interpolate(struct fvec *fvec, REAL8 f)
ProcessParamsTable * ppt
int j
int k
void XLALSimInjectNinjaSignals(REAL4TimeSeries *chan, const char *ifo, REAL8 dynRange, SimInspiralTable *events)
int XLALGetOrderFromString(const char *waveform)
int XLALGetApproximantFromString(const char *waveform)
REAL8 XLALSimInspiralfLow2fStart(REAL8 fLow, INT4 ampOrder, INT4 approximant)
int XLALSimInspiralImplementedFDApproximants(Approximant approximant)
int XLALSimInspiralGetFrameAxisFromString(const char *waveform)
const char * XLALSimInspiralGetStringFromApproximant(Approximant approximant)
#define gamma
int XLALSimInspiralWaveformParamsInsertNonGRDC1(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi4(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRAmp21(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDB4(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChiMinus2(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertPNPhaseOrder(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertNumRelData(LALDict *params, const char *value)
int XLALSimInspiralWaveformParamsInsertNonGRAmp33(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDB2(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDBeta1(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDBeta2(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChiMinus1(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi5L(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi1(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertTidalLambda1(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi5(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi7(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertFrameAxis(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertNonGRDBeta3(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi2(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi3(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertPNSpinOrder(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertTidalLambda2(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertPNAmplitudeOrder(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertNonGRDC2(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertPNTidalOrder(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertNonGRDB3(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDCL(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDAlpha1(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi6(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDC4(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi6L(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDAlpha3(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDChi0(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDB1(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertNonGRDAlpha2(LALDict *params, REAL8 value)
#define ABORTXLAL(sp)
SimInspiralTable * XLALSimInspiralTableFromLIGOLw(const char *fileName)
SimBurst * XLALSimBurstTableFromLIGOLw(const char *filename)
#define fscanf
#define fprintf
const char *const name
double e
const char * detector
sigmaKerr data[0]
LALDetector * XLALCreateDetector(LALDetector *detector, const LALFrDetector *frDetector, LALDetectorType type)
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
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)
REAL8FrequencySeries * XLALCreateREAL8FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
void XLALDestroyCOMPLEX8FrequencySeries(COMPLEX8FrequencySeries *series)
COMPLEX8FrequencySeries * XLALCreateCOMPLEX8FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
void XLALDestroyCOMPLEX16FrequencySeries(COMPLEX16FrequencySeries *series)
void LALGenerateInspiral(LALStatus *status, CoherentGW *waveform, SimInspiralTable *params, PPNParamStruc *ppnParamsInputOutput)
void XLALDestroyCache(LALCache *cache)
LALCache * XLALCacheGlob(const char *dirstr, const char *fnptrn)
LALCache * XLALCacheImport(const char *fname)
LALCache * XLALCacheDuplicate(const LALCache *cache)
int XLALCacheSieve(LALCache *cache, INT4 t0, INT4 t1, const char *srcregex, const char *dscregex, const char *urlregex)
#define LAL_MSUN_SI
#define LAL_PI
#define LAL_TWOPI
#define LAL_PC_SI
#define crect(re, im)
#define XLAL_NUM_ELEM(x)
double REAL8
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
LALDETECTORTYPE_IFODIFF
int XLALFrStreamClose(LALFrStream *stream)
LALFrStream * XLALFrStreamCacheOpen(LALCache *cache)
REAL8TimeSeries * XLALFrStreamInputREAL8TimeSeries(LALFrStream *stream, const char *chname, const LIGOTimeGPS *start, double duration, size_t lengthlimit)
#define VARNAME_MAX
Definition: LALInference.h:50
void LALInferencePrintSample(FILE *fp, LALInferenceVariables *sample)
Output the sample to file *fp, in ASCII format.
Definition: LALInference.c:923
int LALInferenceFprintParameterHeaders(FILE *out, LALInferenceVariables *params)
Print the parameter names to a file as a tab-separated ASCII line.
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.
Definition: LALInference.c:395
void LALInferenceLogp1GammasMasses2Lambdas(REAL8 logp1, REAL8 gamma1, REAL8 gamma2, REAL8 gamma3, REAL8 mass1, REAL8 mass2, REAL8 *lambda1, REAL8 *lambda2)
Calculate lambda1,2(m1,2|eos(logp1,gamma1,gamma2,gamma3))
void LALInferenceRemoveVariable(LALInferenceVariables *vars, const char *name)
Remove name from vars Frees the memory for the name structure and its contents.
Definition: LALInference.c:450
void LALInferenceLambdaTsEta2Lambdas(REAL8 lambdaT, REAL8 dLambdaT, REAL8 eta, REAL8 *lambda1, REAL8 *lambda2)
Convert from lambdaT, dLambdaT, and eta to lambda1 and lambda2.
void LALInferenceCopyVariables(LALInferenceVariables *origin, LALInferenceVariables *target)
Deep copy the variables from one to another LALInferenceVariables structure.
Definition: LALInference.c:558
void * LALInferenceGetVariable(const LALInferenceVariables *vars, const char *name)
Return a pointer to the memory the variable vars is stored in specified by name User must cast this p...
Definition: LALInference.c:238
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
Returns the element of the process params table with "name".
void LALInferenceSDGammasMasses2Lambdas(REAL8 gamma[], REAL8 mass1, REAL8 mass2, REAL8 *lambda1, REAL8 *lambda2, int size)
Convert from spectral parameters to lambda1, lambda2.
void LALInferenceParseCharacterOptionString(char *input, char **strings[], UINT4 *n)
parses a character string (passed as one of the options) and decomposes it into individual parameter ...
#define DETNAMELEN
Definition: LALInference.h:617
void LALInferenceSortVariablesByName(LALInferenceVariables *vars)
Sorts the variable structure by name.
int LALInferenceCheckVariable(LALInferenceVariables *vars, const char *name)
Checks for name being present in vars returns 1(==true) or 0.
Definition: LALInference.c:525
@ LALINFERENCE_PARAM_OUTPUT
A parameter that never changes, functions should respect this.
Definition: LALInference.h:131
@ LALINFERENCE_PARAM_FIXED
A parameter that is cyclic, such as an angle between 0 and 2pi.
Definition: LALInference.h:130
@ LALINFERENCE_REAL8_t
Definition: LALInference.h:109
@ LALINFERENCE_INT4_t
Definition: LALInference.h:105
@ LALINFERENCE_UINT4_t
Definition: LALInference.h:107
REAL8 LALInferenceNullLogLikelihood(LALInferenceIFOData *data)
Identical to LALInferenceFreqDomainNullLogLikelihood, but returns the likelihood of a null template.
void LALInferenceInjectionToVariables(SimInspiralTable *theEventTable, LALInferenceVariables *vars)
Fill the variables passed in vars with the parameters of the injection passed in event will over-writ...
void LALInferenceSetupROQmodel(LALInferenceModel *model, ProcessParamsTable *commandLine)
void LALInferenceSetupROQdata(LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
void LALInferenceInjectFromMDC(ProcessParamsTable *commandLine, LALInferenceIFOData *IFOdata)
LALInferenceVariables * LALInferencePrintInjectionSample(LALInferenceRunState *runState)
Function to output a sample with logL values etc for the injection, if one is made.
LALInferenceIFOData * LALInferenceReadData(ProcessParamsTable *commandLine)
Read IFO data according to command line arguments.
int LALInferenceRemoveLinesChiSquared(REAL8FrequencySeries *spectrum, const REAL8TimeSeries *tseries, UINT4 seglen, UINT4 stride, const REAL8Window *window, const REAL8FFTPlan *plan, REAL8 *pvalues)
Determine non-Gaussian frequency bins using a chi-squared test.
int LALInferenceXCorrBands(REAL8FrequencySeries *spectrum, const REAL8TimeSeries *tseries, UINT4 seglen, UINT4 stride, const REAL8Window *window, const REAL8FFTPlan *plan, REAL8 *pvalues, char *filename)
Determine correlated frequency bands using cross correlation.
int LALInferenceRemoveLinesPowerLaw(REAL8FrequencySeries *spectrum, const REAL8TimeSeries *tseries, UINT4 seglen, UINT4 stride, const REAL8Window *window, const REAL8FFTPlan *plan, REAL8 *pvalues)
Determine large amplitude frequency bins using power law fit.
int LALInferenceAverageSpectrumBinFit(REAL8FrequencySeries *spectrum, const REAL8TimeSeries *tseries, UINT4 seglen, UINT4 stride, const REAL8Window *window, const REAL8FFTPlan *plan, char *filename, LIGOTimeGPS GPStime)
Calculate PSD by fitting bins to lines.
int LALInferenceRemoveLinesKS(REAL8FrequencySeries *spectrum, const REAL8TimeSeries *tseries, UINT4 seglen, UINT4 stride, const REAL8Window *window, const REAL8FFTPlan *plan, REAL8 *pvalues)
Determine non-Gaussian frequency bins using a K-S test.
void * XLALMalloc(size_t n)
void * XLALCalloc(size_t m, size_t n)
void * XLALRealloc(void *p, size_t n)
void XLALFree(void *p)
void LALAdvLIGOPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
void LALGEOPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
void LALEGOPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
void LALLIGOIPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
void LALVIRGOPsd(LALStatus *status, REAL8 *shf, REAL8 x)
int XLALSimInspiralChooseFDWaveform(COMPLEX16FrequencySeries **hptilde, COMPLEX16FrequencySeries **hctilde, const REAL8 m1, const REAL8 m2, const REAL8 S1x, const REAL8 S1y, const REAL8 S1z, const REAL8 S2x, const REAL8 S2y, const REAL8 S2z, const REAL8 distance, const REAL8 inclination, const REAL8 phiRef, const REAL8 longAscNodes, const REAL8 eccentricity, const REAL8 UNUSED meanPerAno, const REAL8 deltaF, const REAL8 f_min, const REAL8 f_max, REAL8 f_ref, LALDict *params, const Approximant approximant)
int XLALSimInspiralChooseTDWaveform(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, const REAL8 m1, const REAL8 m2, const REAL8 S1x, const REAL8 S1y, const REAL8 S1z, const REAL8 S2x, const REAL8 S2y, const REAL8 S2z, const REAL8 distance, const REAL8 inclination, const REAL8 phiRef, const REAL8 longAscNodes, const REAL8 eccentricity, const REAL8 UNUSED meanPerAno, const REAL8 deltaT, const REAL8 f_min, REAL8 f_ref, LALDict *params, const Approximant approximant)
#define LAL_SIM_INSPIRAL_FRAME_AXIS_DEFAULT
LALSimInspiralSpinOrder
LALSimInspiralFrameAxis
LALSimInspiralTidalOrder
Approximant
LALPNOrder
LAL_SIM_INSPIRAL_SPIN_ORDER_ALL
LAL_SIM_INSPIRAL_FRAME_AXIS_VIEW
LAL_SIM_INSPIRAL_FRAME_AXIS_TOTAL_J
LAL_SIM_INSPIRAL_FRAME_AXIS_ORBITAL_L
LAL_SIM_INSPIRAL_TIDAL_ORDER_ALL
TaylorF2
NumRelNinja2
int XLALSimNoisePSDaLIGODesignSensitivityT1800044(REAL8FrequencySeries *psd, double flow)
int XLALSimNoisePSD(REAL8FrequencySeries *psd, double flow, double(*psdfunc)(double))
double XLALSimNoisePSDAdvVirgo(double f)
double XLALSimNoisePSDiLIGOSRD(double f)
double XLALSimNoisePSDVirgo(double f)
REAL8TimeSeries * XLALSimDetectorStrainREAL8TimeSeries(const REAL8TimeSeries *hplus, const REAL8TimeSeries *hcross, REAL8 right_ascension, REAL8 declination, REAL8 psi, const LALDetector *detector)
int XLALSimAddInjectionREAL8TimeSeries(REAL8TimeSeries *target, REAL8TimeSeries *h, const COMPLEX16FrequencySeries *response)
char char * XLALStringDuplicate(const char *s)
REAL4 XLALNormalDeviate(RandomParams *params)
static const INT4 q
RandomParams * XLALCreateRandomParams(INT4 seed)
void XLALDestroyRandomParams(RandomParams *params)
static const INT4 a
REAL8FFTPlan * XLALCreateReverseREAL8FFTPlan(UINT4 size, int measurelvl)
REAL8FFTPlan * XLALCreateForwardREAL8FFTPlan(UINT4 size, int measurelvl)
int XLALResampleREAL4TimeSeries(REAL4TimeSeries *series, REAL8 dt)
int XLALResampleREAL8TimeSeries(REAL8TimeSeries *series, REAL8 dt)
COMPLEX16Sequence * XLALCreateCOMPLEX16Sequence(size_t length)
REAL8Sequence * XLALCreateREAL8Sequence(size_t length)
REAL8 XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
int XLALREAL8AverageSpectrumWelch(REAL8FrequencySeries *spectrum, const REAL8TimeSeries *tseries, UINT4 seglen, UINT4 stride, const REAL8Window *window, const REAL8FFTPlan *plan)
int XLALREAL8AverageSpectrumMedian(REAL8FrequencySeries *spectrum, const REAL8TimeSeries *tseries, UINT4 seglen, UINT4 stride, const REAL8Window *window, const REAL8FFTPlan *plan)
int XLALREAL8TimeFreqFFT(COMPLEX16FrequencySeries *freq, const REAL8TimeSeries *tser, const REAL8FFTPlan *plan)
int XLALREAL8FreqTimeFFT(REAL8TimeSeries *tser, const COMPLEX16FrequencySeries *freq, const REAL8FFTPlan *plan)
REAL4TimeSeries * XLALCreateREAL4TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
REAL8TimeSeries * XLALShrinkREAL8TimeSeries(REAL8TimeSeries *series, size_t first, size_t length)
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
void XLALDestroyREAL4TimeSeries(REAL4TimeSeries *series)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
REAL4TimeSeries * XLALCutREAL4TimeSeries(const REAL4TimeSeries *series, size_t first, size_t length)
const LALUnit lalStrainUnit
const LALUnit lalADCCountUnit
const LALUnit lalDimensionlessUnit
REAL8Vector * XLALDDVectorMultiply(REAL8Vector *out, const REAL8Vector *in1, const REAL8Vector *in2)
REAL8Window * XLALCreateTukeyREAL8Window(UINT4 length, REAL8 beta)
#define XLAL_ERROR_VOID(...)
const char * XLALErrorString(int errnum)
#define XLAL_ERROR_NULL(...)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_TRY(statement, errnum)
int * XLALGetErrnoPtr(void)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFUNC
XLAL_EINVAL
XLAL_FAILURE
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
LIGOTimeGPS * XLALGPSAddGPS(LIGOTimeGPS *epoch, const LIGOTimeGPS *dt)
LIGOTimeGPS * XLALINT8NSToGPS(LIGOTimeGPS *epoch, INT8 ns)
int XLALSimInspiralTransformPrecessingWvf2PE(REAL8 *thetaJN, REAL8 *phiJL, REAL8 *theta1, REAL8 *theta2, REAL8 *phi12, REAL8 *chi1, REAL8 *chi2, const REAL8 incl, const REAL8 S1x, const REAL8 S1y, const REAL8 S1z, const REAL8 S2x, const REAL8 S2y, const REAL8 S2z, const REAL8 m1, const REAL8 m2, const REAL8 fRef, const REAL8 phiRef)
start
double fref
LALCache * cache
char * channel
COMPLEX16Sequence * data
COMPLEX16 * data
COMPLEX8Sequence * data
COMPLEX8 * data
LALDetector * site
CHAR * src
CHAR * dsc
CHAR * url
UINT4 length
LALCacheEntry * list
REAL4 response[3][3]
REAL8 location[3]
LALFrDetector frDetector
REAL8 vertexLongitudeRadians
REAL8 vertexLatitudeRadians
REAL4 xArmMidpoint
REAL4 vertexElevation
REAL4 xArmAzimuthRadians
REAL4 yArmMidpoint
CHAR prefix[3]
REAL4 yArmAltitudeRadians
REAL4 yArmAzimuthRadians
REAL4 xArmAltitudeRadians
CHAR name[LALNameLength]
Structure to contain IFO data.
Definition: LALInference.h:625
REAL8TimeSeries * timeData
Detector name.
Definition: LALInference.h:627
LALDetector * detector
integration limits for overlap integral in F-domain
Definition: LALInference.h:651
REAL8FrequencySeries * oneSidedNoisePowerSpectrum
Definition: LALInference.h:643
REAL8 timeshift
Detector responses.
Definition: LALInference.h:638
REAL8FFTPlan * timeToFreqFFTPlan
Padding for the above window.
Definition: LALInference.h:648
struct tagLALInferenceROQData * roq
counts how many time the template has been calculated
Definition: LALInference.h:657
REAL8Window * window
(one-sided Noise Power Spectrum)^{-1/2}
Definition: LALInference.h:646
char name[DETNAMELEN]
Definition: LALInference.h:626
COMPLEX16FrequencySeries * freqData
What is this?
Definition: LALInference.h:639
COMPLEX16FrequencySeries * whiteFreqData
Buffer for frequency domain data.
Definition: LALInference.h:640
REAL8 SNR
The epoch of this observation (the time of the first sample)
Definition: LALInference.h:653
struct tagLALInferenceIFOData * next
ROQ data.
Definition: LALInference.h:659
LIGOTimeGPS epoch
LALDetector structure for where this data came from.
Definition: LALInference.h:652
REAL8FFTPlan * freqToTimeFFTPlan
Definition: LALInference.h:648
REAL8 fLow
FFT plan needed for time/time-and-phase marginalisation.
Definition: LALInference.h:650
REAL8TimeSeries * whiteTimeData
A time series from the detector.
Definition: LALInference.h:628
Structure to constain a model and its parameters.
Definition: LALInference.h:436
REAL8 loglikelihood
Prior value at params
Definition: LALInference.h:443
int roq_flag
ROQ data.
Definition: LALInference.h:464
LALInferenceVariables * params
Definition: LALInference.h:437
struct tagLALInferenceROQModel * roq
The padding of the above window.
Definition: LALInference.h:463
Structure containing inference run state This includes pointers to the function types required to run...
Definition: LALInference.h:592
ProcessParamsTable * commandLine
Definition: LALInference.h:593
struct tagLALInferenceIFOData * data
Log sample, i.e.
Definition: LALInference.h:601
LALInferencePriorFunction prior
The algorithm's single iteration function.
Definition: LALInference.h:597
LALInferenceLikelihoodFunction likelihood
MultiNest prior for the parameters.
Definition: LALInference.h:599
The LALInferenceVariables structure to contain a set of parameters Implemented as a linked list of LA...
Definition: LALInference.h:170
INT4 gpsNanoSeconds
REAL4Vector * ppn
CHAR value[LIGOMETA_VALUE_MAX]
REAL4Sequence * data
LIGOTimeGPS epoch
REAL4 * data
REAL8Sequence * data
REAL8Sequence * data
LIGOTimeGPS epoch
REAL8 * data
REAL8Sequence * data
REAL8 sumofsquares
struct tagSimBurst * next
LIGOTimeGPS time_geocent_gps
LIGOTimeGPS geocent_end_time
struct tagSimInspiralTable * next
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
CHAR numrel_data[LIGOMETA_STRING_MAX]
enum @1 epoch
double f_min
double f_max
char * outfile