void XLALSimInjectNinjaSignals( REAL4TimeSeries* chan, const char *ifo, REAL8 dynRange, SimInspiralTable* events ) { /* New REAL8, NINJA-2 code */ UINT4 j; SimInspiralTable *thisInj = NULL; REAL8TimeSeries *tempStrain = NULL; REAL8TimeSeries *tempChan = NULL; /* Make a REAL8 version of the channel data */ /* so we can call Jolien's new inject function */ tempChan = XLALCreateREAL8TimeSeries( chan->name, &(chan->epoch), chan->f0, chan->deltaT, &(chan->sampleUnits), chan->data->length); for ( j = 0 ; j < tempChan->data->length ; ++j ) { tempChan->data->data[j] = (REAL8) ( chan->data->data[j] ); } /* loop over injections */ for ( thisInj = events; thisInj; thisInj = thisInj->next ) { tempStrain = XLALNRInjectionStrain(ifo, thisInj); for ( j = 0 ; j < tempStrain->data->length ; ++j ) { tempStrain->data->data[j] *= dynRange; } XLALSimAddInjectionREAL8TimeSeries( tempChan, tempStrain, NULL); XLALDestroyREAL8TimeSeries(tempStrain); } /* loop over injections */ /* Back to REAL4 */ for ( j = 0 ; j < tempChan->data->length ; ++j ) { chan->data->data[j] = (REAL4) ( tempChan->data->data[j] ); } XLALDestroyREAL8TimeSeries(tempChan); }
/** * Main function for injecting numetrical relativity waveforms. * Takes as input a list of injections, and adds h(t) to a given * timeseries for a specified ifo and a dynamic range factor. */ void InjectNumRelWaveformsREAL8 (LALStatus *status, /**< pointer to LALStatus structure */ REAL8TimeSeries *chan, /**< [out] the output time series */ SimInspiralTable *injections, /**< [in] list of injections */ CHAR ifo[3], /**< [in] 2 char code for interferometer */ REAL8 freqLowCutoff, /**< [in] Lower cutoff frequency */ REAL8 snrLow, /**< [in] lower cutoff value of snr */ REAL8 snrHigh, /**< TO BE DOCUMENTED */ CHAR *fname) /**< [in] higher cutoff value of snr */ { SimInspiralTable *thisInj = NULL; REAL8 startFreq, startFreqHz, massTotal; REAL8 thisSNR; SimInspiralTable *simTableOut=NULL; SimInspiralTable *thisInjOut=NULL; INITSTATUS(status); ATTATCHSTATUSPTR (status); ASSERT( chan, status, INSPIRALH_ENULL, INSPIRALH_MSGENULL ); ASSERT( ifo, status, INSPIRALH_ENULL, INSPIRALH_MSGENULL ); /* loop over injections */ for ( thisInj = injections; thisInj; thisInj = thisInj->next ) { startFreq = start_freq_from_frame_url(thisInj->numrel_data); massTotal = (thisInj->mass1 + thisInj->mass2) * LAL_MTSUN_SI; startFreqHz = startFreq / ( LAL_TWOPI * massTotal); if (startFreqHz < freqLowCutoff) { REAL8TimeSeries *strain = NULL; strain = XLALNRInjectionStrain(ifo, thisInj); thisSNR = calculate_ligo_snr_from_strain_real8(strain, ifo); /* set channel name */ snprintf( chan->name, LALNameLength * sizeof( CHAR ), "%s:STRAIN", ifo ); if ((thisSNR < snrHigh) && (thisSNR > snrLow)) { /* simTableOut will be null only the first time */ if ( simTableOut == NULL) { simTableOut = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); memcpy(simTableOut, thisInj, sizeof(*thisInj)); simTableOut->next = NULL; thisInjOut = simTableOut; } else { thisInjOut->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); memcpy(thisInjOut->next, thisInj, sizeof(*thisInj)); thisInjOut->next->next = NULL; thisInjOut = thisInjOut->next; } XLALSimAddInjectionREAL8TimeSeries( chan, strain, NULL); } XLALDestroyREAL8TimeSeries (strain); } } /* loop over injectionsj */ /* write and free the output simInspiral table */ if ( simTableOut ) { LIGOLwXMLStream xmlfp; MetadataTable dummyTable; dummyTable.simInspiralTable = simTableOut; /* write the xml table of actual injections */ memset( &xmlfp, 0, sizeof(LIGOLwXMLStream) ); TRY( LALOpenLIGOLwXMLFile( status->statusPtr, &xmlfp, fname ), status ); TRY( LALBeginLIGOLwXMLTable( status->statusPtr, &xmlfp, sim_inspiral_table ), status ); TRY( LALWriteLIGOLwXMLTable( status->statusPtr, &xmlfp, dummyTable, sim_inspiral_table ), status ); TRY( LALEndLIGOLwXMLTable ( status->statusPtr, &xmlfp ), status ); TRY( LALCloseLIGOLwXMLFile ( status->statusPtr, &xmlfp ), status ); } while (simTableOut) { thisInjOut = simTableOut; simTableOut = simTableOut->next; LALFree(thisInjOut); } DETATCHSTATUSPTR(status); RETURN(status); }
REAL8 calculate_lalsim_snr(SimInspiralTable *inj, char *IFOname, REAL8FrequencySeries *psd, REAL8 start_freq) { /* Calculate and return the single IFO SNR * * Required options: * * inj: SimInspiralTable entry for which the SNR has to be calculated * IFOname: The canonical name (e.g. H1, L1, V1) name of the IFO for which the SNR must be calculated * PSD: PSD curve to be used for the overlap integrap * start_freq: lower cutoff of the overlap integral * * */ int ret=0; INT4 errnum=0; UINT4 j=0; /* Fill detector site info */ LALDetector* detector=NULL; detector=calloc(1,sizeof(LALDetector)); if(!strcmp(IFOname,"H1")) memcpy(detector,&lalCachedDetectors[LALDetectorIndexLHODIFF],sizeof(LALDetector)); if(!strcmp(IFOname,"H2")) memcpy(detector,&lalCachedDetectors[LALDetectorIndexLHODIFF],sizeof(LALDetector)); if(!strcmp(IFOname,"LLO")||!strcmp(IFOname,"L1")) memcpy(detector,&lalCachedDetectors[LALDetectorIndexLLODIFF],sizeof(LALDetector)); if(!strcmp(IFOname,"V1")||!strcmp(IFOname,"VIRGO")) memcpy(detector,&lalCachedDetectors[LALDetectorIndexVIRGODIFF],sizeof(LALDetector)); Approximant approx=TaylorF2; approx=XLALGetApproximantFromString(inj->waveform); LALSimulationDomain modelDomain; if(XLALSimInspiralImplementedFDApproximants(approx)) modelDomain = LAL_SIM_DOMAIN_FREQUENCY; else if(XLALSimInspiralImplementedTDApproximants(approx)) modelDomain = LAL_SIM_DOMAIN_TIME; else { fprintf(stderr,"ERROR. Unknown approximant number %i. Unable to choose time or frequency domain model.",approx); exit(1); } REAL8 m1,m2, s1x,s1y,s1z,s2x,s2y,s2z,phi0,f_min,f_max,iota,polarization; /* No tidal PN terms until injtable is able to get them */ LALDict *LALpars= XLALCreateDict(); /* Spin and tidal interactions at the highest level (default) until injtable stores them. * When spinO and tideO are added to injtable we can un-comment those lines and should be ok * int spinO = inj->spinO; int tideO = inj->tideO; XLALSimInspiralSetSpinOrder(waveFlags, *(LALSimInspiralSpinOrder*) spinO); XLALSimInspiralSetTidalOrder(waveFlags, *(LALSimInspiralTidalOrder*) tideO); */ XLALSimInspiralWaveformParamsInsertPNPhaseOrder(LALpars,XLALGetOrderFromString(inj->waveform)); XLALSimInspiralWaveformParamsInsertPNAmplitudeOrder(LALpars,inj->amp_order); /* Read parameters */ m1=inj->mass1*LAL_MSUN_SI; m2=inj->mass2*LAL_MSUN_SI; s1x=inj->spin1x; s1y=inj->spin1y; s1z=inj->spin1z; s2x=inj->spin2x; s2y=inj->spin2y; s2z=inj->spin2z; iota=inj->inclination; f_min=XLALSimInspiralfLow2fStart(inj->f_lower,XLALSimInspiralWaveformParamsLookupPNAmplitudeOrder(LALpars),XLALGetApproximantFromString(inj->waveform)); phi0=inj->coa_phase; polarization=inj->polarization; REAL8 latitude=inj->latitude; REAL8 longitude=inj->longitude; LIGOTimeGPS epoch; memcpy(&epoch,&(inj->geocent_end_time),sizeof(LIGOTimeGPS)); /* Hardcoded values of srate and segment length. If changed here they must also be changed in inspinj.c */ REAL8 srate=4096.0; const CHAR *WF=inj->waveform; /* Increase srate for EOB WFs */ if (strstr(WF,"EOB")) srate=8192.0; REAL8 segment=64.0; f_max=(srate/2.0-(1.0/segment)); size_t seglen=(size_t) segment*srate; REAL8 deltaF=1.0/segment; REAL8 deltaT=1.0/srate; /* Frequency domain h+ and hx. They are going to be filled either by a FD WF or by the FFT of a TD WF*/ COMPLEX16FrequencySeries *freqHplus; COMPLEX16FrequencySeries *freqHcross; freqHplus= XLALCreateCOMPLEX16FrequencySeries("fhplus", &epoch, 0.0, deltaF, &lalDimensionlessUnit, seglen/2+1 ); freqHcross=XLALCreateCOMPLEX16FrequencySeries("fhcross", &epoch, 0.0, deltaF, &lalDimensionlessUnit, seglen/2+1 ); /* If the approximant is on the FD call XLALSimInspiralChooseFDWaveform */ if (modelDomain == LAL_SIM_DOMAIN_FREQUENCY) { COMPLEX16FrequencySeries *hptilde=NULL; COMPLEX16FrequencySeries *hctilde=NULL; //We do not pass the polarization here, we assume it is taken into account when projecting h+,x onto the detector. XLAL_TRY(ret=XLALSimInspiralChooseFDWaveform(&hptilde,&hctilde, m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, LAL_PC_SI * 1.0e6, iota, phi0, 0., 0., 0., deltaF, f_min, 0.0, 0.0, LALpars,approx),errnum); XLALDestroyDict(LALpars); if(!hptilde|| hptilde->data==NULL || hptilde->data->data==NULL ||!hctilde|| hctilde->data==NULL || hctilde->data->data==NULL) { XLALPrintError(" ERROR in XLALSimInspiralChooseFDWaveform(): error generating waveform. errnum=%d. Exiting...\n",errnum ); exit(1); } COMPLEX16 *dataPtr = hptilde->data->data; for (j=0; j<(UINT4) freqHplus->data->length; ++j) { if(j < hptilde->data->length) { freqHplus->data->data[j] = dataPtr[j]; } else { freqHplus->data->data[j]=0.0 + I*0.0; } } dataPtr = hctilde->data->data; for (j=0; j<(UINT4) freqHplus->data->length; ++j) { if(j < hctilde->data->length) { freqHcross->data->data[j] = dataPtr[j]; } else { freqHcross->data->data[j]=0.0+0.0*I; } } /* Clean */ if(hptilde) XLALDestroyCOMPLEX16FrequencySeries(hptilde); if(hctilde) XLALDestroyCOMPLEX16FrequencySeries(hctilde); } else { /* Otherwise use XLALSimInspiralChooseTDWaveform */ REAL8FFTPlan *timeToFreqFFTPlan = XLALCreateForwardREAL8FFTPlan((UINT4) seglen, 0 ); REAL8TimeSeries *hplus=NULL; REAL8TimeSeries *hcross=NULL; REAL8TimeSeries *timeHplus=NULL; REAL8TimeSeries *timeHcross=NULL; REAL8 padding =0.4;//seconds REAL8Window *window=XLALCreateTukeyREAL8Window(seglen,(REAL8)2.0*padding*srate/(REAL8)seglen); REAL4 WinNorm = sqrt(window->sumofsquares/window->data->length); timeHcross=XLALCreateREAL8TimeSeries("timeModelhCross", &epoch, 0.0, deltaT, &lalStrainUnit, seglen ); timeHplus=XLALCreateREAL8TimeSeries("timeModelhplus", &epoch, 0.0, deltaT, &lalStrainUnit, seglen ); for (j=0;j<(UINT4) timeHcross->data->length;++j) timeHcross->data->data[j]=0.0; for (j=0;j<(UINT4) timeHplus->data->length;++j) timeHplus->data->data[j]=0.0; XLAL_TRY(ret=XLALSimInspiralChooseTDWaveform(&hplus, &hcross, m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, LAL_PC_SI*1.0e6, iota, phi0, 0., 0., 0., deltaT, f_min, 0., LALpars, approx), errnum); if (ret == XLAL_FAILURE || hplus == NULL || hcross == NULL) { XLALPrintError(" ERROR in XLALSimInspiralChooseTDWaveform(): error generating waveform. errnum=%d. Exiting...\n",errnum ); exit(1); } hplus->epoch = timeHplus->epoch; hcross->epoch = timeHcross->epoch; XLALSimAddInjectionREAL8TimeSeries(timeHplus, hplus, NULL); XLALSimAddInjectionREAL8TimeSeries(timeHcross, hcross, NULL); for (j=0; j<(UINT4) timeHplus->data->length; ++j) timeHplus->data->data[j]*=window->data->data[j]; for (j=0; j<(UINT4) timeHcross->data->length; ++j) timeHcross->data->data[j]*=window->data->data[j]; for (j=0; j<(UINT4) freqHplus->data->length; ++j) { freqHplus->data->data[j]=0.0+I*0.0; freqHcross->data->data[j]=0.0+I*0.0; } /* FFT into freqHplus and freqHcross */ XLALREAL8TimeFreqFFT(freqHplus,timeHplus,timeToFreqFFTPlan); XLALREAL8TimeFreqFFT(freqHcross,timeHcross,timeToFreqFFTPlan); for (j=0; j<(UINT4) freqHplus->data->length; ++j) { freqHplus->data->data[j]/=WinNorm; freqHcross->data->data[j]/=WinNorm; } /* Clean... */ if ( hplus ) XLALDestroyREAL8TimeSeries(hplus); if ( hcross ) XLALDestroyREAL8TimeSeries(hcross); if ( timeHplus ) XLALDestroyREAL8TimeSeries(timeHplus); if ( timeHcross ) XLALDestroyREAL8TimeSeries(timeHcross); if (timeToFreqFFTPlan) LALFree(timeToFreqFFTPlan); if (window) XLALDestroyREAL8Window(window); } /* The WF has been generated and is in freqHplus/cross. Now project into the IFO frame */ double Fplus, Fcross; double FplusScaled, FcrossScaled; double HSquared; double GPSdouble=(REAL8) inj->geocent_end_time.gpsSeconds+ (REAL8) inj->geocent_end_time.gpsNanoSeconds*1.0e-9; double gmst; LIGOTimeGPS GPSlal; XLALGPSSetREAL8(&GPSlal, GPSdouble); gmst=XLALGreenwichMeanSiderealTime(&GPSlal); /* Fill Fplus and Fcross*/ XLALComputeDetAMResponse(&Fplus, &Fcross, (const REAL4 (*)[3])detector->response,longitude, latitude, polarization, gmst); /* And take the distance into account */ FplusScaled = Fplus / (inj->distance); FcrossScaled = Fcross / (inj->distance); REAL8 timedelay = XLALTimeDelayFromEarthCenter(detector->location,longitude, latitude, &GPSlal); REAL8 timeshift = timedelay; REAL8 twopit = LAL_TWOPI * timeshift; UINT4 lower = (UINT4)ceil(start_freq / deltaF); UINT4 upper = (UINT4)floor(f_max / deltaF); REAL8 re = cos(twopit*deltaF*lower); REAL8 im = -sin(twopit*deltaF*lower); /* Incremental values, using cos(theta) - 1 = -2*sin(theta/2)^2 */ REAL8 dim = -sin(twopit*deltaF); REAL8 dre = -2.0*sin(0.5*twopit*deltaF)*sin(0.5*twopit*deltaF); REAL8 TwoDeltaToverN = 2.0 *deltaT / ((double) seglen); REAL8 plainTemplateReal, plainTemplateImag,templateReal,templateImag; REAL8 newRe, newIm,temp; REAL8 this_snr=0.0; if ( psd ) { psd = XLALInterpolatePSD(psd, deltaF); } for (j=lower; j<=(UINT4) upper; ++j) { /* derive template (involving location/orientation parameters) from given plus/cross waveforms: */ plainTemplateReal = FplusScaled * creal(freqHplus->data->data[j]) + FcrossScaled *creal(freqHcross->data->data[j]); plainTemplateImag = FplusScaled * cimag(freqHplus->data->data[j]) + FcrossScaled * cimag(freqHcross->data->data[j]); /* do time-shifting... */ /* (also un-do 1/deltaT scaling): */ templateReal = (plainTemplateReal*re - plainTemplateImag*im) / deltaT; templateImag = (plainTemplateReal*im + plainTemplateImag*re) / deltaT; HSquared = templateReal*templateReal + templateImag*templateImag ; temp = ((TwoDeltaToverN * HSquared) / psd->data->data[j]); this_snr += temp; /* Now update re and im for the next iteration. */ newRe = re + re*dre - im*dim; newIm = im + re*dim + im*dre; re = newRe; im = newIm; } /* Clean */ if (freqHcross) XLALDestroyCOMPLEX16FrequencySeries(freqHcross); if (freqHplus) XLALDestroyCOMPLEX16FrequencySeries(freqHplus); if (detector) free(detector); return sqrt(this_snr*2.0); }
/** * Main function for injecting numetrical relativity waveforms. * Takes as input a list of injections, and adds h(t) to a given * timeseries for a specified ifo and a dynamic range factor. * Updated/generalized version of InjectNumRelWaveforms that allows * arbitrary LIGO and Virgo PSDs and integration starting frequencies */ void InjectNumRelWaveformsUsingPSDREAL8(LALStatus *status, /**< pointer to LALStatus structure */ REAL8TimeSeries *chan, /**< [out] the output time series */ SimInspiralTable *injections, /**< [in] list of injections */ CHAR ifo[3], /**< [in] 2 char code for interferometer */ REAL8 freqLowCutoff, /**< [in] Lower cutoff frequency */ REAL8 snrLow, /**< [in] lower cutoff value of snr */ REAL8 snrHigh, /**< TO BE DOCUMENTED */ REAL8FrequencySeries *ligoPSD, /**< [in] PSD to use for LIGO SNRs. If NULL, use initial PSD */ REAL8 ligoSnrLowFreq, /**< [in] Frequency at which to start integration for LIGO SNRs */ REAL8FrequencySeries *virgoPSD, /**< [in] PSD to use for Virgo SNRs. If NULL, use initial PSD */ REAL8 virgoSnrLowFreq, /**< [in] Frequency at which to start integration for Virgo SNRs */ CHAR *fname) /**< [in] higher cutoff value of snr */ { SimInspiralTable *thisInj = NULL; REAL8 startFreq, startFreqHz, massTotal; REAL8 thisSNR; SimInspiralTable *simTableOut=NULL; SimInspiralTable *thisInjOut=NULL; INITSTATUS(status); ATTATCHSTATUSPTR (status); ASSERT( chan, status, INSPIRALH_ENULL, INSPIRALH_MSGENULL ); ASSERT( ifo, status, INSPIRALH_ENULL, INSPIRALH_MSGENULL ); /* loop over injections */ for ( thisInj = injections; thisInj; thisInj = thisInj->next ) { startFreq = start_freq_from_frame_url(thisInj->numrel_data); massTotal = (thisInj->mass1 + thisInj->mass2) * LAL_MTSUN_SI; startFreqHz = startFreq / ( LAL_TWOPI * massTotal); if (startFreqHz < freqLowCutoff) { REAL8TimeSeries *strain = NULL; strain = XLALNRInjectionStrain(ifo, thisInj); if (ifo[0] == 'V') thisSNR = calculate_snr_from_strain_and_psd_real8( strain, virgoPSD, virgoSnrLowFreq, ifo ); else thisSNR = calculate_snr_from_strain_and_psd_real8( strain, ligoPSD, ligoSnrLowFreq, ifo ); /* set channel name */ snprintf( chan->name, LALNameLength * sizeof( CHAR ), "%s:STRAIN", ifo ); printf("Injection at %d.%d in ifo %s has SNR %f\n", thisInj->geocent_end_time.gpsSeconds, thisInj->geocent_end_time.gpsNanoSeconds, ifo, thisSNR); if ((thisSNR < snrHigh) && (thisSNR > snrLow)) { /* simTableOut will be null only the first time */ if ( simTableOut == NULL) { simTableOut = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); memcpy(simTableOut, thisInj, sizeof(*thisInj)); simTableOut->next = NULL; thisInjOut = simTableOut; } else { thisInjOut->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); memcpy(thisInjOut->next, thisInj, sizeof(*thisInj)); thisInjOut->next->next = NULL; thisInjOut = thisInjOut->next; } XLALSimAddInjectionREAL8TimeSeries( chan, strain, NULL); } XLALDestroyREAL8TimeSeries (strain); } else { fprintf( stderr, "Skipping injection at %d because it turns on at %f Hz, " "but the low frequency cutoff is %f\n", thisInj->geocent_end_time.gpsSeconds, startFreqHz, freqLowCutoff); } } /* loop over injectionsj */ /* write and free the output simInspiral table */ if ( simTableOut ) { LIGOLwXMLStream xmlfp; MetadataTable dummyTable; dummyTable.simInspiralTable = simTableOut; /* write the xml table of actual injections */ if (fname) { memset( &xmlfp, 0, sizeof(LIGOLwXMLStream) ); TRY( LALOpenLIGOLwXMLFile( status->statusPtr, &xmlfp, fname ), status ); TRY( LALBeginLIGOLwXMLTable( status->statusPtr, &xmlfp, sim_inspiral_table ), status ); TRY( LALWriteLIGOLwXMLTable( status->statusPtr, &xmlfp, dummyTable, sim_inspiral_table ), status ); TRY( LALEndLIGOLwXMLTable ( status->statusPtr, &xmlfp ), status ); TRY( LALCloseLIGOLwXMLFile ( status->statusPtr, &xmlfp ), status ); } } while (simTableOut) { thisInjOut = simTableOut; simTableOut = simTableOut->next; LALFree(thisInjOut); } DETATCHSTATUSPTR(status); RETURN(status); }
/** * Wrapper to iterate over the entries in a sim_burst linked list and * inject them into a time series. Passing NULL for the response disables * it (input time series is strain). */ int XLALBurstInjectSignals( REAL8TimeSeries *series, const SimBurst *sim_burst, const TimeSlide *time_slide_table_head, const COMPLEX16FrequencySeries *response ) { /* to be deduced from the time series' channel name */ const LALDetector *detector; /* FIXME: fix the const entanglement so as to get rid of this */ LALDetector detector_copy; /* + and x time series for injection waveform */ REAL8TimeSeries *hplus = NULL; REAL8TimeSeries *hcross = NULL; /* injection time series as added to detector's */ REAL8TimeSeries *h; /* skip injections whose geocentre times are more than this many * seconds outside of the target time series */ const double injection_window = 100.0; /* turn the first two characters of the channel name into a * detector */ detector = XLALDetectorPrefixToLALDetector(series->name); if(!detector) XLAL_ERROR(XLAL_EFUNC); XLALPrintInfo("%s(): channel name is '%s', instrument appears to be '%s'\n", __func__, series->name, detector->frDetector.prefix); detector_copy = *detector; /* iterate over injections */ for(; sim_burst; sim_burst = sim_burst->next) { LIGOTimeGPS time_geocent_gps; const TimeSlide *time_slide_row; /* determine the offset to be applied to this injection */ time_slide_row = XLALTimeSlideConstGetByIDAndInstrument(time_slide_table_head, sim_burst->time_slide_id, detector->frDetector.prefix); if(!time_slide_row) { XLALPrintError("%s(): cannot find time shift offset for injection 'sim_burst:simulation_id:%ld'. need 'time_slide:time_slide_id:%ld' for instrument '%s'", __func__, sim_burst->simulation_id, sim_burst->time_slide_id, detector->frDetector.prefix); XLAL_ERROR(XLAL_EINVAL); } /* skip injections whose "times" are too far outside of the * target time series */ time_geocent_gps = sim_burst->time_geocent_gps; XLALGPSAdd(&time_geocent_gps, -time_slide_row->offset); if(XLALGPSDiff(&series->epoch, &time_geocent_gps) > injection_window || XLALGPSDiff(&time_geocent_gps, &series->epoch) > (series->data->length * series->deltaT + injection_window)) continue; XLALPrintInfo("%s(): injection 'sim_burst:simulation_id:%ld' in '%s' at %d.%09u s (GPS) will be shifted by %.16g s to %d.%09u s (GPS)\n", __func__, sim_burst->simulation_id, series->name, sim_burst->time_geocent_gps.gpsSeconds, sim_burst->time_geocent_gps.gpsNanoSeconds, -time_slide_row->offset, time_geocent_gps.gpsSeconds, time_geocent_gps.gpsNanoSeconds); /* construct the h+ and hx time series for the injection * waveform. */ if(XLALGenerateSimBurst(&hplus, &hcross, sim_burst, series->deltaT)) XLAL_ERROR(XLAL_EFUNC); #if 0 { char name[100]; FILE *f; unsigned i; sprintf(name, "%d.%09u_%s.txt", sim_burst->time_geocent_gps.gpsSeconds, sim_burst->time_geocent_gps.gpsNanoSeconds, series->name); f = fopen(name, "w"); for(i = 0; i < hplus->data->length; i++) { LIGOTimeGPS t = hplus->epoch; XLALGPSAdd(&t, i * hplus->deltaT); fprintf(f, "%.16g %.16g %.16g\n", XLALGPSGetREAL8(&t), hplus->data->data[i], hcross->data->data[i]); } fclose(f); } #endif /* project the wave onto the detector to produce the strain * in the detector. */ h = XLALSimDetectorStrainREAL8TimeSeries(hplus, hcross, sim_burst->ra, sim_burst->dec, sim_burst->psi, &detector_copy); XLALDestroyREAL8TimeSeries(hplus); XLALDestroyREAL8TimeSeries(hcross); hplus = hcross = NULL; if(!h) XLAL_ERROR(XLAL_EFUNC); /* shift the waveform by the time slide offset */ XLALGPSAdd(&h->epoch, -time_slide_row->offset); #if 0 { char name[100]; FILE *f; unsigned i; sprintf(name, "%d.%09u_%s.txt", sim_burst->time_geocent_gps.gpsSeconds, sim_burst->time_geocent_gps.gpsNanoSeconds, series->name); f = fopen(name, "w"); for(i = 0; i < h->data->length; i++) { LIGOTimeGPS t = h->epoch; XLALGPSAdd(&t, i * h->deltaT); fprintf(f, "%d.%09u %.16g\n", t.gpsSeconds, t.gpsNanoSeconds, h->data->data[i]); } fclose(f); } #endif /* add the injection strain time series to the detector * data */ if(XLALSimAddInjectionREAL8TimeSeries(series, h, response)) { XLALDestroyREAL8TimeSeries(h); XLAL_ERROR(XLAL_EFUNC); } XLALDestroyREAL8TimeSeries(h); } /* done */ return 0; }