20#include <lal/LALStdio.h>
21#include <lal/FileIO.h>
22#include <lal/NRWaveIO.h>
23#include <lal/LIGOMetadataTables.h>
24#include <lal/LIGOMetadataInspiralUtils.h>
27#include <lal/LALConstants.h>
28#include <lal/NRWaveInject.h>
29#include <lal/Random.h>
30#include <lal/LALSimulation.h>
31#include <lal/LALSimInspiral.h>
32#include <lal/LALDetectors.h>
33#include <lal/DetResponse.h>
34#include <lal/TimeDelay.h>
35#include <lal/SkyCoordinates.h>
36#include <lal/TimeSeries.h>
37#include <lal/FrequencySeries.h>
38#include <lal/TimeFreqFFT.h>
39#include <lal/Window.h>
40#include <lal/SphericalHarmonics.h>
42#include <gsl/gsl_heapsort.h>
45#define UNUSED __attribute__ ((unused))
62 UINT4 vecLength, length, k;
67 for ( k = 0; k < vecLength*length; k++)
80 UINT4 vecLength, length, k;
85 for ( k = 0; k < vecLength*length; k++)
114 XLALSphHarm( &MultSphHarm, modeL, modeM, inclination, coa_phase );
117 for ( k = 0; k < vecLength; k++)
120 tmp2 = strain->
data->
data[vecLength + k];
123 (
tmp1 * creal(MultSphHarm)) +
124 (tmp2 * cimag(MultSphHarm));
127 (tmp2 * creal(MultSphHarm)) -
128 (
tmp1 * cimag(MultSphHarm));
156 XLALSphHarm( &MultSphHarm, modeL, modeM, inclination, coa_phase );
159 for ( k = 0; k < vecLength; k++)
165 (
tmp1 * creal(MultSphHarm)) +
166 (tmp2 * cimag(MultSphHarm));
169 (tmp2 * creal(MultSphHarm)) -
170 (
tmp1 * cimag(MultSphHarm));
197 XLALSphHarm( &MultSphHarm, modeL, modeM, inclination, coa_phase );
200 for ( k = 0; k < vecLength; k++)
203 tmp2 = strain->
data->
data[vecLength + k];
206 (
tmp1 * creal(MultSphHarm)) +
207 (tmp2 * cimag(MultSphHarm));
210 (tmp2 * creal(MultSphHarm)) -
211 (
tmp1 * cimag(MultSphHarm));
249 if ( ! htData->
data )
270 for ( k = 0; k < vecLength; ++k )
294 REAL8 deltaTin, deltaTout,
r, y_1, y_2;
296 UINT4 k, lo, numPoints;
302 numPoints = (
UINT4) (sampleRate * tObs);
317 ret->
deltaT = 1./sampleRate;
328 for (k = 0; k < numPoints; k++) {
330 lo = (
UINT4)( k*deltaTout / deltaTin);
335 if ( lo < in->
data->length - 1) {
341 r = k*deltaTout / deltaTin - lo;
372 REAL8 deltaTin, deltaTout,
r, y_1, y_2;
374 UINT4 k, lo, numPoints;
380 numPoints = (
UINT4) (sampleRate * tObs);
395 ret->
deltaT = 1./sampleRate;
406 for (k = 0; k < numPoints; k++) {
408 lo = (
UINT4)( k*deltaTout / deltaTin);
413 if ( lo < in->
data->length - 1) {
419 r = k*deltaTout / deltaTin - lo;
437 const REAL4 *af, *bf;
440 bf = (
const REAL4 *)b;
442 if ( fabs(*af) > fabs(*bf))
444 else if ( fabs(*af) < fabs(*bf))
453 const REAL8 *af, *bf;
456 bf = (
const REAL8 *)b;
458 if ( fabs(*af) > fabs(*bf))
460 else if ( fabs(*af) < fabs(*bf))
475 REAL4 *sumSquare=NULL;
481 sumSquare =
LALCalloc(1, len*
sizeof(*sumSquare));
483 for (k=0; k < len; k++) {
490 *tc = ind[len-1] * in->
deltaT;
507 REAL8 *sumSquare=NULL;
513 sumSquare =
LALCalloc(1, len*
sizeof(*sumSquare));
515 for (k=0; k < len; k++) {
522 *tc = ind[len-1] * plus->
deltaT;
549 *tc = ind[len-1] * in->
deltaT;
571 *tc = ind[len-1] * in->
deltaT;
593 REAL8 massRatioIn, massRatio, diff, newDiff;
627 for (k = 0; k < nrCatalog->
length; k++) {
629 if ((modeL == nrCatalog->
data[k].
mode[0]) && (modeM == nrCatalog->
data[k].
mode[1])) {
632 newDiff = fabs(massRatio - massRatioIn);
634 if ( (diff < 0) || (diff > newDiff)) {
674 sampleRate = 1.0/injData->
deltaT;
684 for ( k = 0 ; k < htData->
data->
length ; ++k )
695 if ( strcmp( thisInj->
taper,
"TAPER_NONE" ) )
698 if ( ! strcmp(
"TAPER_START", thisInj->
taper ) )
702 else if ( ! strcmp(
"TAPER_END", thisInj->
taper ) )
706 else if ( ! strcmp(
"TAPER_STARTEND", thisInj->
taper ) )
730 XLALPrintError(
"Band-passing not yet implemented for InjectStrainGW.\n" );
763 snprintf( injData->
name,
sizeof(injData->
name),
781 REAL8 UNUSED dynRange)
798 if ( strcmp( thisInj->
taper,
"TAPER_NONE" ) || thisInj->
bandpass )
800 XLALPrintError(
"Tapering/band-passing of REAL8 injection currently unsupported\n" );
812 for ( k = 0; k < len; k++) {
828 snprintf( injData->
name,
sizeof(injData->
name),
851 if ( !((strncmp(polarisation,
"plus", 4) == 0) || (strncmp(polarisation,
"cross", 5) == 0))) {
889 if ( strstr(
name,
"Caltech") || strstr(
name,
"CIT") )
891 else if ( strstr(
name,
"AEI") || strstr(
name,
"Potsdam") )
893 else if ( strstr(
name,
"Jena") )
895 else if ( strstr(
name,
"Pretorius") || strstr(
name,
"Princeton"))
897 else if ( strstr(
name,
"Cornell") )
899 else if ( strstr(
name,
"PSU") || strstr(
name,
"Penn State") )
901 else if ( strstr(
name,
"LSU") )
903 else if ( strstr(
name,
"RIT") || strstr(
name,
"Rochester") )
905 else if ( strstr(
name,
"FAU") || strstr(
name,
"Florida Atlantic") )
907 else if ( strstr(
name,
"UTB") )
909 else if ( strstr(
name,
"UIUC") || strstr(
name,
"Urbana Champaign") )
#define ABORT(statusptr, code, mesg)
#define ATTATCHSTATUSPTR(statusptr)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int compare_abs_float(const void *a, const void *b)
int compare_abs_double(const void *a, const void *b)
void LALInjectStrainGWREAL8(LALStatus *status, REAL8TimeSeries *injData, REAL8TimeVectorSeries *strain, SimInspiralTable *thisInj, CHAR *ifo, REAL8 UNUSED dynRange)
REAL8 version of above but using Jolien's new functions.
void XLALComputeDetAMResponse(double *fplus, double *fcross, const REAL4 D[3][3], const double ra, const double dec, const double psi, const double gmst)
int LALPrintError(const char *fmt,...)
LAL_SIM_INSPIRAL_TAPER_START
LAL_SIM_INSPIRAL_TAPER_STARTEND
LAL_SIM_INSPIRAL_TAPER_END
LAL_SIM_INSPIRAL_TAPER_NONE
const LALDetector * XLALDetectorPrefixToLALDetector(const char *string)
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)
INT4 XLALFindNRFile(NRWaveMetaData *out, NRWaveCatalog *nrCatalog, const SimInspiralTable *inj, INT4 modeL, INT4 modeM)
For given inspiral parameters, find nearest waveform in catalog of numerical relativity waveforms.
REAL4TimeSeries * XLALCalculateNRStrain(REAL4TimeVectorSeries *strain, SimInspiralTable *inj, const CHAR *ifo, INT4 sampleRate)
INT4 XLALOrientNRWave(REAL4TimeVectorSeries *strain, UINT4 modeL, INT4 modeM, REAL4 inclination, REAL4 coa_phase)
Takes a (sky averaged) numerical relativity waveform and returns the waveform appropriate for given c...
REAL8TimeVectorSeries * XLALOrientNRWaveREAL8(REAL8TimeVectorSeries *strain, UINT4 modeL, INT4 modeM, REAL4 inclination, REAL4 coa_phase)
Takes a (sky averaged) numerical relativity waveform and returns the waveform appropriate for given c...
NumRelGroup
enum for list of numrel groups
INT4 XLALFindNRCoalescencePlusCrossREAL8(REAL8 *tc, const REAL8TimeSeries *plus, const REAL8TimeSeries *cross)
INT4 XLALFindNRCoalescenceTimeFromhoft(REAL8 *tc, const REAL4TimeSeries *in)
Function for calculating the coalescence time (defined to be the peak) of a NR wave This uses the pea...
INT4 XLALFindNRCoalescenceTimeREAL8(REAL8 *tc, const REAL8TimeSeries *in)
Function for calculating the coalescence time (defined to be the peak) of a NR wave.
CHAR * XLALGetNinjaChannelName(const CHAR *polarisation, UINT4 l, INT4 m)
construct the channel name corresponding to a particular mode and polarization in frame file containi...
#define NRWAVEINJECT_EVAL
Invalid value.
REAL4TimeVectorSeries * XLALSumStrain(REAL4TimeVectorSeries *tempstrain, REAL4TimeVectorSeries *strain)
Takes a strain of h+ and hx data and stores it in a temporal strain in order to perform the sum over ...
void XLALOrientNRWaveTimeSeriesREAL8(REAL8TimeSeries *plus, REAL8TimeSeries *cross, UINT4 modeL, INT4 modeM, REAL4 inclination, REAL4 coa_phase)
Takes a (sky averaged) numerical relativity waveform and returns the waveform appropriate for given c...
void LALInjectStrainGW(LALStatus *status, REAL4TimeSeries *injData, REAL4TimeVectorSeries *strain, SimInspiralTable *thisInj, CHAR *ifo, REAL8 dynRange)
REAL8TimeVectorSeries * XLALSumStrainREAL8(REAL8TimeVectorSeries *tempstrain, REAL8TimeVectorSeries *strain)
INT4 XLALFindNRCoalescenceTime(REAL8 *tc, const REAL4TimeVectorSeries *in)
Function for calculating the coalescence time (defined to be the peak) of a NR wave.
REAL8TimeSeries * XLALInterpolateNRWaveREAL8(REAL8TimeSeries *in, INT4 sampleRate)
Function for interpolating time series to a given sampling rate.
REAL4TimeSeries * XLALInterpolateNRWave(REAL4TimeSeries *in, INT4 sampleRate)
Function for interpolating time series to a given sampling rate.
NumRelGroup XLALParseNumRelGroupName(CHAR *name)
Function for parsing numrel group name and converting it into a enum element.
INT4 XLALSphHarm(COMPLEX16 *out, UINT4 L, INT4 M, REAL4 theta, REAL4 phi)
REAL8 XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalADCCountUnit
REAL4Vector * XLALCreateREAL4Vector(UINT4 length)
void XLALDestroyREAL4Vector(REAL4Vector *vector)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
#define XLAL_ERROR_VOID(...)
#define XLAL_ERROR_NULL(...)
#define XLAL_CHECK_VOID(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
List of numrel waveform metadata.
NRWaveMetaData * data
List of waveforms.
UINT4 length
Number of waveforms.
REAL4VectorSequence * data
REAL8VectorSequence * data
LIGOTimeGPS geocent_end_time
CHAR taper[LIGOMETA_INSPIRALTAPER_MAX]