31#include <lal/SinCosLUT.h>
33#define SQUARE(x) ( (x) * (x) )
191 for (
UINT4 i = 0;
i < freqnum;
i++ ) {
193 snprintf( varname,
sizeof( varname ),
"F%u",
i );
195 freqs->
data[
i] = f0new;
196 snprintf( varname,
sizeof( varname ),
"F%u_FIXED",
i );
198 deltafreqs->
data[
i] = f0new - f0fixed;
213 for (
UINT4 j = 0;
j < glnum;
j++ ) {
215 snprintf( varname,
sizeof( varname ),
"%s_%u",
glitchpars[
i],
j + 1 );
279 for (
UINT4 i = 0;
i < fbnum;
i++ ) {
281 snprintf( varname,
sizeof( varname ),
"FB%u",
i );
304 int isG4v = strcmp( nonGRmodel,
"G4v" ) * strcmp( nonGRmodel,
"g4v" ) * strcmp( nonGRmodel,
"G4V" );
305 int isEGR = strcmp( nonGRmodel,
"enhanced-GR" ) * strcmp( nonGRmodel,
"EGR" ) * strcmp( nonGRmodel,
"egr" ) * strcmp( nonGRmodel,
"eGR" );
310 REAL8 cosiota = cos( iota );
311 REAL8 siniota = sin( iota );
316 siniota = sin( acos( cosiota ) );
323 REAL8 hVectorY =
h0 * siniota * cosiota;
328 }
else if ( isEGR == 0 ) {
335 REAL8 hPlus_F = 0.25 * h0_F * siniota * cosiota;
336 REAL8 hCross_F = 0.5 * h0_F * siniota;
341 REAL8 hPlus = 0.5 *
h0 * ( 1. + cosiota * cosiota );
347 XLAL_ERROR_VOID(
XLAL_EINVAL,
"Unrecognized non-GR model. Currently supported: enhanced GR (EGR), G4v, or no argument for full search." );
410 INT4 i = 0, length = 0;
425 while ( ifomodel2 ) {
426 for (
j = 0;
j < freqFactors->
length;
j++ ) {
430 length = ifomodel2->compTimeSignal->data->length;
434 for (
i = 0;
i < length;
i++ ) {
440 M = ifomodel2->compTimeSignal->data->data[
i];
443 ifomodel2->compTimeSignal->data->data[
i] =
M * expp;
449 ifomodel2 = ifomodel2->next;
495 UINT4 i = 0,
j = 0,
k = 0, length = 0, isbinary = 0;
497 REAL8 DT = 0., deltat = 0., deltatpow = 0., deltatpowinner = 1., taylorcoeff = 1., Ddelay = 0., Ddelaypow = 0.;
499 REAL8Vector *phis = NULL, *dts = NULL, *fixdts = NULL, *bdts = NULL, *fixbdts = NULL, *glitchphase = NULL, *fixglitchphase = NULL;
514 length = datatimes->
length;
565 for (
i = 0;
i < length;
i++ ) {
566 REAL8 deltaphi = 0., innerphi = 0.;
574 Ddelay += ( dts->data[
i] - fixdts->data[
i] );
576 deltat = DT + fixdts->data[
i];
580 if ( bdts != NULL && fixbdts != NULL ) {
581 Ddelay += ( bdts->data[
i] - fixbdts->data[
i] );
583 deltat += fixbdts->data[
i];
587 if ( cgw > 0.0 && cgw < 1. ) {
595 taylorcoeff = gsl_sf_fact(
j + 1 );
596 deltaphi += deltafs->
data[
j] * deltatpow / taylorcoeff;
597 if ( Ddelay != 0. ) {
600 Ddelaypow = pow( Ddelay,
j + 1 );
601 for (
k = 0;
k <
j + 1;
k++ ) {
602 innerphi += gsl_sf_choose(
j + 1,
k ) * Ddelaypow * deltatpowinner;
603 deltatpowinner *= deltat;
606 deltaphi += innerphi * freqs->
data[
j] / taylorcoeff;
612 if ( glitchphase != NULL ) {
613 deltaphi += ( glitchphase->data[
i] - fixglitchphase->data[
i] );
616 deltaphi *= freqFactor;
617 phis->
data[
i] = deltaphi - floor( deltaphi );
624 if ( bdts != NULL ) {
627 if ( glitchphase != NULL ) {
660 INT4 i = 0, length = 0;
667 if ( ephem == NULL ) {
699 if ( pepoch == 0. && posepoch != 0. ) {
701 }
else if ( posepoch == 0. && pepoch != 0. ) {
705 length = datatimes->
length;
719 REAL8 absdec = fabs( dec );
722 dec = ( dec > 0 ? 1. : -1. ) * ( nwrap % 2 == 1 ? -1. : 1. ) * ( fmod( absdec +
LAL_PI_2,
LAL_PI ) -
LAL_PI_2 );
728 for (
i = 0;
i < length;
i++ ) {
732 bary.
delta = dec + ( realT - posepoch ) * pmdec;
733 bary.
alpha = ra + ( realT - posepoch ) * pmra / cos( bary.
delta );
775 for (
i = 0;
i < length;
i++ ) {
780 binput.
earth = earth;
803 REAL8 *glep = NULL, *glph = NULL, *glf0 = NULL, *glf1 = NULL, *glf2 = NULL, *glf0d = NULL, *gltd = NULL;
818 for (
i = 0;
i < gleppars->
length;
i++ ) {
819 glep[
i] = gleppars->
data[
i];
827 glph[
i] = glpars->
data[
i];
836 glf0[
i] = glpars->
data[
i];
845 glf1[
i] = glpars->
data[
i];
854 glf2[
i] = glpars->
data[
i];
863 glf0d[
i] = glpars->
data[
i];
872 gltd[
i] = glpars->
data[
i];
878 for (
i = 0;
i < length;
i++ ) {
879 REAL8 deltaphi = 0., deltat = 0., DT = 0.;
884 deltat = DT + dts->
data[
i];
887 if ( bdts != NULL ) {
888 deltat += bdts->
data[
i];
892 if ( cgw > 0.0 && cgw < 1. ) {
897 for (
j = 0;
j < glnum;
j++ ) {
898 if ( deltat >= ( glep[
j] -
T0 ) ) {
899 REAL8 dtg = 0, expd = 1.;
900 dtg = deltat - ( glep[
j] -
T0 );
901 if ( gltd[
j] != 0. ) {
902 expd = exp( -dtg / gltd[
j] );
904 deltaphi += glph[
j] + glf0[
j] * dtg + 0.5 * glf1[
j] * dtg * dtg + ( 1. / 6. ) * glf2[
j] * dtg * dtg * dtg + glf0d[
j] * gltd[
j] * ( 1. - expd );
908 glphase->
data[
i] = deltaphi;
939 REAL8 siniota = sin( acos( cosiota ) );
940 REAL8 s2psi = 0., c2psi = 0., spsi = 0., cpsi = 0.;
944 INT4 varyphase = 0, roq = 0;
956 s2psi = sin( twopsi );
957 c2psi = cos( twopsi );
972 for (
j = 0;
j < freqFactors->
length;
j++ ) {
974 COMPLEX16 Cplus = 0., Ccross = 0., Cx = 0., Cy = 0., Cl = 0., Cb = 0.;
981 if ( freqFactors->
data[
j] == 1. ) {
984 COMPLEX16 expPhiTensor, expPsiTensor, expPhiScalar, expPsiScalar, expPhiVector, expPsiVector;
1004 }
else if ( freqFactors->
data[
j] == 2. ) {
1007 COMPLEX16 expPhiTensor, expPsiTensor, expPhiScalar, expPsiScalar, expPhiVector, expPsiVector;
1031 if ( varyphase || roq ) {
1035 REAL8Vector *LUfplus = NULL, *LUfcross = NULL, *LUfx = NULL, *LUfy = NULL, *LUfb = NULL, *LUfl = NULL;
1056 for (
i = 0;
i < length;
i++ ) {
1057 REAL8 plus00, plus01, cross00, cross01, plus = 0., cross = 0.;
1058 REAL8 x00, x01, y00, y01, b00, b01, l00, l01;
1059 REAL8 timeScaled, timeMin, timeMax;
1060 REAL8 plusT = 0., crossT = 0.,
x = 0.,
y = 0., xT = 0., yT = 0., b = 0.,
l = 0.;
1061 INT4 timebinMin, timebinMax;
1066 timebinMin = (
INT4 )fmod( floor(
T / tsv ), tsteps );
1067 timeMin = timebinMin * tsv;
1068 timebinMax = (
INT4 )fmod( timebinMin + 1, tsteps );
1069 timeMax = timeMin + tsv;
1072 plus00 = LUfplus->
data[timebinMin];
1073 plus01 = LUfplus->
data[timebinMax];
1075 cross00 = LUfcross->data[timebinMin];
1076 cross01 = LUfcross->data[timebinMax];
1079 timeScaled = (
T - timeMin ) / ( timeMax - timeMin );
1081 plus = plus00 + ( plus01 - plus00 ) * timeScaled;
1082 cross = cross00 + ( cross01 - cross00 ) * timeScaled;
1084 plusT = plus * c2psi + cross * s2psi;
1085 crossT = cross * c2psi - plus * s2psi;
1088 x00 = LUfx->data[timebinMin];
1089 x01 = LUfx->data[timebinMax];
1090 y00 = LUfy->data[timebinMin];
1091 y01 = LUfy->data[timebinMax];
1092 b00 = LUfb->data[timebinMin];
1093 b01 = LUfb->data[timebinMax];
1094 l00 = LUfl->data[timebinMin];
1095 l01 = LUfl->data[timebinMax];
1097 x = x00 + ( x01 - x00 ) * timeScaled;
1098 y = y00 + ( y01 - y00 ) * timeScaled;
1099 b = b00 + ( b01 - b00 ) * timeScaled;
1100 l = l00 + ( l01 - l00 ) * timeScaled;
1102 xT =
x * cpsi +
y * spsi;
1103 yT =
y * cpsi -
x * spsi;
1107 ifo->compTimeSignal->data->data[
i] = ( Cplus * plusT ) + ( Ccross * crossT );
1111 ifo->compTimeSignal->data->data[
i] += ( Cx * xT ) + ( Cy * yT ) + Cb * b + Cl *
l;
1126 if (
ifo->compTimeSignal->data->length != 2 ) {
1130 ifo->compTimeSignal->data->data[0] = ( Cplus * c2psi - Ccross * s2psi );
1131 ifo->compTimeSignal->data->data[1] = ( Cplus * s2psi + Ccross * c2psi );
1134 if (
ifo->compTimeSignal->data->length != 6 ) {
1138 ifo->compTimeSignal->data->data[0] = ( Cplus * c2psi - Ccross * s2psi );
1139 ifo->compTimeSignal->data->data[1] = ( Cplus * s2psi + Ccross * c2psi );
1140 ifo->compTimeSignal->data->data[2] = ( Cx * cpsi - Cy * spsi );
1141 ifo->compTimeSignal->data->data[3] = ( Cx * spsi + Cy * cpsi );
1142 ifo->compTimeSignal->data->data[4] = Cb;
1143 ifo->compTimeSignal->data->data[5] = Cl;
1182 if (
phi1->length !=
phi2->length ) {
1187 for (
i = 0;
i <
phi1->length - 1;
i++ ) {
1189 dp1 = fmod(
phi1->data[
i] -
phi2->data[
i], 1. );
1196 dp2 = fmod(
phi1->data[
i + 1] -
phi2->data[
i + 1], 1. );
1205 return ( 1. - fabs(
mismatch ) / ( 2.*
T ) );
1229 if ( !earth || !tGPS || !
edat || !
edat->ephemE || !
edat->ephemS ) {
1236 tinitE =
edat->ephemE[0].gps;
1238 t0e = tgps[0] - tinitE;
1239 ientryE =
ROUND( t0e /
edat->dtEtable );
1241 if ( ( ientryE < 0 ) || ( ientryE >=
edat->nentriesE ) ) {
1243 edat->nentriesE *
edat->dtEtable );
1247 tdiffE = t0e -
edat->dtEtable * ientryE + tgps[1] * 1.e-9;
1248 tdiff2E = tdiffE * tdiffE;
1254 for (
j = 0;
j < 3;
j++ ) {
1255 earth->
posNow[
j] =
pos[
j] + vel[
j] * tdiffE + 0.5 * acc[
j] * tdiff2E;
1256 earth->
velNow[
j] = vel[
j] + acc[
j] * tdiffE;
1290 REAL8 T = 0, Tstart = 0., Tav = 0;
1292 REAL8 fplus = 0., fcross = 0., fx = 0., fy = 0., fb = 0., fl = 0.;
1295 INT4 j = 0,
k = 0, nav = 0;
1298 if ( avedt == 60. ) {
1301 nav = floor( avedt / 60. ) + 1;
1307 for (
j = 0 ;
j < timeSteps ;
j++ ) {
1319 Tstart =
T - 0.5 * ( (
REAL8 )nav - 1. ) * 60.;
1321 Tstart =
T - ( 0.5 * (
REAL8 )nav - 1. ) * 60. - 30.;
1324 for (
k = 0;
k < nav;
k++ ) {
1325 Tav = Tstart + 60.*(
REAL8 )
k;
1334 aT->
data[
j] += fplus;
1335 bT->
data[
j] += fcross;
1369 REAL8 sinlambda, coslambda, sinlambda2, coslambda2, sin2lambda;
1370 REAL8 theta, sintheta, costheta2, sintheta2, sin2theta;
1389 }
else if ( ( I21 != 0. || I31 != 0. ) && ( C22 == 0. && C21 == 0. ) ) {
1390 sinlambda = sin( lambda );
1391 coslambda = cos( lambda );
1392 sin2lambda = sin( 2. * lambda );
1393 sinlambda2 =
SQUARE( sinlambda );
1394 coslambda2 =
SQUARE( coslambda );
1397 sintheta = sin(
theta );
1398 sin2theta = sin( 2. *
theta );
1399 sintheta2 =
SQUARE( sintheta );
1402 REAL8 A22 = I21 * ( sinlambda2 - coslambda2 * costheta2 ) - I31 * sintheta2;
1407 REAL8 A21 = I21 * sin2lambda * sintheta;
1408 REAL8 B21 = sin2theta * ( I21 * coslambda2 - I31 );
1412 C22 = 2.*sqrt( A222 + B222 );
1413 C21 = 2.*sqrt( A212 + B212 );
void XLALBinaryPulsarDeltaTNew(BinaryPulsarOutput *output, BinaryPulsarInput *input, PulsarParameters *params)
function to calculate the binary system delay using new parameter structure
const REAL8Vector * PulsarGetREAL8VectorParam(const PulsarParameters *pars, const CHAR *name)
Return a REAL8Vector parameter.
void PulsarAddREAL8Param(PulsarParameters *pars, const CHAR *name, REAL8 value)
Add a REAL8 parameter to the PulsarParameters structure.
REAL8 PulsarGetREAL8ParamOrZero(const PulsarParameters *pars, const CHAR *name)
Return a REAL8 parameter if it exists, otherwise return zero.
int PulsarCheckParam(const PulsarParameters *pars, const CHAR *name)
Check for the existence of the parameter name in the PulsarParameters structure.
REAL8 PulsarGetREAL8Param(const PulsarParameters *pars, const CHAR *name)
Return a REAL8 parameter.
void PulsarFreeParams(PulsarParameters *pars)
Function to free memory from pulsar parameters.
void PulsarAddStringParam(PulsarParameters *pars, const CHAR *name, const CHAR *value)
Add a string parameter to the PulsarParameters structure.
void PulsarAddREAL8VectorParam(PulsarParameters *pars, const CHAR *name, const REAL8Vector *value)
Add a REAL8Vector parameter to the PulsarParameters structure.
#define PULSAR_PARNAME_MAX
void XLALComputeDetAMResponseExtraModes(double *fplus, double *fcross, double *fb, double *fl, double *fx, double *fy, const REAL4 D[3][3], const double ra, const double dec, const double psi, const double gmst)
int XLALBarycenter(EmissionTime *emit, const BarycenterInput *baryinput, const EarthState *earth)
Transforms from detector arrival time in GPS (as specified in the LIGOTimeGPS structure) to pulse em...
int XLALBarycenterEarthNew(EarthState *earth, const LIGOTimeGPS *tGPS, const EphemerisData *edat, const TimeCorrectionData *tdat, TimeCorrectionType ttype)
Computes the position and orientation of the Earth, at some arrival time, but unlike XLALBarycenterEa...
TimeCorrectionType
Enumerated type denoting the time system type to be produced in the solar system barycentring routine...
UINT4 LALInferenceGetUINT4Variable(LALInferenceVariables *vars, const char *name)
void LALInferenceAddVariable(LALInferenceVariables *vars, const char *name, const void *value, LALInferenceVariableType type, LALInferenceParamVaryType vary)
REAL8 LALInferenceGetREAL8Variable(LALInferenceVariables *vars, const char *name)
LALInferenceParamVaryType
void * LALInferenceGetVariable(const LALInferenceVariables *vars, const char *name)
REAL8Vector * LALInferenceGetREAL8VectorVariable(LALInferenceVariables *vars, const char *name)
int LALInferenceCheckVariable(LALInferenceVariables *vars, const char *name)
int LALInferenceCheckVariableNonFixed(LALInferenceVariables *vars, const char *name)
void * XLALCalloc(size_t m, size_t n)
int XLALSinCos2PiLUT(REAL4 *sin2pix, REAL4 *cos2pix, REAL8 x)
Calculate sin(2*pi*x) and cos(2*pi*x) to roughly 1e-7 precision using a lookup-table and Taylor-expan...
COMPLEX16TimeSeries * XLALResizeCOMPLEX16TimeSeries(COMPLEX16TimeSeries *series, int first, size_t length)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
#define XLAL_ERROR_VOID(...)
#define XLAL_ERROR_REAL8(...)
#define XLAL_ERROR_NULL(...)
#define XLAL_CHECK_REAL8(assertion,...)
#define XLAL_CHECK_NULL(assertion,...)
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
void add_variable_parameter(PulsarParameters *params, LALInferenceVariables *var, const CHAR *parname, LALInferenceParamVaryType vary)
Add a REAL8 parameter from a PulsarParameters variable into a LALInferenceVariable.
REAL8Vector * get_glitch_phase(PulsarParameters *pars, LIGOTimeGPSVector *datatimes, REAL8Vector *dts, REAL8Vector *bdts)
Computes the phase from the glitch model.
void response_lookup_table(REAL8 t0, LALDetAndSource detNSource, INT4 timeSteps, REAL8 avedt, REAL8Vector *aT, REAL8Vector *bT, REAL8Vector *aV, REAL8Vector *bV, REAL8Vector *aS, REAL8Vector *bS)
Creates a lookup table of the detector antenna pattern.
void pulsar_model(PulsarParameters *params, LALInferenceIFOModel *ifo)
Generate the model of the neutron star signal.
REAL8Vector * get_bsb_delay(PulsarParameters *pars, LIGOTimeGPSVector *datatimes, REAL8Vector *dts, EphemerisData *edat)
Computes the delay between a pulsar in a binary system and the barycentre of the system.
REAL8Vector * get_ssb_delay(PulsarParameters *pars, LIGOTimeGPSVector *datatimes, EphemerisData *ephem, TimeCorrectionData *tdat, TimeCorrectionType ttype, LALDetector *detector)
Computes the delay between a GPS time at Earth and the solar system barycentre.
void get_earth_pos_vel(EarthState *earth, EphemerisData *edat, LIGOTimeGPS *tGPS)
Get the position and velocity of the Earth at a given time.
REAL8 get_phase_mismatch(REAL8Vector *phi1, REAL8Vector *phi2, LIGOTimeGPSVector *t)
Calculate the phase mismatch between two vectors of phases.
void invert_source_params(PulsarParameters *params)
Convert sources parameters into amplitude and phase notation parameters.
void get_pulsar_model(LALInferenceModel *model)
Defines the pulsar model/template to use.
void get_amplitude_model(PulsarParameters *pars, LALInferenceIFOModel *ifo)
The amplitude model of a complex heterodyned signal from the harmonics of a rotating neutron star.
REAL8Vector * get_phase_model(PulsarParameters *params, LALInferenceIFOModel *ifo, REAL8 freqFactor)
The phase evolution of a source.
void add_pulsar_parameter(LALInferenceVariables *var, PulsarParameters *params, const CHAR *parname)
Add a REAL8 parameter from a LALInferenceVariable into a PulsarParameters variable.
void set_nonGR_model_parameters(PulsarParameters *pars, char *nonGRmodel)
Set amplitude parameters for specific non-GR models.
Header file for the signal models functions used in parameter estimation code for known pulsar search...
#define IFO_XTRA_DATA(ifo)
#define NUMGLITCHPARS
The total number of glitch parameters that can define a signal.
static const CHAR glitchpars[NUMGLITCHPARS][VARNAME_MAX]
A list of the glitch parameters.
structure containing the output parameters for the binary delay function
REAL8 deltaT
deltaT to add to TDB in order to account for binary
Basic output structure of LALBarycenterEarth.c.
REAL8 velNow[3]
dimensionless velocity of Earth's center at tgps, extrapolated from JPL DE405 ephemeris
REAL8 posNow[3]
Cartesian coords of Earth's center at tgps, extrapolated from JPL DE405 ephemeris; units= sec.
Basic output structure produced by LALBarycenter.c.
REAL8 deltaT
(TDB) - (GPS)
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
const LALDetector * pDetector
LALInferenceVariables * params
LALInferenceVariables * params
LALInferenceIFOModel * ifo
SkyPosition equatorialCoords
A vector of 'timestamps' of type LIGOTimeGPS.
LIGOTimeGPS * data
array of timestamps
UINT4 length
number of timestamps
The PulsarParameters structure to contain a set of pulsar parameters.
This structure will contain a vector of time corrections used during conversion from TT to TDB/TCB/Te...