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 = deltatpow;
205 frequpdate[
i] += ( freqsu->
data[
j] * deltatpowu ) / gsl_sf_fact(
j -
i );
206 deltatpowu *= deltat;
213 if ( origparams != NULL ) {
217 for (
i = 0;
i < nfreqs;
i++ ) {
220 deltafs[
i] = frequpdate[
i];
222 deltafs[
i] = frequpdate[
i] - tmpvec->
data[
i];
230 for (
i = 0;
i < nfreqs;
i++ ) {
231 deltafs[
i] = -frequpdate[
i];
236 fixfitwavesph = fitwavesphase;
237 if ( calcfitwaves ) {
238 const REAL8Vector *whichssb = dts != NULL ? dts : fixdts;
239 if ( origparams != NULL && fitwavesphase != NULL ) {
246 for (
i = 0;
i < length;
i++ ) {
247 REAL8 deltaphi = 0., innerphi = 0.;
256 Ddelay += ( dts->data[
i] - fixdts->data[
i] );
258 if ( fixdts != NULL ) {
259 deltat += fixdts->data[
i];
263 if ( bdts != NULL && fixbdts != NULL ) {
264 Ddelay += ( bdts->data[
i] - fixbdts->data[
i] );
266 if ( fixbdts != NULL ) {
267 deltat += fixbdts->data[
i];
272 for (
j = 0;
j < nfreqs;
j++ ) {
273 taylorcoeff = gsl_sf_fact(
j + 1 );
274 deltaphi += deltafs[
j] * deltatpow / taylorcoeff;
275 if ( Ddelay != 0. ) {
278 Ddelaypow = pow( Ddelay,
j + 1 );
279 for (
k = 0;
k <
j + 1;
k++ ) {
280 innerphi += gsl_sf_choose(
j + 1,
k ) * Ddelaypow * deltatpowinner;
281 deltatpowinner *= deltat;
284 deltaphi += innerphi * frequpdate[
j] / taylorcoeff;
290 if ( glph != NULL && fixglph != NULL ) {
291 deltaphi += ( glph->data[
i] - fixglph->data[
i] );
292 }
else if ( fixglph != NULL ) {
293 deltaphi += fixglph->data[
i];
297 if ( fitwavesph != NULL && fixfitwavesph != NULL ) {
298 deltaphi += ( fitwavesph->data[
i] - fixfitwavesph->data[
i] );
299 }
else if ( fixfitwavesph != NULL ) {
300 deltaphi += fixfitwavesph->data[
i];
303 deltaphi *= freqfactor;
304 phis->
data[
i] = deltaphi - floor( deltaphi );
311 if ( bdts != NULL ) {
314 if ( ssbdts == NULL ) {
317 if ( bsbdts == NULL ) {
320 if ( glph != NULL ) {
323 if ( glphase == NULL ) {
326 if ( fitwavesph != NULL ) {
329 if ( fitwavesphase == NULL ) {
375 INT4 i = 0, length = 0;
418 if ( pepoch == 0. && posepoch != 0. ) {
420 }
else if ( posepoch == 0. && pepoch != 0. ) {
424 length = datatimes->
length;
438 REAL8 absdec = fabs( dec );
441 dec = ( dec > 0 ? 1. : -1. ) * ( nwrap % 2 == 1 ? -1. : 1. ) * ( fmod( absdec +
LAL_PI_2,
LAL_PI ) -
LAL_PI_2 );
447 for (
i = 0;
i < length;
i++ ) {
451 bary.
delta = dec + ( realT - posepoch ) * pmdec;
452 bary.
alpha = ra + ( realT - posepoch ) * pmra / cos( bary.
delta );
514 for (
i = 0;
i < length;
i++ ) {
519 binput.
earth = earth;
566 if ( !earth || !tGPS || !
edat || !
edat->ephemE || !
edat->ephemS ) {
573 tinitE =
edat->ephemE[0].gps;
575 t0e = tgps[0] - tinitE;
578 if ( ( ientryE < 0 ) || ( ientryE >=
edat->nentriesE ) ) {
584 tdiffE = t0e -
edat->dtEtable * ientryE + tgps[1] * 1.e-9;
585 tdiff2E = tdiffE * tdiffE;
591 for (
j = 0;
j < 3;
j++ ) {
592 earth->
posNow[
j] =
pos[
j] + vel[
j] * tdiffE + 0.5 * acc[
j] * tdiff2E;
593 earth->
velNow[
j] = vel[
j] + acc[
j] * tdiffE;
622 if ( bsbdts != NULL ) {
630 length = datatimes->
length;
685 for (
i = 0;
i < length;
i++ ) {
686 glphase->
data[
i] = 0.;
688 if ( bsbdts != NULL ) {
689 tdt += bsbdts->
data[
i];
691 for (
UINT4 k = 0;
k < glnum;
k++ ) {
692 if ( tdt >= glep->
data[
k] ) {
693 REAL8 dtg = 0, expd = 1.;
694 dtg = tdt - glep->
data[
k];
695 if ( gltd[
k] != 0. ) {
696 expd = exp( -dtg / gltd[
k] );
698 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 );
741 UINT4 i = 0, length = 0,
j = 0;
744 length = datatimes->
length;
761 REAL8 twave = 0., dtwave = 0.;
762 for (
i = 0;
i < length;
i++ ) {
767 for (
j = 0;
j < nwaves;
j++ ) {
768 twave += wsin->
data[
j] * sin( waveom * (
REAL8 )(
j + 1. ) * dtwave );
769 twave +=
wcos->data[
j] * cos( waveom * (
REAL8 )(
j + 1. ) * dtwave );
827 INT4 rectWindow = 0, expWindow = 0;
833 rectWindow = !strcmp( transientWindow,
"RECT" );
834 expWindow = !strcmp( transientWindow,
"EXP" );
837 if ( varyphase || useroq || rectWindow || expWindow ) {
859 XLAL_CHECK_NULL( freqfactor != 1. || nonGR != 1,
XLAL_EFUNC,
"A non-GR model is not defined for a frequency harmonic of 1" );
871 REAL8 siniota = sin( acos( cosiota ) );
872 REAL8 s2psi = 0., c2psi = 0., spsi = 0., cpsi = 0.;
875 s2psi = sin( twopsi );
876 c2psi = cos( twopsi );
886 COMPLEX16 Cplus = 0., Ccross = 0., Cx = 0., Cy = 0., Cl = 0., Cb = 0.;
889 if ( freqfactor == 1. ) {
892 COMPLEX16 expPhiTensor, expPsiTensor, expPhiScalar, expPsiScalar, expPhiVector, expPsiVector;
912 }
else if ( freqfactor == 2. ) {
915 COMPLEX16 expPhiTensor, expPsiTensor, expPhiScalar, expPsiScalar, expPhiVector, expPsiVector;
939 if ( varyphase || useroq || rectWindow || expWindow ) {
946 REAL8 plus00, plus01, cross00, cross01, plus = 0., cross = 0.;
947 REAL8 x00, x01, y00, y01, b00, b01, l00, l01;
948 REAL8 timeGPS, timeScaled, timeMin, timeMax;
949 REAL8 plusT = 0., crossT = 0.,
x = 0.,
y = 0., xT = 0., yT = 0., b = 0.,
l = 0.;
950 INT4 timebinMin, timebinMax;
958 if ( rectWindow && ( timeGPS < transientStartTime || timeGPS > transientStartTime + transientTau ) ) {
961 }
else if ( expWindow && timeGPS < transientStartTime ) {
967 timeMin = timebinMin * tsv;
968 timebinMax = (
INT4 )fmod( timebinMin + 1, resp->
ntimebins );
969 timeMax = timeMin + tsv;
979 timeScaled = (
T - timeMin ) / ( timeMax - timeMin );
981 plus = plus00 + ( plus01 - plus00 ) * timeScaled;
982 cross = cross00 + ( cross01 - cross00 ) * timeScaled;
984 plusT = plus * c2psi + cross * s2psi;
985 crossT = cross * c2psi - plus * s2psi;
988 x00 = resp->
fx->
data[timebinMin];
989 x01 = resp->
fx->
data[timebinMax];
990 y00 = resp->
fy->
data[timebinMin];
991 y01 = resp->
fy->
data[timebinMax];
992 b00 = resp->
fb->
data[timebinMin];
993 b01 = resp->
fb->
data[timebinMax];
994 l00 = resp->
fl->
data[timebinMin];
995 l01 = resp->
fl->
data[timebinMax];
997 x = x00 + ( x01 - x00 ) * timeScaled;
998 y = y00 + ( y01 - y00 ) * timeScaled;
999 b = b00 + ( b01 - b00 ) * timeScaled;
1000 l = l00 + ( l01 - l00 ) * timeScaled;
1002 xT =
x * cpsi +
y * spsi;
1003 yT =
y * cpsi -
x * spsi;
1007 csignal->
data->
data[
i] = ( Cplus * plusT ) + ( Ccross * crossT );
1011 csignal->
data->
data[
i] += ( Cx * xT ) + ( Cy * yT ) + Cb * b + Cl *
l;
1016 csignal->
data->
data[
i] *= exp( -( timeGPS - transientStartTime ) / transientTau );
1030 csignal->
data->
data[0] = ( Cplus * c2psi - Ccross * s2psi );
1031 csignal->
data->
data[1] = ( Cplus * s2psi + Ccross * c2psi );
1033 csignal->
data->
data[0] = ( Cplus * c2psi - Ccross * s2psi );
1034 csignal->
data->
data[1] = ( Cplus * s2psi + Ccross * c2psi );
1035 csignal->
data->
data[2] = ( Cx * cpsi - Cy * spsi );
1036 csignal->
data->
data[3] = ( Cx * spsi + Cy * cpsi );
1208 memcpy( &resp->
det, &det,
sizeof( det ) );
1221 REAL8 T = 0., Tstart = 0., Tav = 0., psi = 0.;
1223 REAL8 fplus = 0., fcross = 0., fx = 0., fy = 0., fb = 0., fl = 0.;
1229 if ( avedt == 60. ) {
1232 nav = floor( avedt / 60. ) + 1;
1235 for (
j = 0 ;
j < timeSteps ;
j++ ) {
1247 Tstart =
T - 0.5 * ( (
REAL8 )nav - 1. ) * 60.;
1249 Tstart =
T - ( 0.5 * (
REAL8 )nav - 1. ) * 60. - 30.;
1252 for (
k = 0;
k < nav;
k++ ) {
1253 Tav = Tstart + 60.*(
REAL8 )
k;
1286 if ( resp == NULL ) {
1290 if ( resp->
fplus ) {
1327 REAL8 sinlambda, coslambda, sinlambda2, coslambda2, sin2lambda;
1328 REAL8 theta, sintheta, costheta2, sintheta2, sin2theta;
1349 if ( ( q22 != 0. &&
dist != 0. ) && ( I21 == 0. && I21 == 0. && C21 == 0. && C22 == 0. ) ) {
1366 if ( phi22 == 0. ) {
1371 }
else if (
h0 != 0. ) {
1375 if ( phi22 == 0. ) {
1380 }
else if ( ( I21 != 0. || I31 != 0. ) && ( C22 == 0. && C21 == 0. ) ) {
1381 sinlambda = sin( lambda );
1382 coslambda = cos( lambda );
1383 sin2lambda = sin( 2. * lambda );
1384 sinlambda2 =
SQUARE( sinlambda );
1385 coslambda2 =
SQUARE( coslambda );
1388 sintheta = sin(
theta );
1389 sin2theta = sin( 2. *
theta );
1390 sintheta2 =
SQUARE( sintheta );
1393 REAL8 A22 = I21 * ( sinlambda2 - coslambda2 * costheta2 ) - I31 * sintheta2;
1398 REAL8 A21 = I21 * sin2lambda * sintheta;
1399 REAL8 B21 = sin2theta * ( I21 * coslambda2 - I31 );
1403 C22 = 2.*sqrt( A222 + B222 );
1404 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 * XLALHeterodynedPulsarGetGlitchPhase(PulsarParameters *params, const LIGOTimeGPSVector *datatimes, const REAL8Vector *ssbdts, const REAL8Vector *bsbdts)
Computes the phase evolution due to the presence of glitches.
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.
void XLALPulsarSourceToWaveformParams(PulsarParameters *params)
Convert source parameters into amplitude and phase notation parameters.
void XLALDestroyDetResponseTimeLookupTable(DetResponseTimeLookupTable *resp)
Free memory for antenna response look-up table structure.
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.
#define SQUARE(x)
Macro to square a value.
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)
REAL8Vector * XLALHeterodynedPulsarGetFITWAVESPhase(PulsarParameters *params, const LIGOTimeGPSVector *datatimes, const REAL8Vector *ssbdts, REAL8 freq)
Computes the phase evolution due to the presence of FITWAVES parameters.
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.
#define ROUND(x)
Macro to round a value to the nearest integer.
DetResponseTimeLookupTable * XLALDetResponseLookupTable(REAL8 t0, const LALDetector *det, REAL8 alpha, REAL8 delta, UINT4 timeSteps, REAL8 avedt)
Creates a lookup table of the detector antenna pattern.
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.
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.
const CHAR * PulsarGetStringParam(const PulsarParameters *pars, const CHAR *name)
Return a string parameter.
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.
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 * XLALCalloc(size_t m, size_t n)
void * XLALMalloc(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...