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>
66#include <lal/FindChirp.h>
67#include <lal/LALDict.h>
68#include <lal/LALNoiseModels.h>
70#include <lal/LALSimulation.h>
71#include <lal/LALSimNoise.h>
72#include <lal/LALInspiral.h>
91 REAL8 negativeSevenOverThree = -7.0/3.0;
92 REAL8 totalMass = candleM1 + candleM2;
93 REAL8 mu = candleM1 * candleM2 / totalMass;
95 REAL8 a = sqrt( (5.0 *
mu) / 96.0 ) *
98 REAL8 sigmaSq = 4.0 * ( chanDeltaT / (
REAL8) nPoints ) *
99 distNorm * distNorm *
a *
a;
103 for (
k = cut,
f = spec->
deltaF * cut;
108 pow( (
REAL8)
k / (
REAL8) nPoints, negativeSevenOverThree )
112 sigmaSq *= sigmaSqSum;
114 distance = sqrt( sigmaSq ) / thissnr;
135 REAL4FFTPlan *fwdPlan = NULL;
141 memset( &tmplt, 0,
sizeof(tmplt) );
149 tmplt.
mass1 = candleM1;
150 tmplt.
mass2 = candleM2;
169 for (
i = cut;
i < waveFFT->
length;
i++ )
171 sigmaSq += ( crealf(waveFFT->
data[
i]) * crealf(waveFFT->
data[
i])
175 sigmaSq *= 4.0 * chanDeltaT / (
REAL8)nPoints;
178 distance = sqrt( sigmaSq ) / (
REAL8)candlesnr;
185 return (
REAL4)distance;
193 INT4 modeL, modeM, modeLlo, modeLhi;
194 INT4 len, lenPlus, lenCross,
k;
195 CHAR *channel_name_plus;
196 CHAR *channel_name_cross;
223 epoch.gpsSeconds = 0;
224 epoch.gpsNanoSeconds = 0;
227 for ( modeL = modeLlo; modeL <= modeLhi; modeL++ ) {
230 for ( modeM = -modeL; modeM <= modeL; modeM++ ) {
243 if ( (lenPlus <= 0) || (lenCross <= 0) || (lenPlus != lenCross) ) {
268 tempStrain =
LALCalloc(1,
sizeof(*tempStrain));
271 tempStrain->
f0 = seriesPlus->
f0;
276 for (
k = 0;
k < len;
k++) {
288 if (sumStrain == NULL) {
290 sumStrain =
LALCalloc(1,
sizeof(*sumStrain));
293 sumStrain->
f0 = tempStrain->
f0;
305 if (tempStrain->
data != NULL) {
315 *outStrain = sumStrain;
336 REAL8 ligoSnrLowFreq,
338 REAL8 virgoSnrLowFreq,
342 REAL8 startFreq, startFreqHz, massTotal;
359 startFreqHz = startFreq / (
LAL_TWOPI * massTotal);
361 if (startFreqHz < freqLowCutoff)
375 printf(
"Injection at %d.%d in ifo %s has SNR %f\n",
381 if ((thisSNR < snrHigh) && (thisSNR > snrLow))
384 if ( simTableOut == NULL) {
387 simTableOut->
next = NULL;
388 thisInjOut = simTableOut;
393 thisInjOut->
next->next = NULL;
394 thisInjOut = thisInjOut->
next;
404 fprintf( stderr,
"Skipping injection at %d because it turns on at %f Hz, "
405 "but the low frequency cutoff is %f\n",
412 if ( simTableOut &&
fname ) {
418 while (simTableOut) {
419 thisInjOut = simTableOut;
420 simTableOut = simTableOut->
next;
448 REAL8 startFreq, startFreqHz, massTotal;
465 startFreqHz = startFreq / (
LAL_TWOPI * massTotal);
467 if (startFreqHz < freqLowCutoff)
477 if ((thisSNR < snrHigh) && (thisSNR > snrLow))
480 if ( simTableOut == NULL) {
483 simTableOut->
next = NULL;
484 thisInjOut = simTableOut;
489 thisInjOut->
next->next = NULL;
490 thisInjOut = thisInjOut->
next;
498 tempStrain->
data = NULL;
518 while (simTableOut) {
519 thisInjOut = simTableOut;
520 simTableOut = simTableOut->
next;
544 REAL8 startFreq, startFreqHz, massTotal;
561 startFreqHz = startFreq / (
LAL_TWOPI * massTotal);
563 if (startFreqHz < freqLowCutoff)
573 if ((thisSNR < snrHigh) && (thisSNR > snrLow))
576 if ( simTableOut == NULL) {
579 simTableOut->
next = NULL;
580 thisInjOut = simTableOut;
585 thisInjOut->
next->next = NULL;
586 thisInjOut = thisInjOut->
next;
609 while (simTableOut) {
610 thisInjOut = simTableOut;
611 simTableOut = simTableOut->
next;
625 FrHistory *frHist=NULL;
637 path+=strlen(
"://localhost");
639 frFile = FrFileINew(
path );
640 frame = FrameRead (frFile);
641 frHist = frame->history;
647 strcpy(
comment, thisHist->comment);
651 if (strstr(token,
"freqStart22") || strstr(token,
"freq_start_22")) {
652 token = strtok(NULL,
":");
659 thisHist = thisHist->next;
662 FrFileIEnd( frFile );
681 strain->data->length/2 + 1 );
712 snrSq *= 4*fftData->
deltaF;
738 strain->data->length/2 + 1 );
758 if ( freq < startFreq || k >
psd->data->length )
760 psdValue =
psd->data->data[
k];
763 else if (
ifo[0] ==
'V' )
783 snrSq *= 4*fftData->
deltaF;
793 printf(
"Obtained snr=%f\n", ret);
847 snrSq *= 4*fftData->
deltaF;
889 for (
k = 0;
k < length;
k++) {
927 REAL8 deltaFin,
r, y_1, y_2;
959 lo = (
UINT4)(
k*deltaFout / deltaFin);
964 if ( lo < in->
data->length - 1) {
970 r =
k*deltaFout / deltaFin - lo;
986 if (!strcmp(
"LALAdVirgo",FakePsdName))
990 else if (!strcmp(
"LALVirgo",FakePsdName))
994 else if(!strcmp(
"LALAdLIGO",FakePsdName))
998 else if(!strcmp(
"LALLIGO",FakePsdName))
1004 fprintf(stderr,
"Unknown fake PSD %s. Known types are LALLIGO, LALAdLIGO, LALAdVirgo, LALVirgo. Exiting...\n",FakePsdName);
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"))
1046 fprintf(stderr,
"ERROR. Unknown approximant number %i. Unable to choose time or frequency domain model.",
approx);
1050 REAL8 m1,
m2,
s1x,
s1y,
s1z,
s2x,
s2y,
s2z,
phi0,
f_min,
f_max,iota,polarization;
1090 if (strstr(WF,
"EOB"))
1132 if(!hptilde|| hptilde->
data==NULL || hptilde->
data->
data==NULL ||!hctilde|| hctilde->
data==NULL || hctilde->
data->
data==NULL)
1134 XLALPrintError(
" ERROR in XLALSimInspiralChooseFDWaveform(): error generating waveform. errnum=%d. Exiting...\n",errnum );
1141 if(j < hptilde->
data->length)
1153 if(j < hctilde->
data->length)
1204 if (ret ==
XLAL_FAILURE || hplus == NULL || hcross == NULL)
1206 XLALPrintError(
" ERROR in XLALSimInspiralChooseTDWaveform(): error generating waveform. errnum=%d. Exiting...\n",errnum );
1239 if (timeToFreqFFTPlan)
LALFree(timeToFreqFFTPlan);
1244 double Fplus, Fcross;
1245 double FplusScaled, FcrossScaled;
1256 FplusScaled = Fplus / (inj->
distance);
1257 FcrossScaled = Fcross / (inj->
distance);
1260 REAL8 timeshift = timedelay;
1273 REAL8 plainTemplateReal, plainTemplateImag,templateReal,templateImag;
1280 for (
j=lower;
j<=(
UINT4) upper; ++
j)
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]);
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]);
1296 newRe = re + re*dre - im*dim;
1297 newIm = im + re*dim + im*dre;
1308 return sqrt(this_snr*2.0);
LALDetectorIndexVIRGODIFF
void XLALDestroyDict(LALDict *dict)
LALDict * XLALCreateDict(void)
#define LAL_CALL(function, statusptr)
void LALInspiralParameterCalc(LALStatus *status, InspiralTemplate *params)
void LALInspiralWave(LALStatus *status, REAL4Vector *signalvec, InspiralTemplate *params)
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)
#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 *)
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 XLAL_INIT_DECL(var,...)
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)
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)
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)
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_TRY(statement, errnum)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
SimInspiralTable * thisInj
CHAR comment[LIGOMETA_COMMENT_MAX]
SimInspiralTable * injections
#define INSPIRALH_MSGENULL
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)
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.
struct tagLALStatus * statusPtr
REAL4VectorSequence * data
LIGOTimeGPS geocent_end_time
struct tagSimInspiralTable * next
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
CHAR numrel_data[LIGOMETA_STRING_MAX]