48#include <lal/LALBarycenter.h>
49#include <lal/LALInitBarycenter.h>
50#include <lal/DetectorSite.h>
52#include <lal/LogPrintf.h>
62 REAL8 abserr = fabs(
x - xapprox );
63 REAL8 absmean = 0.5 * fabs(
x + xapprox );
64 if ( absmean > 10 * LAL_REAL8_EPS ) {
65 return abserr / absmean;
75const INT4 t2000 = 630720013;
76const INT4 t1998 = 630720013 - 730 * 86400 - 1;
84 char eEphFileBad[] = TEST_DATA_DIR
"earth47.dat";
85 char eEphFile[] = TEST_DATA_DIR
"earth98.dat";
86 char sEphFile[] = TEST_DATA_DIR
"sun98.dat";
136 baryinput.alpha = 120;
137 baryinput.delta = 60;
148 REAL8 tau = 0, tau_opt = 0;
149 BarycenterBuffer *buffer = NULL;
155 for (
UINT4 k = 0;
k < 300;
k++ ) {
156 baryinput.alpha = ( 1.0 * rand() / RAND_MAX ) * LAL_TWOPI;
157 baryinput.delta = ( 1.0 * rand() / RAND_MAX ) * LAL_PI - LAL_PI_2;
158 baryinput.dInv = 0.e0;
162 REAL8 tPulse = t1998 + ( 1.0 * rand() / RAND_MAX ) * LAL_YRSID_SI;
164 baryinput.tgps = tGPS;
168 for (
UINT4 l = 0;
l < NRepeat;
l ++ ) {
172 tau += ( toc - tic ) / NRepeat;
176 for (
UINT4 l = 0;
l < NRepeat;
l ++ ) {
180 tau_opt += ( toc - tic ) / NRepeat;
184 diffEmissionTime( &thisDiff, &emit, &emit_opt );
185 absmaxEmissionTime( &maxDiffOpt, &maxDiffOpt, &thisDiff );
197 REAL8 maxEmitDiffOpt = maxErrInEmissionTime( &maxDiffOpt );
198 XLALPrintInfo(
"Max error (in seconds) between XLALBarycenter() and XLALBarycenterOpt() = %g s (tolerance = %g s)\n", maxEmitDiffOpt, tolerance );
200 "Max error (in seconds) between XLALBarycenter() and XLALBarycenterOpt() = %g s, exceeding tolerance of %g s\n",
201 maxEmitDiffOpt, tolerance );
202 printf(
"%g %g %d %d %g %g %g %g %g %g %g\n",
204 maxDiffOpt.deltaT, maxDiffOpt.te.gpsSeconds, maxDiffOpt.te.gpsNanoSeconds, maxDiffOpt.tDot,
205 maxDiffOpt.rDetector[0], maxDiffOpt.rDetector[1], maxDiffOpt.rDetector[2],
206 maxDiffOpt.vDetector[0], maxDiffOpt.vDetector[1], maxDiffOpt.vDetector[2]
210 XLALPrintError(
"Runtimes per function-call, averaged over %g calls\n", 1.0 * NRepeat * counter );
212 XLALPrintError(
"XLALBarycenterOpt() %g s (= %.1f %%)\n", tau_opt / counter, - 100 * ( tau - tau_opt ) / tau );
215 XLALPrintInfo(
"\n\nTesting XLALRestrictEphemerisData() ... " );
218 const INT4 orig_nentriesS =
edat->nentriesS;
219 for (
INT4 i = 1;
i <= 4; ++
i ) {
231 diff_nentriesS = ( (
i *
i +
i ) * 5 ) / 2 + 2 * (
i - 1 );
232 XLAL_CHECK( orig_nentriesS -
edat->nentriesS == diff_nentriesS,
XLAL_EFAILED,
"\nTest S%dA FAILED: nentries %d != %d\n",
i, orig_nentriesS -
edat->nentriesS, diff_nentriesS );
241 diff_nentriesS = ( (
i *
i +
i ) * 5 ) / 2 + 2 * (
i - 1 );
242 XLAL_CHECK( orig_nentriesS -
edat->nentriesS == diff_nentriesS,
XLAL_EFAILED,
"\nTest S%dB FAILED: nentries %d != %d\n",
i, orig_nentriesS -
edat->nentriesS, diff_nentriesS );
251 diff_nentriesS = ( (
i *
i +
i ) * 5 ) / 2 + 2 *
i;
252 XLAL_CHECK( orig_nentriesS -
edat->nentriesS == diff_nentriesS,
XLAL_EFAILED,
"\nTest S%dC FAILED: nentries %d != %d\n",
i, orig_nentriesS -
edat->nentriesS, diff_nentriesS );
256 const INT4 orig_nentriesE =
edat->nentriesE;
257 for (
INT4 i = 1;
i <= 4; ++
i ) {
269 diff_nentriesE = ( (
i *
i +
i ) * 5 ) / 2 + 2 * (
i - 1 );
270 XLAL_CHECK( orig_nentriesE -
edat->nentriesE == diff_nentriesE,
XLAL_EFAILED,
"\nTest E%dA FAILED: nentries %d != %d\n",
i, orig_nentriesE -
edat->nentriesE, diff_nentriesE );
279 diff_nentriesE = ( (
i *
i +
i ) * 5 ) / 2 + 2 * (
i - 1 );
280 XLAL_CHECK( orig_nentriesE -
edat->nentriesE == diff_nentriesE,
XLAL_EFAILED,
"\nTest E%dB FAILED: nentries %d != %d\n",
i, orig_nentriesE -
edat->nentriesE, diff_nentriesE );
289 diff_nentriesE = ( (
i *
i +
i ) * 5 ) / 2 + 2 *
i;
290 XLAL_CHECK( orig_nentriesE -
edat->nentriesE == diff_nentriesE,
XLAL_EFAILED,
"\nTest E%dC FAILED: nentries %d != %d\n",
i, orig_nentriesE -
edat->nentriesE, diff_nentriesE );
313 if ( !edat1 || !edat2 ) {
357 XLALPrintError(
" edat1 = %g, (%g, %g, %g), (%g, %g, %g), (%g, %g, %g)\n",
363 XLALPrintError(
" edat2 = %g, (%g, %g, %g), (%g, %g, %g), (%g, %g, %g)\n",
395 XLALPrintError(
" edat1 = %g, (%g, %g, %g), (%g, %g, %g), (%g, %g, %g)\n",
401 XLALPrintError(
" edat2 = %g, (%g, %g, %g), (%g, %g, %g), (%g, %g, %g)\n",
421 if ( diff == NULL ) {
442 if ( absmax == NULL ) {
#define __func__
log an I/O error, i.e.
LALDetectorIndexGEO600DIFF
void LALCheckMemoryLeaks(void)
int main(int argc, char **argv)
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
int XLALBarycenterOpt(EmissionTime *emit, const BarycenterInput *baryinput, const EarthState *earth, BarycenterBuffer **buffer)
Speed optimized version of XLALBarycenter(), should be fully equivalent except for the additional buf...
int XLALBarycenterEarth(EarthState *earth, const LIGOTimeGPS *tGPS, const EphemerisData *edat)
Computes the position and orientation of the Earth, at some arrival time , specified LIGOTimeGPS inp...
int XLALRestrictEphemerisData(EphemerisData *edat, const LIGOTimeGPS *startGPS, const LIGOTimeGPS *endGPS)
Restrict the EphemerisData 'edat' to the smallest number of entries required to cover the GPS time ra...
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...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
#define XLAL_INIT_DECL(var,...)
REAL8 XLALGetTimeOfDay(void)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_MAIN(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
Basic output structure of LALBarycenterEarth.c.
Basic output structure produced by LALBarycenter.c.
REAL8 deltaT
(TDB) - (GPS)
REAL8 rDetector[3]
Cartesian coords (0=x,1=y,2=z) of detector position at $t_a$ (GPS), in ICRS J2000 coords.
LIGOTimeGPS te
pulse emission time (TDB); also sometimes called `‘arrival time (TDB) of same wavefront at SSB’'
REAL8 tDot
d(emission time in TDB)/d(arrival time in GPS)
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
INT4 nentriesE
The number of entries in Earth ephemeris table.
REAL8 dtStable
The spacing in sec between consecutive instants in Sun ephemeris table.
PosVelAcc * ephemE
Array containing pos,vel,acc of earth, as extracted from earth ephem file.
INT4 nentriesS
The number of entries in Sun ephemeris table.
REAL8 dtEtable
The spacing in sec between consecutive instants in Earth ephemeris table.
PosVelAcc * ephemS
Array with pos, vel and acc for the sun (see ephemE)
REAL8 acc[3]
acceleration-vector
REAL8 gps
REAL8 timestamp.
REAL8 vel[3]
velocity-vector
REAL8 pos[3]
position-vector