20#include <lal/HeterodynedPulsarModel.h>
23#define ROUND(x) (floor(x+0.5))
26#define SQUARE(x) ( (x) * (x) )
131 UINT4 i = 0,
j = 0,
k = 0, length = 0, nfreqs = 0;
133 REAL8 DT = 0., deltat = 0., deltatpow = 0., deltatpowinner = 1., taylorcoeff = 1., Ddelay = 0., Ddelaypow = 0.;
135 REAL8Vector *phis = NULL, *dts = NULL, *fixdts = NULL, *bdts = NULL, *fixbdts = NULL, *fixglph = NULL, *glph = NULL, *fixfitwavesph = NULL, *fitwavesph = NULL;
138 REAL8 T0 = pepoch, pepochorig = pepoch;
139 REAL8 *deltafs = NULL, *frequpdate = NULL;
141 length = datatimes->
length;
148 if ( calcSSBDelay ) {
149 if ( origparams != NULL && ssbdts != NULL ) {
154 XLAL_CHECK_NULL( length == fixdts->length,
XLAL_EFUNC,
"Lengths of time stamp vector and SSB delay vector are not the same" );
159 if ( calcBSBDelay ) {
160 REAL8Vector *whichssb = dts != NULL ? dts : fixdts;
161 if ( origparams != NULL && bsbdts != NULL ) {
166 XLAL_CHECK_NULL( length == fixbdts->length,
XLAL_EFUNC,
"Lengths of time stamp vector and BSB delay vector are not the same" );
172 const REAL8Vector *whichssb = dts != NULL ? dts : fixdts;
173 const REAL8Vector *whichbsb = bdts != NULL ? bdts : fixbdts;
174 if ( origparams != NULL && glphase != NULL ) {
182 if ( origparams != NULL ) {
196 deltat = ( pepochorig - pepoch );
199 frequpdate[
i] = freqsu->
data[
i];
202 if ( pepoch != pepochorig ) {
203 REAL8 deltatpowu = deltat;
205 frequpdate[
i] += ( freqsu->
data[
j] * deltatpowu ) / gsl_sf_fact(
j -
i );
207 deltatpowu *= deltat;
212 if ( pepoch != pepochorig ) {
218 if ( origparams != NULL ) {
222 for (
i = 0;
i < nfreqs;
i++ ) {
225 deltafs[
i] = frequpdate[
i];
227 deltafs[
i] = frequpdate[
i] - tmpvec->
data[
i];
235 for (
i = 0;
i < nfreqs;
i++ ) {
236 deltafs[
i] = -frequpdate[
i];
241 fixfitwavesph = fitwavesphase;
242 if ( calcfitwaves ) {
243 const REAL8Vector *whichssb = dts != NULL ? dts : fixdts;
244 if ( origparams != NULL && fitwavesphase != NULL ) {
251 for (
i = 0;
i < length;
i++ ) {
252 REAL8 deltaphi = 0., innerphi = 0.;
261 Ddelay += ( dts->data[
i] - fixdts->data[
i] );
263 if ( fixdts != NULL ) {
264 deltat += fixdts->data[
i];
268 if ( bdts != NULL && fixbdts != NULL ) {
269 Ddelay += ( bdts->data[
i] - fixbdts->data[
i] );
271 if ( fixbdts != NULL ) {
272 deltat += fixbdts->data[
i];
277 for (
j = 0;
j < nfreqs;
j++ ) {
278 taylorcoeff = gsl_sf_fact(
j + 1 );
279 deltaphi += deltafs[
j] * deltatpow / taylorcoeff;
280 if ( Ddelay != 0. ) {
283 Ddelaypow = pow( Ddelay,
j + 1 );
284 for (
k = 0;
k <
j + 1;
k++ ) {
285 innerphi += gsl_sf_choose(
j + 1,
k ) * Ddelaypow * deltatpowinner;
286 deltatpowinner *= deltat;
289 deltaphi += innerphi * frequpdate[
j] / taylorcoeff;
295 if ( glph != NULL && fixglph != NULL ) {
296 deltaphi += ( glph->data[
i] - fixglph->data[
i] );
297 }
else if ( fixglph != NULL ) {
298 deltaphi += fixglph->data[
i];
302 if ( fitwavesph != NULL && fixfitwavesph != NULL ) {
303 deltaphi += ( fitwavesph->data[
i] - fixfitwavesph->data[
i] );
304 }
else if ( fixfitwavesph != NULL ) {
305 deltaphi += fixfitwavesph->data[
i];
308 deltaphi *= freqfactor;
309 phis->
data[
i] = deltaphi - floor( deltaphi );
316 if ( bdts != NULL ) {
319 if ( ssbdts == NULL ) {
322 if ( bsbdts == NULL ) {
325 if ( glph != NULL ) {
328 if ( glphase == NULL ) {
331 if ( fitwavesph != NULL ) {
334 if ( fitwavesphase == NULL ) {
380 INT4 i = 0, length = 0;
423 if ( pepoch == 0. && posepoch != 0. ) {
425 }
else if ( posepoch == 0. && pepoch != 0. ) {
429 length = datatimes->
length;
443 REAL8 absdec = fabs( dec );
446 dec = ( dec > 0 ? 1. : -1. ) * ( nwrap % 2 == 1 ? -1. : 1. ) * ( fmod( absdec +
LAL_PI_2,
LAL_PI ) -
LAL_PI_2 );
452 for (
i = 0;
i < length;
i++ ) {
456 bary.
delta = dec + ( realT - posepoch ) * pmdec;
457 bary.
alpha = ra + ( realT - posepoch ) * pmra / cos( bary.
delta );
519 for (
i = 0;
i < length;
i++ ) {
524 binput.
earth = earth;
571 if ( !earth || !tGPS || !
edat || !
edat->ephemE || !
edat->ephemS ) {
578 tinitE =
edat->ephemE[0].gps;
580 t0e = tgps[0] - tinitE;
583 if ( ( ientryE < 0 ) || ( ientryE >=
edat->nentriesE ) ) {
589 tdiffE = t0e -
edat->dtEtable * ientryE + tgps[1] * 1.e-9;
590 tdiff2E = tdiffE * tdiffE;
596 for (
j = 0;
j < 3;
j++ ) {
597 earth->
posNow[
j] =
pos[
j] + vel[
j] * tdiffE + 0.5 * acc[
j] * tdiff2E;
598 earth->
velNow[
j] = vel[
j] + acc[
j] * tdiffE;
627 if ( bsbdts != NULL ) {
635 length = datatimes->
length;
690 for (
i = 0;
i < length;
i++ ) {
691 glphase->
data[
i] = 0.;
693 if ( bsbdts != NULL ) {
694 tdt += bsbdts->
data[
i];
696 for (
UINT4 k = 0;
k < glnum;
k++ ) {
697 if ( tdt >= glep->
data[
k] ) {
698 REAL8 dtg = 0, expd = 1.;
699 dtg = tdt - glep->
data[
k];
700 if ( gltd[
k] != 0. ) {
701 expd = exp( -dtg / gltd[
k] );
703 glphase->
data[
i] += glph[
k] + glf0[
k] * dtg + 0.5 * glf1[
k] * dtg * dtg + ( 1. / 6. ) * glf2[
k] * dtg * dtg * dtg + glf0d[
k] * gltd[
k] * ( 1. - expd );
746 UINT4 i = 0, length = 0,
j = 0;
749 length = datatimes->
length;
766 REAL8 twave = 0., dtwave = 0.;
767 for (
i = 0;
i < length;
i++ ) {
772 for (
j = 0;
j < nwaves;
j++ ) {
773 twave += wsin->
data[
j] * sin( waveom * (
REAL8 )(
j + 1. ) * dtwave );
774 twave +=
wcos->data[
j] * cos( waveom * (
REAL8 )(
j + 1. ) * dtwave );
832 INT4 rectWindow = 0, expWindow = 0;
838 rectWindow = !strcmp( transientWindow,
"RECT" );
839 expWindow = !strcmp( transientWindow,
"EXP" );
842 if ( varyphase || useroq || rectWindow || expWindow ) {
864 XLAL_CHECK_NULL( freqfactor != 1. || nonGR != 1,
XLAL_EFUNC,
"A non-GR model is not defined for a frequency harmonic of 1" );
876 REAL8 siniota = sin( acos( cosiota ) );
877 REAL8 s2psi = 0., c2psi = 0., spsi = 0., cpsi = 0.;
880 s2psi = sin( twopsi );
881 c2psi = cos( twopsi );
891 COMPLEX16 Cplus = 0., Ccross = 0., Cx = 0., Cy = 0., Cl = 0., Cb = 0.;
894 if ( freqfactor == 1. ) {
897 COMPLEX16 expPhiTensor, expPsiTensor, expPhiScalar, expPsiScalar, expPhiVector, expPsiVector;
917 }
else if ( freqfactor == 2. ) {
920 COMPLEX16 expPhiTensor, expPsiTensor, expPhiScalar, expPsiScalar, expPhiVector, expPsiVector;
944 if ( varyphase || useroq || rectWindow || expWindow ) {
951 REAL8 plus00, plus01, cross00, cross01, plus = 0., cross = 0.;
952 REAL8 x00, x01, y00, y01, b00, b01, l00, l01;
953 REAL8 timeGPS, timeScaled, timeMin, timeMax;
954 REAL8 plusT = 0., crossT = 0.,
x = 0.,
y = 0., xT = 0., yT = 0., b = 0.,
l = 0.;
955 INT4 timebinMin, timebinMax;
963 if ( rectWindow && ( timeGPS < transientStartTime || timeGPS > transientStartTime + transientTau ) ) {
966 }
else if ( expWindow && timeGPS < transientStartTime ) {
972 timeMin = timebinMin * tsv;
973 timebinMax = (
INT4 )fmod( timebinMin + 1, resp->
ntimebins );
974 timeMax = timeMin + tsv;
984 timeScaled = (
T - timeMin ) / ( timeMax - timeMin );
986 plus = plus00 + ( plus01 - plus00 ) * timeScaled;
987 cross = cross00 + ( cross01 - cross00 ) * timeScaled;
989 plusT = plus * c2psi + cross * s2psi;
990 crossT = cross * c2psi - plus * s2psi;
993 x00 = resp->
fx->
data[timebinMin];
994 x01 = resp->
fx->
data[timebinMax];
995 y00 = resp->
fy->
data[timebinMin];
996 y01 = resp->
fy->
data[timebinMax];
997 b00 = resp->
fb->
data[timebinMin];
998 b01 = resp->
fb->
data[timebinMax];
999 l00 = resp->
fl->
data[timebinMin];
1000 l01 = resp->
fl->
data[timebinMax];
1002 x = x00 + ( x01 - x00 ) * timeScaled;
1003 y = y00 + ( y01 - y00 ) * timeScaled;
1004 b = b00 + ( b01 - b00 ) * timeScaled;
1005 l = l00 + ( l01 - l00 ) * timeScaled;
1007 xT =
x * cpsi +
y * spsi;
1008 yT =
y * cpsi -
x * spsi;
1012 csignal->
data->
data[
i] = ( Cplus * plusT ) + ( Ccross * crossT );
1016 csignal->
data->
data[
i] += ( Cx * xT ) + ( Cy * yT ) + Cb * b + Cl *
l;
1021 csignal->
data->
data[
i] *= exp( -( timeGPS - transientStartTime ) / transientTau );
1035 csignal->
data->
data[0] = ( Cplus * c2psi - Ccross * s2psi );
1036 csignal->
data->
data[1] = ( Cplus * s2psi + Ccross * c2psi );
1038 csignal->
data->
data[0] = ( Cplus * c2psi - Ccross * s2psi );
1039 csignal->
data->
data[1] = ( Cplus * s2psi + Ccross * c2psi );
1040 csignal->
data->
data[2] = ( Cx * cpsi - Cy * spsi );
1041 csignal->
data->
data[3] = ( Cx * spsi + Cy * cpsi );
1213 memcpy( &resp->
det, &det,
sizeof( det ) );
1226 REAL8 T = 0., Tstart = 0., Tav = 0., psi = 0.;
1228 REAL8 fplus = 0., fcross = 0., fx = 0., fy = 0., fb = 0., fl = 0.;
1234 if ( avedt == 60. ) {
1237 nav = floor( avedt / 60. ) + 1;
1240 for (
j = 0 ;
j < timeSteps ;
j++ ) {
1252 Tstart =
T - 0.5 * ( (
REAL8 )nav - 1. ) * 60.;
1254 Tstart =
T - ( 0.5 * (
REAL8 )nav - 1. ) * 60. - 30.;
1257 for (
k = 0;
k < nav;
k++ ) {
1258 Tav = Tstart + 60.*(
REAL8 )
k;
1291 if ( resp == NULL ) {
1295 if ( resp->
fplus ) {
1332 REAL8 sinlambda, coslambda, sinlambda2, coslambda2, sin2lambda;
1333 REAL8 theta, sintheta, costheta2, sintheta2, sin2theta;
1354 if ( ( q22 != 0. &&
dist != 0. ) && ( I21 == 0. && I21 == 0. && C21 == 0. && C22 == 0. ) ) {
1371 if ( phi22 == 0. ) {
1376 }
else if (
h0 != 0. ) {
1380 if ( phi22 == 0. ) {
1385 }
else if ( ( I21 != 0. || I31 != 0. ) && ( C22 == 0. && C21 == 0. ) ) {
1386 sinlambda = sin( lambda );
1387 coslambda = cos( lambda );
1388 sin2lambda = sin( 2. * lambda );
1389 sinlambda2 =
SQUARE( sinlambda );
1390 coslambda2 =
SQUARE( coslambda );
1393 sintheta = sin(
theta );
1394 sin2theta = sin( 2. *
theta );
1395 sintheta2 =
SQUARE( sintheta );
1398 REAL8 A22 = I21 * ( sinlambda2 - coslambda2 * costheta2 ) - I31 * sintheta2;
1403 REAL8 A21 = I21 * sin2lambda * sintheta;
1404 REAL8 B21 = sin2theta * ( I21 * coslambda2 - I31 );
1408 C22 = 2.*sqrt( A222 + B222 );
1409 C21 = 2.*sqrt( A212 + B212 );
void XLALBinaryPulsarDeltaTNew(BinaryPulsarOutput *output, BinaryPulsarInput *input, PulsarParameters *params)
function to calculate the binary system delay using new parameter structure
REAL8Vector * XLALHeterodynedPulsarPhaseDifference(PulsarParameters *params, PulsarParameters *origparams, const LIGOTimeGPSVector *datatimes, REAL8 freqfactor, REAL8Vector *ssbdts, UINT4 calcSSBDelay, REAL8Vector *bsbdts, UINT4 calcBSBDelay, REAL8Vector *glphase, UINT4 calcglphase, REAL8Vector *fitwavesphase, UINT4 calcfitwaves, const LALDetector *detector, const EphemerisData *ephem, const TimeCorrectionData *tdat, TimeCorrectionType ttype)
The phase evolution difference compared to a heterodyned phase (for a pulsar)
void XLALPulsarSourceToWaveformParams(PulsarParameters *params)
Convert source parameters into amplitude and phase notation parameters.
COMPLEX16TimeSeries * XLALHeterodynedPulsarGetAmplitudeModel(PulsarParameters *pars, REAL8 freqfactor, UINT4 varyphase, UINT4 useroq, UINT4 nonGR, const LIGOTimeGPSVector *timestamps, const DetResponseTimeLookupTable *resp)
The amplitude model of a complex heterodyned signal from the harmonics of a rotating neutron star.
COMPLEX16TimeSeries * XLALHeterodynedPulsarGetModel(PulsarParameters *pars, PulsarParameters *origpars, REAL8 freqfactor, UINT4 usephase, UINT4 useroq, UINT4 nonGR, const LIGOTimeGPSVector *timestamps, REAL8Vector *hetssbdelays, UINT4 calcSSBDelay, REAL8Vector *hetbsbdelays, UINT4 calcBSBDelay, REAL8Vector *glphase, UINT4 calcglphase, REAL8Vector *fitwavesphase, UINT4 calcfitwaves, const DetResponseTimeLookupTable *resp, const EphemerisData *ephem, const TimeCorrectionData *tdat, TimeCorrectionType ttype)
Generate the model of the neutron star signal.
void XLALDestroyDetResponseTimeLookupTable(DetResponseTimeLookupTable *resp)
Free memory for antenna response look-up table structure.
DetResponseTimeLookupTable * XLALDetResponseLookupTable(REAL8 t0, const LALDetector *det, REAL8 alpha, REAL8 delta, UINT4 timeSteps, REAL8 avedt)
Creates a lookup table of the detector antenna pattern.
#define SQUARE(x)
Macro to square a value.
REAL8Vector * XLALHeterodynedPulsarGetSSBDelay(PulsarParameters *pars, const LIGOTimeGPSVector *datatimes, const LALDetector *detector, const EphemerisData *ephem, const TimeCorrectionData *tdat, TimeCorrectionType ttype)
Computes the delay between a GPS time at Earth and the solar system barycentre.
#define ROUND(x)
Macro to round a value to the nearest integer.
void XLALGetEarthPosVel(EarthState *earth, const EphemerisData *edat, const LIGOTimeGPS *tGPS)
Get the position and velocity of the Earth at a given time.
REAL8Vector * XLALHeterodynedPulsarGetBSBDelay(PulsarParameters *pars, const LIGOTimeGPSVector *datatimes, const REAL8Vector *dts, const EphemerisData *edat)
Computes the delay between a pulsar in a binary system and the barycentre of the system.
REAL8Vector * XLALHeterodynedPulsarGetGlitchPhase(PulsarParameters *params, const LIGOTimeGPSVector *datatimes, const REAL8Vector *ssbdts, const REAL8Vector *bsbdts)
Computes the phase evolution due to the presence of glitches.
REAL8Vector * XLALHeterodynedPulsarGetFITWAVESPhase(PulsarParameters *params, const LIGOTimeGPSVector *datatimes, const REAL8Vector *ssbdts, REAL8 freq)
Computes the phase evolution due to the presence of FITWAVES parameters.
static double double delta
const REAL8Vector * PulsarGetREAL8VectorParam(const PulsarParameters *pars, const CHAR *name)
Return a REAL8Vector parameter.
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.
void PulsarAddParam(PulsarParameters *pars, const CHAR *name, void *value, PulsarParamType type)
Add a parameter and value to the PulsarParameters structure.
REAL8 PulsarGetREAL8Param(const PulsarParameters *pars, const CHAR *name)
Return a REAL8 parameter.
const CHAR * PulsarGetStringParam(const PulsarParameters *pars, const CHAR *name)
Return a string parameter.
REAL8 PulsarGetREAL8VectorParamIndividual(const PulsarParameters *pars, const CHAR *name)
Return an individual REAL8 value from a REAL8Vector parameter.
LIGOTimeGPSVector * timestamps
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...
void * XLALMalloc(size_t n)
void * XLALCalloc(size_t m, size_t n)
COMPLEX16TimeSeries * XLALCreateCOMPLEX16TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalSecondUnit
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
#define XLAL_ERROR_VOID(...)
#define XLAL_ERROR_NULL(...)
#define XLAL_CHECK_NULL(assertion,...)
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
structure containing the output parameters for the binary delay function
REAL8 deltaT
deltaT to add to TDB in order to account for binary
Pulsar signal-generation routines for heterodyned data.
REAL8 alpha
the source right ascension in radians
REAL8Vector * fb
scalar breathing mode polarisation response
REAL8 delta
the source declination in radians
LALDetector * det
detector
REAL8Vector * fl
scalar longitudinal mode polarisation response
REAL8 psi
the polarisation angle in radians
UINT4 ntimebins
number of time bins in the look-up table
REAL8Vector * fy
vector "y" polarisation response
REAL8Vector * fx
vector "x" polarisation response
REAL8Vector * fcross
tensor cross polarisation response
LIGOTimeGPS t0
GPS time epoch for the look-up table.
REAL8Vector * fplus
tensor plus polarisation response
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)
REAL8 roemer
the Roemer delay
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
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...