Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALApps 10.1.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
inspiralutils.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Patrick Brady
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/*-----------------------------------------------------------------------
21 *
22 * File Name: inspiralutils.c
23 *
24 * Author: Brown, D. A., Krishnan, B, Vitale S.
25 *
26 *
27 *-----------------------------------------------------------------------
28 */
29
30#include <config.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34#include <sys/types.h>
35#include <sys/stat.h>
36#include <fcntl.h>
37#include <regex.h>
38#include <time.h>
39#include <math.h>
40
41#include <LALAppsVCSInfo.h>
42#include <series.h>
43#include <lalappsfrutils.h>
44
45#include <lal/LALConfig.h>
46#include <lal/LALStdio.h>
47#include <lal/LALStdlib.h>
48#include <lal/LALError.h>
49#include <lal/LALDatatypes.h>
50#include <lal/AVFactories.h>
51#include <lal/LALConstants.h>
52#include <lal/PrintFTSeries.h>
53#include <lal/LALFrStream.h>
54#include <lal/ResampleTimeSeries.h>
55#include <lal/Calibration.h>
56#include <lal/Window.h>
57#include <lal/TimeFreqFFT.h>
58#include <lal/IIRFilter.h>
59#include <lal/BandPassTimeSeries.h>
60#include <lal/LIGOLwXML.h>
61#include <lal/LIGOLwXMLRead.h>
62#include <lal/LIGOMetadataTables.h>
63#include <lal/LIGOMetadataUtils.h>
64#include <lal/Date.h>
65#include <lal/Units.h>
66#include <lal/FindChirp.h>
67#include <lal/LALDict.h>
68#include <lal/LALNoiseModels.h>
69
70#include <lal/LALSimulation.h>
71#include <lal/LALSimNoise.h>
72#include <lal/LALInspiral.h>
73
74#include "inspiral.h"
75
76/*
77#include <lal/AVFactories.h>
78#include <lal/FrequencySeries.h>
79#include <lal/LALNoiseModels.h>
80#include <lal/ConfigFile.h>
81#include <lal/Units.h>
82*/
83
85 REAL4 thissnr, REAL8 chanDeltaT, INT4 nPoints,
86 REAL8FrequencySeries *spec, UINT4 cut)
87{
88 UINT4 k;
89 REAL8 sigmaSqSum = 0;
90 REAL8 distance = 0;
91 REAL8 negativeSevenOverThree = -7.0/3.0;
92 REAL8 totalMass = candleM1 + candleM2;
93 REAL8 mu = candleM1 * candleM2 / totalMass;
94 REAL8 distNorm = 2.0 * LAL_MRSUN_SI / (1.0e6 * LAL_PC_SI );
95 REAL8 a = sqrt( (5.0 * mu) / 96.0 ) *
96 pow( totalMass / ( LAL_PI * LAL_PI ), 1.0/3.0 ) *
97 pow( LAL_MTSUN_SI / chanDeltaT, -1.0/6.0 );
98 REAL8 sigmaSq = 4.0 * ( chanDeltaT / (REAL8) nPoints ) *
99 distNorm * distNorm * a * a;
100 REAL8 f_max = 1.0 / (6.0 * sqrt(6.0) * LAL_PI * totalMass * LAL_MTSUN_SI);
101 REAL8 f = 0;
102
103 for ( k = cut, f = spec->deltaF * cut;
104 k < spec->data->length && f < f_max;
105 ++k, f = spec->deltaF * k )
106 {
107 sigmaSqSum +=
108 pow( (REAL8) k / (REAL8) nPoints, negativeSevenOverThree )
109 / spec->data->data[k];
110 }
111
112 sigmaSq *= sigmaSqSum;
113
114 distance = sqrt( sigmaSq ) / thissnr;
115
116 return distance;
117}
118
121 REAL4 candleM1,
122 REAL4 candleM2,
123 REAL4 candlesnr,
124 REAL8 chanDeltaT,
125 INT4 nPoints,
127 UINT4 cut)
128{
129
131
132 InspiralTemplate tmplt;
133 REAL4Vector *waveform = NULL;
134 COMPLEX8Vector *waveFFT = NULL;
135 REAL4FFTPlan *fwdPlan = NULL;
136
137 REAL8 sigmaSq;
138 REAL8 distance;
139 UINT4 i;
140
141 memset( &tmplt, 0, sizeof(tmplt) );
142
143 /* Create storage for TD and FD template */
144 waveform = XLALCreateREAL4Vector( nPoints );
145 waveFFT = XLALCreateCOMPLEX8Vector( spec->data->length );
146 fwdPlan = XLALCreateForwardREAL4FFTPlan( nPoints, 0 );
147
148 /* Populate the template parameters */
149 tmplt.mass1 = candleM1;
150 tmplt.mass2 = candleM2;
151 tmplt.ieta = 1;
152 tmplt.approximant = approximant;
153 tmplt.tSampling = 1.0/chanDeltaT;
154 tmplt.order = LAL_PNORDER_PSEUDO_FOUR; /* Hardcode for EOBNR for now */
155 tmplt.fLower = spec->deltaF *cut;
156 tmplt.distance = 1.0e6 * LAL_PC_SI; /* Mpc */
157 tmplt.massChoice = m1Andm2;
158 tmplt.fCutoff = tmplt.tSampling / 2.0 - spec->deltaF;
159
160 /* From this, calculate the other parameters */
162
163 /* Generate the waveform */
165
166 XLALREAL4ForwardFFT( waveFFT, waveform, fwdPlan );
167
168 sigmaSq = 0.0;
169 for ( i = cut; i < waveFFT->length; i++ )
170 {
171 sigmaSq += ( crealf(waveFFT->data[i]) * crealf(waveFFT->data[i])
172 + cimagf(waveFFT->data[i]) * cimagf(waveFFT->data[i]) )/ spec->data->data[i];
173 }
174
175 sigmaSq *= 4.0 * chanDeltaT / (REAL8)nPoints;
176
177 /* Now calculate the distance */
178 distance = sqrt( sigmaSq ) / (REAL8)candlesnr;
179
180 /* Clean up! */
182 XLALDestroyCOMPLEX8Vector( waveFFT );
183 XLALDestroyREAL4FFTPlan( fwdPlan );
184
185 return (REAL4)distance;
186}
187
188
189void AddNumRelStrainModes( LALStatus *status, /**< pointer to LALStatus structure */
190 REAL4TimeVectorSeries **outStrain, /**< [out] h+, hx data */
191 SimInspiralTable *thisinj /**< [in] injection data */)
192{
193 INT4 modeL, modeM, modeLlo, modeLhi;
194 INT4 len, lenPlus, lenCross, k;
195 CHAR *channel_name_plus;
196 CHAR *channel_name_cross;
197 LALFrStream *frStream = NULL;
198 LALCache frCache;
200 REAL4TimeSeries *seriesPlus=NULL;
201 REAL4TimeSeries *seriesCross=NULL;
202 REAL8 massMpc;
203 REAL4TimeVectorSeries *sumStrain=NULL;
204 REAL4TimeVectorSeries *tempStrain=NULL;
205 /* NRWaveMetaData thisMetaData; */
206
209
210 modeLlo = thisinj->numrel_mode_min;
211 modeLhi = thisinj->numrel_mode_max;
212
213 /* create a frame cache and open the frame stream */
214 frCache.length = 1;
215 frCache.list = LALCalloc(1, sizeof(frCache.list[0]));
216 frCache.list[0].url = thisinj->numrel_data;
217 frStream = XLALFrStreamCacheOpen( &frCache );
218
219 /* the total mass of the binary in Mpc */
220 massMpc = (thisinj->mass1 + thisinj->mass2) * LAL_MRSUN_SI / ( LAL_PC_SI * 1.0e6);
221
222 /* start time of waveform -- set it to something */
223 epoch.gpsSeconds = 0;
224 epoch.gpsNanoSeconds = 0;
225
226 /* loop over l values */
227 for ( modeL = modeLlo; modeL <= modeLhi; modeL++ ) {
228
229 /* loop over m values */
230 for ( modeM = -modeL; modeM <= modeL; modeM++ ) {
231 /* read numrel waveform */
232 /* first the plus polarization */
233 channel_name_plus = XLALGetNinjaChannelName("plus", modeL, modeM);
234 /*get number of data points */
235 lenPlus = XLALFrStreamGetVectorLength ( channel_name_plus, frStream );
236
237 /* now the cross polarization */
238 channel_name_cross = XLALGetNinjaChannelName("cross", modeL, modeM);
239 /*get number of data points */
240 lenCross = XLALFrStreamGetVectorLength ( channel_name_cross, frStream );
241
242 /* skip on to next mode if mode doesn't exist */
243 if ( (lenPlus <= 0) || (lenCross <= 0) || (lenPlus != lenCross) ) {
245 LALFree(channel_name_plus);
246 LALFree(channel_name_cross);
247 continue;
248 }
249
250 /* note: lenPlus and lenCross must be equal if we got this far*/
251 /* len = lenPlus; */
252 len = lenPlus;
253
254 /* allocate and read the plus/cross time series */
255 seriesPlus = XLALCreateREAL4TimeSeries ( channel_name_plus, &epoch, 0, 0, &lalDimensionlessUnit, len);
256 memset(seriesPlus->data->data, 0, seriesPlus->data->length*sizeof(REAL4));
257 XLALFrStreamGetREAL4TimeSeries ( seriesPlus, frStream );
258 XLALFrStreamRewind( frStream );
259 LALFree(channel_name_plus);
260
261 seriesCross = XLALCreateREAL4TimeSeries ( channel_name_cross, &epoch, 0, 0, &lalDimensionlessUnit, len);
262 memset(seriesCross->data->data, 0, seriesCross->data->length*sizeof(REAL4));
263 XLALFrStreamGetREAL4TimeSeries ( seriesCross, frStream );
264 XLALFrStreamRewind( frStream );
265 LALFree(channel_name_cross);
266
267 /* allocate memory for tempStrain */
268 tempStrain = LALCalloc(1, sizeof(*tempStrain));
269 tempStrain->data = XLALCreateREAL4VectorSequence(2, len);
270 tempStrain->deltaT = LAL_MTSUN_SI * (thisinj->mass1 + thisinj->mass2) * seriesPlus->deltaT ;
271 tempStrain->f0 = seriesPlus->f0;
272 tempStrain->sampleUnits = seriesPlus->sampleUnits;
273 memset(tempStrain->data->data, 0, tempStrain->data->length * tempStrain->data->vectorLength*sizeof(REAL4));
274
275 /* now copy the data and scale amplitude corresponding to distance of 1Mpc*/
276 for (k = 0; k < len; k++) {
277 tempStrain->data->data[k] = massMpc * seriesPlus->data->data[k];
278 tempStrain->data->data[len + k] = massMpc * seriesCross->data->data[k]; }
279
280 /* we are done with seriesPlus and Cross for this iteration */
281 XLALDestroyREAL4TimeSeries (seriesPlus);
282 XLALDestroyREAL4TimeSeries (seriesCross);
283 seriesPlus = NULL;
284 seriesCross = NULL;
285
286 /* compute the h+ and hx for given inclination and coalescence phase*/
287 XLALOrientNRWave( tempStrain, modeL, modeM, thisinj->inclination, thisinj->coa_phase );
288 if (sumStrain == NULL) {
289
290 sumStrain = LALCalloc(1, sizeof(*sumStrain));
291 sumStrain->data = XLALCreateREAL4VectorSequence(2, tempStrain->data->vectorLength);
292 sumStrain->deltaT = tempStrain->deltaT;
293 sumStrain->f0 = tempStrain->f0;
294 sumStrain->sampleUnits = tempStrain->sampleUnits;
295
296 memset(sumStrain->data->data,0.0,2*tempStrain->data->vectorLength*sizeof(REAL4));
297
298 sumStrain = XLALSumStrain( sumStrain, tempStrain );
299
300 } else {
301 sumStrain = XLALSumStrain( sumStrain, tempStrain );
302 }
303
304 /* clear memory for strain */
305 if (tempStrain->data != NULL) {
306 XLALDestroyREAL4VectorSequence ( tempStrain->data );
307 LALFree( tempStrain );
308 tempStrain = NULL;
309 }
310 } /* end loop over modeM values */
311 } /* end loop over modeL values */
312
313 XLALFrStreamClose( frStream );
314 LALFree(frCache.list);
315 *outStrain = sumStrain;
317 RETURN(status);
318
319}
320
321/**
322 * Main function for injecting numetrical relativity waveforms.
323 * Takes as input a list of injections, and adds h(t) to a given
324 * timeseries for a specified ifo and a dynamic range factor.
325 * Updated/generalized version of InjectNumRelWaveforms that allows
326 * arbitrary LIGO and Virgo PSDs and integration starting frequencies
327 */
328void InjectNumRelWaveformsUsingPSDREAL8(LALStatus *status, /**< pointer to LALStatus structure */
329 REAL8TimeSeries *chan, /**< [out] the output time series */
330 SimInspiralTable *injections, /**< [in] list of injections */
331 CHAR ifo[3], /**< [in] 2 char code for interferometer */
332 REAL8 freqLowCutoff, /**< [in] Lower cutoff frequency */
333 REAL8 snrLow, /**< [in] lower cutoff value of snr */
334 REAL8 snrHigh, /**< TO BE DOCUMENTED */
335 REAL8FrequencySeries *ligoPSD, /**< [in] PSD to use for LIGO SNRs. If NULL, use initial PSD */
336 REAL8 ligoSnrLowFreq, /**< [in] Frequency at which to start integration for LIGO SNRs */
337 REAL8FrequencySeries *virgoPSD, /**< [in] PSD to use for Virgo SNRs. If NULL, use initial PSD */
338 REAL8 virgoSnrLowFreq, /**< [in] Frequency at which to start integration for Virgo SNRs */
339 CHAR *fname) /**< [in] higher cutoff value of snr */
340{
342 REAL8 startFreq, startFreqHz, massTotal;
343 REAL8 thisSNR;
344 SimInspiralTable *simTableOut=NULL;
345 SimInspiralTable *thisInjOut=NULL;
346
351
352
353 /* loop over injections */
355 {
356
358 massTotal = (thisInj->mass1 + thisInj->mass2) * LAL_MTSUN_SI;
359 startFreqHz = startFreq / ( LAL_TWOPI * massTotal);
360
361 if (startFreqHz < freqLowCutoff)
362 {
363 REAL8TimeSeries *strain = NULL;
365
366 if (ifo[0] == 'V')
367 thisSNR = calculate_snr_from_strain_and_psd_real8( strain, virgoPSD, virgoSnrLowFreq, ifo );
368 else
369 thisSNR = calculate_snr_from_strain_and_psd_real8( strain, ligoPSD, ligoSnrLowFreq, ifo );
370
371 /* set channel name */
372 snprintf( chan->name, LALNameLength * sizeof( CHAR ),
373 "%s:STRAIN", ifo );
374
375 printf("Injection at %d.%d in ifo %s has SNR %f\n",
378 ifo,
379 thisSNR);
380
381 if ((thisSNR < snrHigh) && (thisSNR > snrLow))
382 {
383 /* simTableOut will be null only the first time */
384 if ( simTableOut == NULL) {
385 simTableOut = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) );
386 memcpy(simTableOut, thisInj, sizeof(*thisInj));
387 simTableOut->next = NULL;
388 thisInjOut = simTableOut;
389 }
390 else {
391 thisInjOut->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) );
392 memcpy(thisInjOut->next, thisInj, sizeof(*thisInj));
393 thisInjOut->next->next = NULL;
394 thisInjOut = thisInjOut->next;
395 }
396
398 }
399
401 }
402 else
403 {
404 fprintf( stderr, "Skipping injection at %d because it turns on at %f Hz, "
405 "but the low frequency cutoff is %f\n",
406 thisInj->geocent_end_time.gpsSeconds, startFreqHz, freqLowCutoff);
407 }
408 } /* loop over injectionsj */
409
410
411 /* write and free the output simInspiral table */
412 if ( simTableOut && fname ) {
416 }
417
418 while (simTableOut) {
419 thisInjOut = simTableOut;
420 simTableOut = simTableOut->next;
421 LALFree(thisInjOut);
422 }
423
425 RETURN(status);
426
427}
428
429
430/**
431 * Main function for injecting numetrical relativity waveforms.
432 * Takes as input a list of injections, and adds h(t) to a given
433 * timeseries for a specified ifo and a dynamic range factor.
434 */
435void InjectNumRelWaveforms (LALStatus *status, /**< pointer to LALStatus structure */
436 REAL4TimeSeries *chan, /**< [out] the output time series */
437 SimInspiralTable *injections, /**< [in] list of injections */
438 CHAR ifo[3], /**< [in] 2 char code for interferometer */
439 REAL8 dynRange, /**< [in] dynamic range factor for scaling time series */
440 REAL8 freqLowCutoff, /**< [in] Lower cutoff frequency */
441 REAL8 snrLow, /**< [in] lower cutoff value of snr */
442 REAL8 snrHigh, /**< TO BE DOCUMENTED */
443 CHAR *fname) /**< [in] higher cutoff value of snr */
444{
445
446 REAL4TimeVectorSeries *tempStrain=NULL;
448 REAL8 startFreq, startFreqHz, massTotal;
449 REAL8 thisSNR;
450 SimInspiralTable *simTableOut=NULL;
451 SimInspiralTable *thisInjOut=NULL;
452
457
458
459 /* loop over injections */
461 {
462
464 massTotal = (thisInj->mass1 + thisInj->mass2) * LAL_MTSUN_SI;
465 startFreqHz = startFreq / ( LAL_TWOPI * massTotal);
466
467 if (startFreqHz < freqLowCutoff)
468 {
470 status);
471 thisSNR = calculate_ligo_snr_from_strain( tempStrain, thisInj, ifo);
472
473 /* set channel name */
474 snprintf( chan->name, LALNameLength * sizeof( CHAR ),
475 "%s:STRAIN", ifo );
476
477 if ((thisSNR < snrHigh) && (thisSNR > snrLow))
478 {
479 /* simTableOut will be null only the first time */
480 if ( simTableOut == NULL) {
481 simTableOut = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) );
482 memcpy(simTableOut, thisInj, sizeof(*thisInj));
483 simTableOut->next = NULL;
484 thisInjOut = simTableOut;
485 }
486 else {
487 thisInjOut->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) );
488 memcpy(thisInjOut->next, thisInj, sizeof(*thisInj));
489 thisInjOut->next->next = NULL;
490 thisInjOut = thisInjOut->next;
491 }
492
493 TRY( LALInjectStrainGW( status->statusPtr, chan, tempStrain, thisInj,
494 ifo, dynRange), status);
495 }
496
498 tempStrain->data = NULL;
499 LALFree(tempStrain);
500 tempStrain = NULL;
501 }
502
503 } /* loop over injectionsj */
504
505
506 /* write and free the output simInspiral table */
507 if ( simTableOut ) {
508
510
511 /* write the xml table of actual injections */
515
516 }
517
518 while (simTableOut) {
519 thisInjOut = simTableOut;
520 simTableOut = simTableOut->next;
521 LALFree(thisInjOut);
522 }
523
525 RETURN(status);
526
527}
528
529/**
530 * Main function for injecting numetrical relativity waveforms.
531 * Takes as input a list of injections, and adds h(t) to a given
532 * timeseries for a specified ifo and a dynamic range factor.
533 */
534void InjectNumRelWaveformsREAL8 (LALStatus *status, /**< pointer to LALStatus structure */
535 REAL8TimeSeries *chan, /**< [out] the output time series */
536 SimInspiralTable *injections, /**< [in] list of injections */
537 CHAR ifo[3], /**< [in] 2 char code for interferometer */
538 REAL8 freqLowCutoff, /**< [in] Lower cutoff frequency */
539 REAL8 snrLow, /**< [in] lower cutoff value of snr */
540 REAL8 snrHigh, /**< TO BE DOCUMENTED */
541 CHAR *fname) /**< [in] higher cutoff value of snr */
542{
544 REAL8 startFreq, startFreqHz, massTotal;
545 REAL8 thisSNR;
546 SimInspiralTable *simTableOut=NULL;
547 SimInspiralTable *thisInjOut=NULL;
548
553
554
555 /* loop over injections */
557 {
558
560 massTotal = (thisInj->mass1 + thisInj->mass2) * LAL_MTSUN_SI;
561 startFreqHz = startFreq / ( LAL_TWOPI * massTotal);
562
563 if (startFreqHz < freqLowCutoff)
564 {
565 REAL8TimeSeries *strain = NULL;
568
569 /* set channel name */
570 snprintf( chan->name, LALNameLength * sizeof( CHAR ),
571 "%s:STRAIN", ifo );
572
573 if ((thisSNR < snrHigh) && (thisSNR > snrLow))
574 {
575 /* simTableOut will be null only the first time */
576 if ( simTableOut == NULL) {
577 simTableOut = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) );
578 memcpy(simTableOut, thisInj, sizeof(*thisInj));
579 simTableOut->next = NULL;
580 thisInjOut = simTableOut;
581 }
582 else {
583 thisInjOut->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) );
584 memcpy(thisInjOut->next, thisInj, sizeof(*thisInj));
585 thisInjOut->next->next = NULL;
586 thisInjOut = thisInjOut->next;
587 }
588
590 }
591
593 }
594 } /* loop over injectionsj */
595
596
597 /* write and free the output simInspiral table */
598 if ( simTableOut ) {
599
601
602 /* write the xml table of actual injections */
606
607 }
608
609 while (simTableOut) {
610 thisInjOut = simTableOut;
611 simTableOut = simTableOut->next;
612 LALFree(thisInjOut);
613 }
614
616 RETURN(status);
617
618}
619
621{
622
623 FrameH *frame=NULL;
624 FrFile *frFile=NULL;
625 FrHistory *frHist=NULL;
626 FrHistory *thisHist;
627 CHAR *comment=NULL;
628 CHAR *token=NULL;
629 REAL8 ret=0;
630 CHAR *path;
631
632 /* convert url to path by skipping protocol part of protocol:path */
633 path = strchr(url, ':');
634 if (path == NULL)
635 path = url;
636 else
637 path+=strlen("://localhost"); /* skip the '://localhost' -- now on the path */
638
639 frFile = FrFileINew( path );
640 frame = FrameRead (frFile);
641 frHist = frame->history;
642 thisHist = frHist;
643 while (thisHist) {
644
645 /* get history comment string and parse it */
646 comment = LALCalloc(1, (strlen(thisHist->comment)+1)*sizeof(CHAR));
647 strcpy(comment, thisHist->comment);
648
649 token = strtok(comment,":");
650
651 if (strstr(token,"freqStart22") || strstr(token,"freq_start_22")) {
652 token = strtok(NULL,":");
653 ret = atof(token);
654 }
655
657 comment = NULL;
658
659 thisHist = thisHist->next;
660 }
661
662 FrFileIEnd( frFile );
663 return ret;
664}
665
666
668 const CHAR ifo[3])
669{
670
671 REAL8 ret = -1, snrSq, freq, psdValue;
673 REAL8FFTPlan *pfwd;
675 UINT4 k;
676
677 /* create the time series */
678 deltaF = strain->deltaT * strain->data->length;
679 fftData = XLALCreateCOMPLEX16FrequencySeries( strain->name, &(strain->epoch),
681 strain->data->length/2 + 1 );
682
683 /* perform the fft */
684 pfwd = XLALCreateForwardREAL8FFTPlan( strain->data->length, 0 );
685 XLALREAL8TimeFreqFFT( fftData, strain, pfwd );
686
687 /* compute the SNR for initial LIGO at design */
688 for ( snrSq = 0, k = 0; k < fftData->data->length; k++ )
689 {
690 freq = fftData->deltaF * k;
691
692 if ( ifo[0] == 'V' )
693 {
694 if (freq < 35)
695 continue;
696
697 LALVIRGOPsd( NULL, &psdValue, freq );
698 psdValue /= 9e-46;
699 }
700 else
701 {
702 if (freq < 40)
703 continue;
704
705 LALLIGOIPsd( NULL, &psdValue, freq );
706 }
707
708 fftData->data->data[k] /= 3e-23;
709 snrSq += creal(fftData->data->data[k]) * creal(fftData->data->data[k]) / psdValue;
710 snrSq += cimag(fftData->data->data[k]) * cimag(fftData->data->data[k]) / psdValue;
711 }
712 snrSq *= 4*fftData->deltaF;
713
716
717 ret = sqrt(snrSq);
718 return ret;
719}
720
721
724 REAL8 startFreq,
725 const CHAR ifo[3])
726{
727
728 REAL8 ret = -1, snrSq, freq, psdValue;
730 REAL8FFTPlan *pfwd;
732 UINT4 k;
733
734 /* create the time series */
735 deltaF = strain->deltaT * strain->data->length;
736 fftData = XLALCreateCOMPLEX16FrequencySeries( strain->name, &(strain->epoch),
738 strain->data->length/2 + 1 );
739
740 /* perform the fft */
741 pfwd = XLALCreateForwardREAL8FFTPlan( strain->data->length, 0 );
742 XLALREAL8TimeFreqFFT( fftData, strain, pfwd );
743
744 /* The PSD, if provided, comes in as it was in the original file */
745 /* since we don't know deltaF until we get here. Interpolate now */
746 if ( psd )
747 {
749 }
750
751 /* compute the SNR for initial LIGO at design */
752 for ( snrSq = 0, k = 0; k < fftData->data->length; k++ )
753 {
754 freq = fftData->deltaF * k;
755
756 if ( psd )
757 {
758 if ( freq < startFreq || k > psd->data->length )
759 continue;
760 psdValue = psd->data->data[k];
761 psdValue /= 9e-46;
762 }
763 else if ( ifo[0] == 'V' )
764 {
765 if (freq < 35)
766 continue;
767 LALVIRGOPsd( NULL, &psdValue, freq );
768 psdValue /= 9e-46;
769 }
770 else
771 {
772 if (freq < 40)
773 continue;
774 LALLIGOIPsd( NULL, &psdValue, freq );
775 }
776
777 fftData->data->data[k] /= 3e-23;
778
779 snrSq += creal(fftData->data->data[k]) * creal(fftData->data->data[k]) / psdValue;
780 snrSq += cimag(fftData->data->data[k]) * cimag(fftData->data->data[k]) / psdValue;
781 }
782
783 snrSq *= 4*fftData->deltaF;
784
787
788 if ( psd )
790
791 ret = sqrt(snrSq);
792
793 printf("Obtained snr=%f\n", ret);
794 return ret;
795}
796
797
800 const CHAR ifo[3])
801{
802
803 REAL8 ret = -1, snrSq, freq, psdValue;
804 REAL8 sampleRate = 4096, deltaF;
805 REAL4TimeSeries *chan = NULL;
806 REAL4FFTPlan *pfwd;
808 UINT4 k;
809
810 /* create the time series */
812 deltaF = chan->deltaT * strain->data->vectorLength;
813 fftData = XLALCreateCOMPLEX8FrequencySeries( chan->name, &(chan->epoch),
815 chan->data->length/2 + 1 );
816
817 /* perform the fft */
818 pfwd = XLALCreateForwardREAL4FFTPlan( chan->data->length, 0 );
819 XLALREAL4TimeFreqFFT( fftData, chan, pfwd );
820
821 /* compute the SNR for initial LIGO at design */
822 for ( snrSq = 0, k = 0; k < fftData->data->length; k++ )
823 {
824 freq = fftData->deltaF * k;
825
826 if ( ifo[0] == 'V' )
827 {
828 if (freq < 35)
829 continue;
830
831 LALVIRGOPsd( NULL, &psdValue, freq );
832 psdValue /= 9e-46;
833 }
834 else
835 {
836 if (freq < 40)
837 continue;
838
839 LALLIGOIPsd( NULL, &psdValue, freq );
840 }
841
842 fftData->data->data[k] /= 3e-23;
843 snrSq += crealf(fftData->data->data[k]) * crealf(fftData->data->data[k]) / psdValue;
844 snrSq += cimagf(fftData->data->data[k]) * cimagf(fftData->data->data[k]) / psdValue;
845 }
846
847 snrSq *= 4*fftData->deltaF;
848
851
853 LALFree(chan);
854
855 ret = sqrt(snrSq);
856 return ret;
857}
858
859int
860XLALPsdFromFile(REAL8FrequencySeries **psd, /**< [out] The PSD */
861 const CHAR *filename) /**< [in] name of the file to be read */
862{
864 LALParsedDataFile *cfgdata=NULL;
865 LIGOTimeGPS stubEpoch;
866 UINT4 length, k, r;
867 REAL8 freq, value;
868 REAL8 step1=0, deltaF=0;
869 int retval;
870
871 /* XLALParseDataFile checks that filename is not null for us */
872 retval = XLALParseDataFile(&cfgdata, filename);
873 if ( retval != XLAL_SUCCESS ) {
874 XLAL_ERROR ( retval );
875 }
876
877 /*number of data points */
878 length = cfgdata->lines->nTokens;
879
880 /* allocate memory */
881 ret = XLALCreateREAL8FrequencySeries("PSD", &stubEpoch, 0, 0, &lalHertzUnit, length);
882 if (ret == NULL) {
883 XLALDestroyParsedDataFile( cfgdata );
884 XLALPrintError ("%s: XLALPsdFromFile() failed.\n", __func__ );
886 }
887
888 /* now get the data */
889 for (k = 0; k < length; k++) {
890 r = sscanf(cfgdata->lines->tokens[k], "%lf%lf", &freq, &value);
891
892 /* Check the data file format */
893 if ( r != 2 ) {
894 XLALDestroyParsedDataFile( cfgdata );
895 XLALPrintError ("%s: XLALPsdFromFile() failed on bad line in psd file.\n", __func__ );
897 }
898
899 if (deltaF == 0) {
900 if (step1 == 0) {
901 step1 = freq;
902 } else {
903 deltaF = (freq - step1);
904 ret->deltaF = deltaF;
905 }
906 }
907
908 ret->data->data[k] = value;
909 }
910
911 (*psd) = ret;
912
913 XLALDestroyParsedDataFile( cfgdata );
914
915 return XLAL_SUCCESS;
916}
917
918
919/**
920 * Function for interpolating PSD to a given sample rate
921 */
923XLALInterpolatePSD( REAL8FrequencySeries *in, /**< input strain time series */
924 REAL8 deltaFout /**< sample rate of time series */)
925{
926 REAL8FrequencySeries *ret=NULL;
927 REAL8 deltaFin, r, y_1, y_2;
928 UINT4 k, lo, numPoints;
929
930 deltaFin = in->deltaF;
931
932 /* length of output vector */
933 numPoints = (UINT4) (in->data->length * deltaFin / deltaFout);
934
935 /* allocate memory */
936 ret = LALCalloc(1, sizeof(*ret));
937 if (!ret)
938 {
940 }
941
943 if (! ret->data)
944 {
946 }
947
948 ret->deltaF = deltaFout;
949
950 /* copy values from in which should be the same */
951 ret->epoch = in->epoch;
952 ret->f0 = in->f0;
953 ret->sampleUnits = in->sampleUnits;
954 strcpy(ret->name, in->name);
955
956 /* go over points of output vector and interpolate linearly
957 using closest points of input */
958 for (k = 0; k < numPoints; k++) {
959 lo = (UINT4)( k*deltaFout / deltaFin);
960
961 /* y_1 and y_2 are the input values at x1 and x2 */
962 /* here we need to make sure that we don't exceed
963 bounds of input vector */
964 if ( lo < in->data->length - 1) {
965 y_1 = in->data->data[lo];
966 y_2 = in->data->data[lo+1];
967
968 /* we want to calculate y_2*r + y_1*(1-r) where
969 r = (x-x1)/(x2-x1) */
970 r = k*deltaFout / deltaFin - lo;
971
972 ret->data->data[k] = y_2 * r + y_1 * (1 - r);
973 }
974 else {
975 ret->data->data[k] = 0.0;
976 }
977 }
978
979 return ret;
980}
981
982
983void get_FakePsdFromString(REAL8FrequencySeries* PsdFreqSeries,char* FakePsdName, REAL8 StartFreq)
984{
985 /* Call XLALSimNoisePSD to fill the REAL8FrequencySeries PsdFreqSeries (must been already allocated by callers). FakePsdName contains the label of the fake PSD */
986 if (!strcmp("LALAdVirgo",FakePsdName))
987 {
988 XLALSimNoisePSD(PsdFreqSeries,StartFreq,XLALSimNoisePSDAdvVirgo);
989 }
990 else if (!strcmp("LALVirgo",FakePsdName))
991 {
992 XLALSimNoisePSD(PsdFreqSeries,StartFreq,XLALSimNoisePSDVirgo);
993 }
994 else if(!strcmp("LALAdLIGO",FakePsdName))
995 {
997 }
998 else if(!strcmp("LALLIGO",FakePsdName))
999 {
1000 XLALSimNoisePSD(PsdFreqSeries,StartFreq,XLALSimNoisePSDiLIGOSRD);
1001 }
1002 else
1003 {
1004 fprintf(stderr,"Unknown fake PSD %s. Known types are LALLIGO, LALAdLIGO, LALAdVirgo, LALVirgo. Exiting...\n",FakePsdName);
1005 exit(1);
1006 }
1007}
1008
1009
1011{
1012 /* Calculate and return the single IFO SNR
1013 *
1014 * Required options:
1015 *
1016 * inj: SimInspiralTable entry for which the SNR has to be calculated
1017 * IFOname: The canonical name (e.g. H1, L1, V1) name of the IFO for which the SNR must be calculated
1018 * PSD: PSD curve to be used for the overlap integrap
1019 * start_freq: lower cutoff of the overlap integral
1020 *
1021 * */
1022
1023 int ret=0;
1024 INT4 errnum=0;
1025 UINT4 j=0;
1026 /* Fill detector site info */
1027 LALDetector* detector=NULL;
1028 detector=calloc(1,sizeof(LALDetector));
1029 if(!strcmp(IFOname,"H1"))
1031 if(!strcmp(IFOname,"H2"))
1033 if(!strcmp(IFOname,"LLO")||!strcmp(IFOname,"L1"))
1035 if(!strcmp(IFOname,"V1")||!strcmp(IFOname,"VIRGO"))
1037
1040 LALSimulationDomain modelDomain;
1041
1044 else
1045 {
1046 fprintf(stderr,"ERROR. Unknown approximant number %i. Unable to choose time or frequency domain model.",approx);
1047 exit(1);
1048 }
1049
1050 REAL8 m1,m2, s1x,s1y,s1z,s2x,s2y,s2z,phi0,f_min,f_max,iota,polarization;
1051
1052 /* No tidal PN terms until injtable is able to get them */
1053
1054 LALDict *LALpars= XLALCreateDict();
1055
1056 /* Spin and tidal interactions at the highest level (default) until injtable stores them.
1057 * When spinO and tideO are added to injtable we can un-comment those lines and should be ok
1058 *
1059 int spinO = inj->spinO;
1060 int tideO = inj->tideO;
1061 XLALSimInspiralSetSpinOrder(waveFlags, *(LALSimInspiralSpinOrder*) spinO);
1062 XLALSimInspiralSetTidalOrder(waveFlags, *(LALSimInspiralTidalOrder*) tideO);
1063 */
1064
1067 /* Read parameters */
1068 m1=inj->mass1*LAL_MSUN_SI;
1069 m2=inj->mass2*LAL_MSUN_SI;
1070 s1x=inj->spin1x;
1071 s1y=inj->spin1y;
1072 s1z=inj->spin1z;
1073 s2x=inj->spin2x;
1074 s2y=inj->spin2y;
1075 s2z=inj->spin2z;
1076 iota=inj->inclination;
1078 phi0=inj->coa_phase;
1079 polarization=inj->polarization;
1080 REAL8 latitude=inj->latitude;
1082
1084 memcpy(&epoch,&(inj->geocent_end_time),sizeof(LIGOTimeGPS));
1085
1086 /* Hardcoded values of srate and segment length. If changed here they must also be changed in inspinj.c */
1087 REAL8 srate=4096.0;
1088 const CHAR *WF=inj->waveform;
1089 /* Increase srate for EOB WFs */
1090 if (strstr(WF,"EOB"))
1091 srate=8192.0;
1092 REAL8 segment=64.0;
1093
1094 f_max=(srate/2.0-(1.0/segment));
1095 size_t seglen=(size_t) segment*srate;
1096 REAL8 deltaF=1.0/segment;
1097 REAL8 deltaT=1.0/srate;
1098
1099 /* Frequency domain h+ and hx. They are going to be filled either by a FD WF or by the FFT of a TD WF*/
1100 COMPLEX16FrequencySeries *freqHplus;
1101 COMPLEX16FrequencySeries *freqHcross;
1102 freqHplus= XLALCreateCOMPLEX16FrequencySeries("fhplus",
1103 &epoch,
1104 0.0,
1105 deltaF,
1107 seglen/2+1
1108 );
1109
1110 freqHcross=XLALCreateCOMPLEX16FrequencySeries("fhcross",
1111 &epoch,
1112 0.0,
1113 deltaF,
1115 seglen/2+1
1116 );
1117
1118 /* If the approximant is on the FD call XLALSimInspiralChooseFDWaveform */
1119 if (modelDomain == LAL_SIM_DOMAIN_FREQUENCY)
1120 {
1121
1122 COMPLEX16FrequencySeries *hptilde=NULL;
1123 COMPLEX16FrequencySeries *hctilde=NULL;
1124 //We do not pass the polarization here, we assume it is taken into account when projecting h+,x onto the detector.
1125 XLAL_TRY(ret=XLALSimInspiralChooseFDWaveform(&hptilde,&hctilde, m1, m2,
1126 s1x, s1y, s1z, s2x, s2y, s2z,
1127 LAL_PC_SI * 1.0e6, iota, phi0, 0., 0., 0.,
1128 deltaF, f_min, 0.0, 0.0,
1129 LALpars,approx),errnum);
1130 XLALDestroyDict(LALpars);
1131
1132 if(!hptilde|| hptilde->data==NULL || hptilde->data->data==NULL ||!hctilde|| hctilde->data==NULL || hctilde->data->data==NULL)
1133 {
1134 XLALPrintError(" ERROR in XLALSimInspiralChooseFDWaveform(): error generating waveform. errnum=%d. Exiting...\n",errnum );
1135 exit(1);
1136 }
1137
1138 COMPLEX16 *dataPtr = hptilde->data->data;
1139 for (j=0; j<(UINT4) freqHplus->data->length; ++j)
1140 {
1141 if(j < hptilde->data->length)
1142 {
1143 freqHplus->data->data[j] = dataPtr[j];
1144 }
1145 else
1146 {
1147 freqHplus->data->data[j]=0.0 + I*0.0;
1148 }
1149 }
1150 dataPtr = hctilde->data->data;
1151 for (j=0; j<(UINT4) freqHplus->data->length; ++j)
1152 {
1153 if(j < hctilde->data->length)
1154 {
1155 freqHcross->data->data[j] = dataPtr[j];
1156 }
1157 else
1158 {
1159 freqHcross->data->data[j]=0.0+0.0*I;
1160 }
1161 }
1162 /* Clean */
1163 if(hptilde) XLALDestroyCOMPLEX16FrequencySeries(hptilde);
1164 if(hctilde) XLALDestroyCOMPLEX16FrequencySeries(hctilde);
1165
1166 }
1167 else
1168 {
1169
1170 /* Otherwise use XLALSimInspiralChooseTDWaveform */
1171 REAL8FFTPlan *timeToFreqFFTPlan = XLALCreateForwardREAL8FFTPlan((UINT4) seglen, 0 );
1172 REAL8TimeSeries *hplus=NULL;
1173 REAL8TimeSeries *hcross=NULL;
1174 REAL8TimeSeries *timeHplus=NULL;
1175 REAL8TimeSeries *timeHcross=NULL;
1176 REAL8 padding =0.4;//seconds
1178 REAL4 WinNorm = sqrt(window->sumofsquares/window->data->length);
1179 timeHcross=XLALCreateREAL8TimeSeries("timeModelhCross",
1180 &epoch,
1181 0.0,
1182 deltaT,
1184 seglen
1185 );
1186 timeHplus=XLALCreateREAL8TimeSeries("timeModelhplus",
1187 &epoch,
1188 0.0,
1189 deltaT,
1191 seglen
1192 );
1193 for (j=0;j<(UINT4) timeHcross->data->length;++j)
1194 timeHcross->data->data[j]=0.0;
1195 for (j=0;j<(UINT4) timeHplus->data->length;++j)
1196 timeHplus->data->data[j]=0.0;
1197 XLAL_TRY(ret=XLALSimInspiralChooseTDWaveform(&hplus, &hcross, m1, m2,
1198 s1x, s1y, s1z, s2x, s2y, s2z,
1199 LAL_PC_SI*1.0e6, iota,
1200 phi0, 0., 0., 0., deltaT, f_min, 0.,
1201 LALpars, approx),
1202 errnum);
1203
1204 if (ret == XLAL_FAILURE || hplus == NULL || hcross == NULL)
1205 {
1206 XLALPrintError(" ERROR in XLALSimInspiralChooseTDWaveform(): error generating waveform. errnum=%d. Exiting...\n",errnum );
1207 exit(1);
1208 }
1209
1210 hplus->epoch = timeHplus->epoch;
1211 hcross->epoch = timeHcross->epoch;
1212
1213 XLALSimAddInjectionREAL8TimeSeries(timeHplus, hplus, NULL);
1214 XLALSimAddInjectionREAL8TimeSeries(timeHcross, hcross, NULL);
1215 for (j=0; j<(UINT4) timeHplus->data->length; ++j)
1216 timeHplus->data->data[j]*=window->data->data[j];
1217 for (j=0; j<(UINT4) timeHcross->data->length; ++j)
1218 timeHcross->data->data[j]*=window->data->data[j];
1219
1220 for (j=0; j<(UINT4) freqHplus->data->length; ++j)
1221 {
1222 freqHplus->data->data[j]=0.0+I*0.0;
1223 freqHcross->data->data[j]=0.0+I*0.0;
1224 }
1225
1226 /* FFT into freqHplus and freqHcross */
1227 XLALREAL8TimeFreqFFT(freqHplus,timeHplus,timeToFreqFFTPlan);
1228 XLALREAL8TimeFreqFFT(freqHcross,timeHcross,timeToFreqFFTPlan);
1229 for (j=0; j<(UINT4) freqHplus->data->length; ++j)
1230 {
1231 freqHplus->data->data[j]/=WinNorm;
1232 freqHcross->data->data[j]/=WinNorm;
1233 }
1234 /* Clean... */
1235 if ( hplus ) XLALDestroyREAL8TimeSeries(hplus);
1236 if ( hcross ) XLALDestroyREAL8TimeSeries(hcross);
1237 if ( timeHplus ) XLALDestroyREAL8TimeSeries(timeHplus);
1238 if ( timeHcross ) XLALDestroyREAL8TimeSeries(timeHcross);
1239 if (timeToFreqFFTPlan) LALFree(timeToFreqFFTPlan);
1240 if (window) XLALDestroyREAL8Window(window);
1241 }
1242
1243 /* The WF has been generated and is in freqHplus/cross. Now project into the IFO frame */
1244 double Fplus, Fcross;
1245 double FplusScaled, FcrossScaled;
1246 double HSquared;
1247 double GPSdouble=(REAL8) inj->geocent_end_time.gpsSeconds+ (REAL8) inj->geocent_end_time.gpsNanoSeconds*1.0e-9;
1248 double gmst;
1249 LIGOTimeGPS GPSlal;
1250 XLALGPSSetREAL8(&GPSlal, GPSdouble);
1251 gmst=XLALGreenwichMeanSiderealTime(&GPSlal);
1252
1253 /* Fill Fplus and Fcross*/
1254 XLALComputeDetAMResponse(&Fplus, &Fcross, (const REAL4 (*)[3])detector->response,longitude, latitude, polarization, gmst);
1255 /* And take the distance into account */
1256 FplusScaled = Fplus / (inj->distance);
1257 FcrossScaled = Fcross / (inj->distance);
1258
1259 REAL8 timedelay = XLALTimeDelayFromEarthCenter(detector->location,longitude, latitude, &GPSlal);
1260 REAL8 timeshift = timedelay;
1261 REAL8 twopit = LAL_TWOPI * timeshift;
1262
1263 UINT4 lower = (UINT4)ceil(start_freq / deltaF);
1264 UINT4 upper = (UINT4)floor(f_max / deltaF);
1265 REAL8 re = cos(twopit*deltaF*lower);
1266 REAL8 im = -sin(twopit*deltaF*lower);
1267
1268 /* Incremental values, using cos(theta) - 1 = -2*sin(theta/2)^2 */
1269 REAL8 dim = -sin(twopit*deltaF);
1270 REAL8 dre = -2.0*sin(0.5*twopit*deltaF)*sin(0.5*twopit*deltaF);
1271 REAL8 TwoDeltaToverN = 2.0 *deltaT / ((double) seglen);
1272
1273 REAL8 plainTemplateReal, plainTemplateImag,templateReal,templateImag;
1274 REAL8 newRe, newIm,temp;
1275 REAL8 this_snr=0.0;
1276 if ( psd )
1277 {
1279 }
1280 for (j=lower; j<=(UINT4) upper; ++j)
1281 {
1282 /* derive template (involving location/orientation parameters) from given plus/cross waveforms: */
1283 plainTemplateReal = FplusScaled * creal(freqHplus->data->data[j])
1284 + FcrossScaled *creal(freqHcross->data->data[j]);
1285 plainTemplateImag = FplusScaled * cimag(freqHplus->data->data[j])
1286 + FcrossScaled * cimag(freqHcross->data->data[j]);
1287
1288 /* do time-shifting... */
1289 /* (also un-do 1/deltaT scaling): */
1290 templateReal = (plainTemplateReal*re - plainTemplateImag*im) / deltaT;
1291 templateImag = (plainTemplateReal*im + plainTemplateImag*re) / deltaT;
1292 HSquared = templateReal*templateReal + templateImag*templateImag ;
1293 temp = ((TwoDeltaToverN * HSquared) / psd->data->data[j]);
1294 this_snr += temp;
1295 /* Now update re and im for the next iteration. */
1296 newRe = re + re*dre - im*dim;
1297 newIm = im + re*dim + im*dre;
1298
1299 re = newRe;
1300 im = newIm;
1301 }
1302
1303 /* Clean */
1304 if (freqHcross) XLALDestroyCOMPLEX16FrequencySeries(freqHcross);
1305 if (freqHplus) XLALDestroyCOMPLEX16FrequencySeries(freqHplus);
1306 if (detector) free(detector);
1307
1308 return sqrt(this_snr*2.0);
1309
1310}
#define __func__
LALDetectorIndexLLODIFF
LALDetectorIndexVIRGODIFF
LALDetectorIndexLHODIFF
void XLALDestroyDict(LALDict *dict)
LALDict * XLALCreateDict(void)
#define LAL_CALL(function, statusptr)
int j
int k
void LALInspiralParameterCalc(LALStatus *status, InspiralTemplate *params)
void LALInspiralWave(LALStatus *status, REAL4Vector *signalvec, InspiralTemplate *params)
#define LALCalloc(m, n)
#define LALFree(p)
int XLALGetOrderFromString(const char *waveform)
int XLALGetApproximantFromString(const char *waveform)
REAL8 XLALSimInspiralfLow2fStart(REAL8 fLow, INT4 ampOrder, INT4 approximant)
int XLALSimInspiralImplementedFDApproximants(Approximant approximant)
int XLALSimInspiralImplementedTDApproximants(Approximant approximant)
int XLALSimInspiralWaveformParamsInsertPNPhaseOrder(LALDict *params, INT4 value)
INT4 XLALSimInspiralWaveformParamsLookupPNAmplitudeOrder(LALDict *params)
int XLALSimInspiralWaveformParamsInsertPNAmplitudeOrder(LALDict *params, INT4 value)
#define TRY(func, statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int XLALCloseLIGOLwXMLFile(LIGOLwXMLStream *xml)
LIGOLwXMLStream * XLALOpenLIGOLwXMLFile(const char *path)
int XLALWriteLIGOLwXMLSimInspiralTable(LIGOLwXMLStream *, const SimInspiralTable *)
#define fprintf
double e
REAL8 dynRange
Definition: blindinj.c:122
INT4 sampleRate
Definition: blindinj.c:124
const char * detector
sigmaKerr data[0]
void XLALDestroyREAL4VectorSequence(REAL4VectorSequence *vecseq)
REAL4VectorSequence * XLALCreateREAL4VectorSequence(UINT4 length, UINT4 veclen)
int XLALParseDataFile(LALParsedDataFile **cfgdata, const CHAR *fname)
void XLALDestroyParsedDataFile(LALParsedDataFile *cfgdata)
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 XLALDestroyREAL8FrequencySeries(REAL8FrequencySeries *series)
void XLALDestroyCOMPLEX16FrequencySeries(COMPLEX16FrequencySeries *series)
#define LAL_MSUN_SI
#define LAL_PI
#define LAL_TWOPI
#define LAL_MTSUN_SI
#define LAL_PC_SI
#define LAL_MRSUN_SI
double complex COMPLEX16
double REAL8
#define XLAL_INIT_DECL(var,...)
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
LALNameLength
int XLALFrStreamClose(LALFrStream *stream)
LALFrStream * XLALFrStreamCacheOpen(LALCache *cache)
int XLALFrStreamRewind(LALFrStream *stream)
int XLALFrStreamGetREAL4TimeSeries(REAL4TimeSeries *series, LALFrStream *stream)
int XLALFrStreamGetVectorLength(const char *chname, LALFrStream *stream)
m1Andm2
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)
LALSimulationDomain
Approximant
LAL_SIM_DOMAIN_TIME
LAL_SIM_DOMAIN_FREQUENCY
TaylorF2
LAL_PNORDER_PSEUDO_FOUR
double XLALSimNoisePSDaLIGOZeroDetHighPower(double f)
int XLALSimNoisePSD(REAL8FrequencySeries *psd, double flow, double(*psdfunc)(double))
double XLALSimNoisePSDAdvVirgo(double f)
double XLALSimNoisePSDiLIGOSRD(double f)
double XLALSimNoisePSDVirgo(double f)
int XLALSimAddInjectionREAL8TimeSeries(REAL8TimeSeries *target, REAL8TimeSeries *h, const COMPLEX16FrequencySeries *response)
REAL4TimeSeries * XLALCalculateNRStrain(REAL4TimeVectorSeries *strain, SimInspiralTable *thisInj, const CHAR *ifo, INT4 sampleRate)
INT4 XLALOrientNRWave(REAL4TimeVectorSeries *strain, UINT4 modeL, INT4 modeM, REAL4 inclination, REAL4 coa_phase)
CHAR * XLALGetNinjaChannelName(const CHAR *polarisation, UINT4 l, INT4 m)
REAL4TimeVectorSeries * XLALSumStrain(REAL4TimeVectorSeries *tempstrain, REAL4TimeVectorSeries *strain)
void LALInjectStrainGW(LALStatus *status, REAL4TimeSeries *injData, REAL4TimeVectorSeries *strain, SimInspiralTable *thisInj, CHAR *ifo, REAL8 dynRange)
static const INT4 r
static const INT4 a
void XLALDestroyREAL8FFTPlan(REAL8FFTPlan *plan)
REAL4FFTPlan * XLALCreateForwardREAL4FFTPlan(UINT4 size, int measurelvl)
void XLALDestroyREAL4FFTPlan(REAL4FFTPlan *plan)
REAL8FFTPlan * XLALCreateForwardREAL8FFTPlan(UINT4 size, int measurelvl)
int XLALREAL4ForwardFFT(COMPLEX8Vector *output, const REAL4Vector *input, const REAL4FFTPlan *plan)
REAL8 XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
int XLALREAL8TimeFreqFFT(COMPLEX16FrequencySeries *freq, const REAL8TimeSeries *tser, const REAL8FFTPlan *plan)
int XLALREAL4TimeFreqFFT(COMPLEX8FrequencySeries *freq, const REAL4TimeSeries *tser, const REAL4FFTPlan *plan)
REAL4TimeSeries * XLALCreateREAL4TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, 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)
const LALUnit lalStrainUnit
const LALUnit lalHertzUnit
const LALUnit lalDimensionlessUnit
REAL4Vector * XLALCreateREAL4Vector(UINT4 length)
void XLALDestroyREAL4Vector(REAL4Vector *vector)
COMPLEX8Vector * XLALCreateCOMPLEX8Vector(UINT4 length)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyCOMPLEX8Vector(COMPLEX8Vector *vector)
REAL8Window * XLALCreateTukeyREAL8Window(UINT4 length, REAL8 beta)
void XLALDestroyREAL8Window(REAL8Window *window)
#define XLAL_ERROR_NULL(...)
#define XLAL_ERROR(...)
#define XLAL_TRY(statement, errnum)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int XLALClearErrno(void)
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFUNC
XLAL_FAILURE
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
char * ifo
Definition: gwf2xml.c:57
SimInspiralTable * thisInj
Definition: inspfrinj.c:340
CHAR comment[LIGOMETA_COMMENT_MAX]
Definition: inspfrinj.c:350
SimInspiralTable * injections
Definition: inspfrinj.c:339
REAL4 longitude
Definition: inspinj.c:520
static LALStatus status
Definition: inspinj.c:552
int i
Definition: inspinj.c:596
REAL4 latitude
Definition: inspinj.c:521
#define INSPIRALH_MSGENULL
Definition: inspiral.h:60
#define INSPIRALH_ENULL
Definition: inspiral.h:54
REAL8TimeSeries * XLALNRInjectionStrain(const char *ifo, SimInspiralTable *inj)
REAL8 calculate_lalsim_snr(SimInspiralTable *inj, char *IFOname, REAL8FrequencySeries *psd, REAL8 start_freq)
REAL8 calculate_snr_from_strain_and_psd_real8(REAL8TimeSeries *strain, REAL8FrequencySeries *psd, REAL8 startFreq, const CHAR ifo[3])
int XLALPsdFromFile(REAL8FrequencySeries **psd, const CHAR *filename)
void get_FakePsdFromString(REAL8FrequencySeries *PsdFreqSeries, char *FakePsdName, REAL8 StartFreq)
void InjectNumRelWaveformsREAL8(LALStatus *status, REAL8TimeSeries *chan, SimInspiralTable *injections, CHAR ifo[3], REAL8 freqLowCutoff, REAL8 snrLow, REAL8 snrHigh, CHAR *fname)
Main function for injecting numetrical relativity waveforms.
REAL8 calculate_ligo_snr_from_strain_real8(REAL8TimeSeries *strain, const CHAR ifo[3])
REAL8 calculate_ligo_snr_from_strain(REAL4TimeVectorSeries *strain, SimInspiralTable *thisInj, const CHAR ifo[3])
REAL4 XLALCandleDistanceTD(Approximant approximant, REAL4 candleM1, REAL4 candleM2, REAL4 candlesnr, REAL8 chanDeltaT, INT4 nPoints, REAL8FrequencySeries *spec, UINT4 cut)
void AddNumRelStrainModes(LALStatus *status, REAL4TimeVectorSeries **outStrain, SimInspiralTable *thisinj)
REAL4 compute_candle_distance(REAL4 candleM1, REAL4 candleM2, REAL4 thissnr, REAL8 chanDeltaT, INT4 nPoints, REAL8FrequencySeries *spec, UINT4 cut)
Definition: inspiralutils.c:84
void InjectNumRelWaveforms(LALStatus *status, REAL4TimeSeries *chan, SimInspiralTable *injections, CHAR ifo[3], REAL8 dynRange, REAL8 freqLowCutoff, REAL8 snrLow, REAL8 snrHigh, CHAR *fname)
Main function for injecting numetrical relativity waveforms.
REAL8 start_freq_from_frame_url(CHAR *url)
void InjectNumRelWaveformsUsingPSDREAL8(LALStatus *status, REAL8TimeSeries *chan, SimInspiralTable *injections, CHAR ifo[3], REAL8 freqLowCutoff, REAL8 snrLow, REAL8 snrHigh, REAL8FrequencySeries *ligoPSD, REAL8 ligoSnrLowFreq, REAL8FrequencySeries *virgoPSD, REAL8 virgoSnrLowFreq, CHAR *fname)
Main function for injecting numetrical relativity waveforms.
REAL8FrequencySeries * XLALInterpolatePSD(REAL8FrequencySeries *in, REAL8 deltaFout)
Function for interpolating PSD to a given sample rate.
list mu
temp
f
s1z
m2
s2x
s2y
s2z
s1y
m1
s1x
waveform
path
string url
seglen
approx
psd
int deltaF
strain
phi0
float freq
LIGOLwXMLStream * xmlfp
Definition: spininj.c:210
CHAR fname[256]
Definition: spininj.c:211
COMPLEX16Sequence * data
COMPLEX16 * data
COMPLEX8Sequence * data
COMPLEX8 * data
Approximant approximant
LALPNOrder order
InputMasses massChoice
CHAR * url
UINT4 length
LALCacheEntry * list
TokenList * lines
struct tagLALStatus * statusPtr
INT4 gpsNanoSeconds
CHAR name[LALNameLength]
REAL4Sequence * data
LALUnit sampleUnits
LIGOTimeGPS epoch
REAL4VectorSequence * data
REAL4 * data
REAL8Sequence * data
CHAR name[LALNameLength]
REAL8Sequence * data
LIGOTimeGPS epoch
CHAR name[LALNameLength]
REAL8 * data
REAL8Sequence * data
REAL8 sumofsquares
LIGOTimeGPS geocent_end_time
struct tagSimInspiralTable * next
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
CHAR numrel_data[LIGOMETA_STRING_MAX]
CHAR ** tokens
UINT4 nTokens
enum @1 epoch
Approximant approximant
Definition: tmpltbank.c:445
INT4 numPoints
Definition: tmpltbank.c:399
double f_min
double deltaT
double f_max
double srate