Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALBarycenterTest.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 Miroslav Shaltev, R Prix
3* Copyright (C) 2007 Curt Cutler, David Chin, Jolien Creighton, Reinhard Prix, Teviet Creighton
4*
5* This program is free software; you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation; either version 2 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with with program; see the file COPYING. If not, write to the
17* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18* MA 02110-1301 USA
19*/
20
21/**
22 * \author Curt Cutler
23 * \date 2001
24 * \file
25 * \ingroup LALBarycenter_h
26 * \brief Tests the routine XLALBarycenter(): exercises some of the error
27 * conditions and makes sure that they work.
28 *
29 * ### Program <tt>LALBarycenterTest.c</tt> ###
30 *
31 *
32 * ### Usage ###
33 *
34 * \code
35 * LALBarycenterTest
36 * \endcode
37 *
38 * ### Description ###
39 *
40 * This program demonstrates the use of XLALBarycenter.c.
41 * The two ephemeris files specified in the EphemerisFilenames
42 * structure (e.g., for data taken in 1998, <tt>sun98.dat</tt> and <tt>earth98.dat</tt>)
43 * are assumed to be in the same directory as the program as
44 * the test program.
45 *
46 */
47
48#include <lal/LALBarycenter.h>
49#include <lal/LALInitBarycenter.h>
50#include <lal/DetectorSite.h>
51#include <lal/Date.h>
52#include <lal/LogPrintf.h>
53
54/** \cond DONT_DOXYGEN */
55
56/* ----- internal prototype ---------- */
57int compare_ephemeris( const EphemerisData *edat1, const EphemerisData *edat2 );
58REAL8 relerr( REAL8 x, REAL8 xapprox );
59
60inline REAL8 relerr( REAL8 x, REAL8 xapprox )
61{
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;
66 } else {
67 return abserr;
68 }
69}
70
71int diffEmissionTime( EmissionTime *diff, const EmissionTime *emit1, const EmissionTime *emit2 );
72int absmaxEmissionTime( EmissionTime *absmax, const EmissionTime *demit1, const EmissionTime *demit2 );
73REAL8 maxErrInEmissionTime( const EmissionTime *demit );
74
75const INT4 t2000 = 630720013; /* gps time at Jan 1, 2000 00:00:00 UTC */
76const INT4 t1998 = 630720013 - 730 * 86400 - 1; /* gps at Jan 1,1998 00:00:00 UTC*/
77
78// ----------------------------------------------------------------------
79
80int
81main( void )
82{
83
84 char eEphFileBad[] = TEST_DATA_DIR "earth47.dat";
85 char eEphFile[] = TEST_DATA_DIR "earth98.dat";
86 char sEphFile[] = TEST_DATA_DIR "sun98.dat";
87
88 /* Checking response if data files not present */
89 EphemerisData *edat = XLALInitBarycenter( eEphFileBad, sEphFile );
90 XLAL_CHECK_MAIN( edat == NULL, XLAL_EFAILED, "Expected XLALInitBarycenter( '%s', '%s' ) to fail!", eEphFileBad, sEphFile );
92
93 /* Now inputting kosher ephemeris. files and leap sec, to illustrate
94 * proper usage. The real, serious TEST of the code is a script written
95 * by Rejean Dupuis comparing XLALBarycenter to TEMPO for thousands
96 * of source positions and times.
97 */
98 XLAL_CHECK_MAIN( ( edat = XLALInitBarycenter( eEphFile, sEphFile ) ) != NULL, XLAL_EFUNC );
99
100 /* ========================================================================== */
101
102
103 /* The routines using XLALBarycenter package, the code above, leading
104 up XLALInitBarycenter() call, should be near top of main. The idea is
105 that ephemeris data is read into RAM once, at the beginning.
106
107 NOTE that the only part of the piece of the LALDetector structure
108 baryinput.site that has to be filled in by the driver code is
109 the 3-vector: baryinput.site.location[] .
110
111 NOTE that the driver code that calls XLALInitBarycenter() must
112 XLALDestroyEphemerisData(edat).
113 */
114
115 /* Now getting coords for detector */
116 LALDetector cachedDetector;
118
119 BarycenterInput XLAL_INIT_DECL( baryinput );
120 baryinput.site.location[0] = cachedDetector.location[0] / LAL_C_SI;
121 baryinput.site.location[1] = cachedDetector.location[1] / LAL_C_SI;
122 baryinput.site.location[2] = cachedDetector.location[2] / LAL_C_SI;
123
124 EarthState earth;
125 EmissionTime emit, emit_opt;
126
127 /* ----- Checking error messages when the timestamp is not within the 1-yr ephemeris files */
128 LIGOTimeGPS tGPS = {t1998 + 5e7, 0 };
129 XLAL_CHECK_MAIN( XLALBarycenterEarth( &earth, &tGPS, edat ) == XLAL_FAILURE, XLAL_EFAILED, "Expected XLALBarycenterEarth() to fail!" );
131
132 /* next try calling for bad choice of RA,DEC (e.g., something sensible in degrees, but radians)*/
133 tGPS.gpsSeconds = t1998 + 3600;
135
136 baryinput.alpha = 120;
137 baryinput.delta = 60;
138 baryinput.dInv = 0;
139
140 XLAL_CHECK_MAIN( XLALBarycenter( &emit, &baryinput, &earth ) == XLAL_FAILURE, XLAL_EFAILED, "Expected XLALBarycenter() to fail!" );
142
143 /* ---------- Now running program w/o errors, to illustrate proper use. ---------- */
144 EmissionTime XLAL_INIT_DECL( maxDiffOpt );
145 REAL8 tic, toc;
146 UINT4 NRepeat = 1;
147 UINT4 counter = 0;
148 REAL8 tau = 0, tau_opt = 0;
149 BarycenterBuffer *buffer = NULL;
150
151 unsigned int seed = XLALGetTimeOfDay();
152 srand( seed );
153
154 /* Outer loop over different sky positions */
155 for ( UINT4 k = 0; k < 300; k++ ) {
156 baryinput.alpha = ( 1.0 * rand() / RAND_MAX ) * LAL_TWOPI; // in [0, 2pi]
157 baryinput.delta = ( 1.0 * rand() / RAND_MAX ) * LAL_PI - LAL_PI_2;// in [-pi/2, pi/2]
158 baryinput.dInv = 0.e0;
159
160 /* inner loop over pulse arrival times */
161 for ( UINT4 i = 0; i < 100; i++ ) {
162 REAL8 tPulse = t1998 + ( 1.0 * rand() / RAND_MAX ) * LAL_YRSID_SI; // t in [1998, 1999]
163 XLALGPSSetREAL8( &tGPS, tPulse );
164 baryinput.tgps = tGPS;
165
167 tic = XLALGetTimeOfDay();
168 for ( UINT4 l = 0; l < NRepeat; l ++ ) {
169 XLAL_CHECK( XLALBarycenter( &emit, &baryinput, &earth ) == XLAL_SUCCESS, XLAL_EFAILED );
170 }
171 toc = XLALGetTimeOfDay();
172 tau += ( toc - tic ) / NRepeat;
173
174 /* ----- optimized XLAL version with buffering ---------- */
175 tic = XLALGetTimeOfDay();
176 for ( UINT4 l = 0; l < NRepeat; l ++ ) {
177 XLAL_CHECK( XLALBarycenterOpt( &emit_opt, &baryinput, &earth, &buffer ) == XLAL_SUCCESS, XLAL_EFAILED );
178 }
179 toc = XLALGetTimeOfDay();
180 tau_opt += ( toc - tic ) / NRepeat;
181
182 /* collect maximal deviations over all struct-fields of 'emit' */
183 EmissionTime thisDiff;
184 diffEmissionTime( &thisDiff, &emit, &emit_opt );
185 absmaxEmissionTime( &maxDiffOpt, &maxDiffOpt, &thisDiff );
186
187 counter ++;
188 } /* for i */
189
190 } /* for k */
191
192 XLALFree( buffer );
193 buffer = NULL;
194
195 /* ----- check differences in results ---------- */
196 REAL8 tolerance = 1e-9; // in seconds: can't go beyond nanosecond precision due to GPS limitation
197 REAL8 maxEmitDiffOpt = maxErrInEmissionTime( &maxDiffOpt );
198 XLALPrintInfo( "Max error (in seconds) between XLALBarycenter() and XLALBarycenterOpt() = %g s (tolerance = %g s)\n", maxEmitDiffOpt, tolerance );
199 XLAL_CHECK( maxEmitDiffOpt < tolerance, XLAL_EFAILED,
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",
203 maxEmitDiffOpt,
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]
207 );
208
209 /* ----- output runtimes ---------- */
210 XLALPrintError( "Runtimes per function-call, averaged over %g calls\n", 1.0 * NRepeat * counter );
211 XLALPrintError( "XLALBarycenter() %g s\n", tau / counter );
212 XLALPrintError( "XLALBarycenterOpt() %g s (= %.1f %%)\n", tau_opt / counter, - 100 * ( tau - tau_opt ) / tau );
213
214 /* ===== test XLALRestrictEphemerisData() ===== */
215 XLALPrintInfo( "\n\nTesting XLALRestrictEphemerisData() ... " );
216 {
217 XLAL_CHECK( edat->nentriesS >= 100, XLAL_EFAILED );
218 const INT4 orig_nentriesS = edat->nentriesS;
219 for ( INT4 i = 1; i <= 4; ++i ) {
220 REAL8 start, end;
221 LIGOTimeGPS startGPS, endGPS;
222 INT4 diff_nentriesS;
223
224 start = edat->ephemS[2 * i].gps;
225 end = edat->ephemS[edat->nentriesS - 1 - 3 * i].gps;
226 XLAL_CHECK( XLALGPSSetREAL8( &startGPS, start ) != NULL, XLAL_EFUNC );
227 XLAL_CHECK( XLALGPSSetREAL8( &endGPS, end ) != NULL, XLAL_EFUNC );
229 XLAL_CHECK( edat->ephemS[0].gps == start, XLAL_EFAILED, "\nTest S%dA FAILED: %0.9f != start %0.9f\n", i, edat->ephemS[0].gps, start );
230 XLAL_CHECK( edat->ephemS[edat->nentriesS - 1].gps == end, XLAL_EFAILED, "\nTest S%dA FAILED: end %0.9f != %0.9f\n", i, edat->ephemS[edat->nentriesS - 1].gps, end );
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 );
233
234 XLAL_CHECK( XLALGPSSetREAL8( &startGPS, start + 0.5 * edat->dtStable ) != NULL, XLAL_EFUNC );
235 XLAL_CHECK( XLALGPSSetREAL8( &endGPS, end - 0.5 * edat->dtStable ) != NULL, XLAL_EFUNC );
236 start = edat->ephemS[0].gps;
237 end = edat->ephemS[edat->nentriesS - 1].gps;
239 XLAL_CHECK( edat->ephemS[0].gps == start, XLAL_EFAILED, "\nTest S%dB FAILED: start %0.9f != %0.9f\n", i, edat->ephemS[0].gps, start );
240 XLAL_CHECK( edat->ephemS[edat->nentriesS - 1].gps == end, XLAL_EFAILED, "\nTest S%dB FAILED: end %0.9f != %0.9f\n", i, edat->ephemS[edat->nentriesS - 1].gps, end );
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 );
243
244 XLAL_CHECK( XLALGPSSetREAL8( &startGPS, start + 1.5 * edat->dtStable ) != NULL, XLAL_EFUNC );
245 XLAL_CHECK( XLALGPSSetREAL8( &endGPS, end - 1.5 * edat->dtStable ) != NULL, XLAL_EFUNC );
246 start = edat->ephemS[1].gps;
247 end = edat->ephemS[edat->nentriesS - 2].gps;
249 XLAL_CHECK( edat->ephemS[0].gps == start, XLAL_EFAILED, "\nTest S%dC FAILED: start %0.9f != %0.9f\n", i, edat->ephemS[0].gps, start );
250 XLAL_CHECK( edat->ephemS[edat->nentriesS - 1].gps == end, XLAL_EFAILED, "\nTest S%dC FAILED: end %0.9f != %0.9f\n", i, edat->ephemS[edat->nentriesS - 1].gps, end );
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 );
253 }
254
255 XLAL_CHECK( edat->nentriesE >= 100, XLAL_EFAILED );
256 const INT4 orig_nentriesE = edat->nentriesE;
257 for ( INT4 i = 1; i <= 4; ++i ) {
258 REAL8 start, end;
259 LIGOTimeGPS startGPS, endGPS;
260 INT4 diff_nentriesE;
261
262 start = edat->ephemE[2 * i].gps;
263 end = edat->ephemE[edat->nentriesE - 1 - 3 * i].gps;
264 XLAL_CHECK( XLALGPSSetREAL8( &startGPS, start ) != NULL, XLAL_EFUNC );
265 XLAL_CHECK( XLALGPSSetREAL8( &endGPS, end ) != NULL, XLAL_EFUNC );
267 XLAL_CHECK( edat->ephemE[0].gps == start, XLAL_EFAILED, "\nTest E%dA FAILED: %0.9f != start %0.9f\n", i, edat->ephemE[0].gps, start );
268 XLAL_CHECK( edat->ephemE[edat->nentriesE - 1].gps == end, XLAL_EFAILED, "\nTest E%dA FAILED: end %0.9f != %0.9f\n", i, edat->ephemE[edat->nentriesE - 1].gps, end );
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 );
271
272 XLAL_CHECK( XLALGPSSetREAL8( &startGPS, start + 0.5 * edat->dtEtable ) != NULL, XLAL_EFUNC );
273 XLAL_CHECK( XLALGPSSetREAL8( &endGPS, end - 0.5 * edat->dtEtable ) != NULL, XLAL_EFUNC );
274 start = edat->ephemE[0].gps;
275 end = edat->ephemE[edat->nentriesE - 1].gps;
277 XLAL_CHECK( edat->ephemE[0].gps == start, XLAL_EFAILED, "\nTest E%dB FAILED: start %0.9f != %0.9f\n", i, edat->ephemE[0].gps, start );
278 XLAL_CHECK( edat->ephemE[edat->nentriesE - 1].gps == end, XLAL_EFAILED, "\nTest E%dB FAILED: end %0.9f != %0.9f\n", i, edat->ephemE[edat->nentriesE - 1].gps, end );
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 );
281
282 XLAL_CHECK( XLALGPSSetREAL8( &startGPS, start + 1.5 * edat->dtEtable ) != NULL, XLAL_EFUNC );
283 XLAL_CHECK( XLALGPSSetREAL8( &endGPS, end - 1.5 * edat->dtEtable ) != NULL, XLAL_EFUNC );
284 start = edat->ephemE[1].gps;
285 end = edat->ephemE[edat->nentriesE - 2].gps;
287 XLAL_CHECK( edat->ephemE[0].gps == start, XLAL_EFAILED, "\nTest E%dC FAILED: start %0.9f != %0.9f\n", i, edat->ephemE[0].gps, start );
288 XLAL_CHECK( edat->ephemE[edat->nentriesE - 1].gps == end, XLAL_EFAILED, "\nTest E%dC FAILED: end %0.9f != %0.9f\n", i, edat->ephemE[edat->nentriesE - 1].gps, end );
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 );
291 }
292 }
293 XLALPrintInfo( "PASSED\n\n" );
294
296
298
299 XLALPrintError( "==> OK. All tests successful!\n\n" );
300
301 return 0;
302
303} /* main() */
304
305
306/**
307 * Function to test equivalence between two loaded ephemeris-data structs.
308 * Note: we compare everything *except* the ephiles fields, which are actually useless.
309 */
310int
311compare_ephemeris( const EphemerisData *edat1, const EphemerisData *edat2 )
312{
313 if ( !edat1 || !edat2 ) {
314 XLALPrintError( "%s: invalid NULL input edat1=%p, edat2=%p\n", __func__, edat1, edat2 );
316 }
317
318 if ( edat1->nentriesE != edat2->nentriesE ) {
319 XLALPrintError( "%s: different nentriesE (%d != %d)\n", __func__, edat1->nentriesE, edat2->nentriesE );
321 }
322 if ( edat1->nentriesS != edat2->nentriesS ) {
323 XLALPrintError( "%s: different nentriesS (%d != %d)\n", __func__, edat1->nentriesS, edat2->nentriesS );
325 }
326 if ( edat1->dtEtable != edat2->dtEtable ) {
327 XLALPrintError( "%s: different dtEtable (%g != %g)\n", __func__, edat1->dtEtable, edat2->dtEtable );
329 }
330 if ( edat1->dtStable != edat2->dtStable ) {
331 XLALPrintError( "%s: different dtStable (%g != %g)\n", __func__, edat1->dtStable, edat2->dtStable );
333 }
334
335 /* compare earth ephemeris data */
336 if ( !edat1->ephemE || !edat2->ephemE ) {
337 XLALPrintError( "%s: invalid NULL ephemE pointer edat1 (%p), edat2 (%p)\n", __func__, edat1->ephemE, edat2->ephemE );
339 }
340 INT4 i;
341 for ( i = 0; i < edat1->nentriesE; i ++ ) {
342 if ( edat1->ephemE[i].gps != edat2->ephemE[i].gps ||
343
344 edat1->ephemE[i].pos[0] != edat2->ephemE[i].pos[0] ||
345 edat1->ephemE[i].pos[1] != edat2->ephemE[i].pos[1] ||
346 edat1->ephemE[i].pos[2] != edat2->ephemE[i].pos[2] ||
347
348 edat1->ephemE[i].vel[0] != edat2->ephemE[i].vel[0] ||
349 edat1->ephemE[i].vel[1] != edat2->ephemE[i].vel[1] ||
350 edat1->ephemE[i].vel[2] != edat2->ephemE[i].vel[2] ||
351
352 edat1->ephemE[i].acc[0] != edat2->ephemE[i].acc[0] ||
353 edat1->ephemE[i].acc[1] != edat2->ephemE[i].acc[1] ||
354 edat1->ephemE[i].acc[2] != edat2->ephemE[i].acc[2]
355 ) {
356 XLALPrintError( "%s: Inconsistent earth-entry %d:\n", __func__, i );
357 XLALPrintError( " edat1 = %g, (%g, %g, %g), (%g, %g, %g), (%g, %g, %g)\n",
358 edat1->ephemE[i].gps,
359 edat1->ephemE[i].pos[0], edat1->ephemE[i].pos[1], edat1->ephemE[i].pos[2],
360 edat1->ephemE[i].vel[0], edat1->ephemE[i].vel[1], edat1->ephemE[i].vel[2],
361 edat1->ephemE[i].acc[0], edat1->ephemE[i].acc[1], edat1->ephemE[i].acc[2]
362 );
363 XLALPrintError( " edat2 = %g, (%g, %g, %g), (%g, %g, %g), (%g, %g, %g)\n",
364 edat2->ephemE[i].gps,
365 edat2->ephemE[i].pos[0], edat2->ephemE[i].pos[1], edat2->ephemE[i].pos[2],
366 edat2->ephemE[i].vel[0], edat2->ephemE[i].vel[1], edat2->ephemE[i].vel[2],
367 edat2->ephemE[i].acc[0], edat2->ephemE[i].acc[1], edat2->ephemE[i].acc[2]
368 );
370 } /* if difference in data-set i */
371
372 } /* for i < nentriesE */
373
374 /* compare sun ephemeris data */
375 if ( !edat1->ephemS || !edat2->ephemS ) {
376 XLALPrintError( "%s: invalid NULL ephemS pointer edat1 (%p), edat2 (%p)\n", __func__, edat1->ephemS, edat2->ephemS );
378 }
379 for ( i = 0; i < edat1->nentriesS; i ++ ) {
380 if ( edat1->ephemS[i].gps != edat2->ephemS[i].gps ||
381
382 edat1->ephemS[i].pos[0] != edat2->ephemS[i].pos[0] ||
383 edat1->ephemS[i].pos[1] != edat2->ephemS[i].pos[1] ||
384 edat1->ephemS[i].pos[2] != edat2->ephemS[i].pos[2] ||
385
386 edat1->ephemS[i].vel[0] != edat2->ephemS[i].vel[0] ||
387 edat1->ephemS[i].vel[1] != edat2->ephemS[i].vel[1] ||
388 edat1->ephemS[i].vel[2] != edat2->ephemS[i].vel[2] ||
389
390 edat1->ephemS[i].acc[0] != edat2->ephemS[i].acc[0] ||
391 edat1->ephemS[i].acc[1] != edat2->ephemS[i].acc[1] ||
392 edat1->ephemS[i].acc[2] != edat2->ephemS[i].acc[2]
393 ) {
394 XLALPrintError( "%s: Inconsistent sun-entry %d:\n", __func__, i );
395 XLALPrintError( " edat1 = %g, (%g, %g, %g), (%g, %g, %g), (%g, %g, %g)\n",
396 edat1->ephemS[i].gps,
397 edat1->ephemS[i].pos[0], edat1->ephemS[i].pos[1], edat1->ephemS[i].pos[2],
398 edat1->ephemS[i].vel[0], edat1->ephemS[i].vel[1], edat1->ephemS[i].vel[2],
399 edat1->ephemS[i].acc[0], edat1->ephemS[i].acc[1], edat1->ephemS[i].acc[2]
400 );
401 XLALPrintError( " edat2 = %g, (%g, %g, %g), (%g, %g, %g), (%g, %g, %g)\n",
402 edat2->ephemS[i].gps,
403 edat2->ephemS[i].pos[0], edat2->ephemS[i].pos[1], edat2->ephemS[i].pos[2],
404 edat2->ephemS[i].vel[0], edat2->ephemS[i].vel[1], edat2->ephemS[i].vel[2],
405 edat2->ephemS[i].acc[0], edat2->ephemS[i].acc[1], edat2->ephemS[i].acc[2]
406 );
408 } /* if difference in data-set i */
409
410 } /* for i < nentriesE */
411
412 /* everything seems fine */
413 return XLAL_SUCCESS;
414
415} /* compare_ephemeris() */
416
417/* return differences in all fields from EmissionTime struct */
418int
419diffEmissionTime( EmissionTime *diff, const EmissionTime *emit1, const EmissionTime *emit2 )
420{
421 if ( diff == NULL ) {
422 return -1;
423 }
424
425 diff->deltaT = emit1->deltaT - emit2->deltaT;
426 diff->te.gpsSeconds = emit1->te.gpsSeconds - emit2->te.gpsSeconds;
427 diff->te.gpsNanoSeconds = emit1->te.gpsNanoSeconds - emit2->te.gpsNanoSeconds;
428 diff->tDot = emit1->tDot - emit2->tDot;
429 for ( UINT4 i = 0; i < 3; i ++ ) {
430 diff->rDetector[i] = emit1->rDetector[i] - emit2->rDetector[i];
431 diff->vDetector[i] = emit1->vDetector[i] - emit2->vDetector[i];
432 }
433
434 return 0;
435
436} /* DiffEmissionTime() */
437
438/* return max ( fabs ( de1, e2 ) ) on all struct fields of 'de1' and 'de2' respectively */
439int
440absmaxEmissionTime( EmissionTime *absmax, const EmissionTime *demit1, const EmissionTime *demit2 )
441{
442 if ( absmax == NULL ) {
443 return -1;
444 }
445
446 absmax->deltaT = fmax( fabs( demit1->deltaT ), fabs( demit2->deltaT ) );
447 absmax->te.gpsSeconds = fmax( abs( demit1->te.gpsSeconds ), abs( demit2->te.gpsSeconds ) );
448 absmax->te.gpsNanoSeconds = fmax( abs( demit1->te.gpsNanoSeconds ), abs( demit2->te.gpsNanoSeconds ) );
449 absmax->tDot = fmax( fabs( demit1->tDot ), fabs( demit2->tDot ) );
450 for ( UINT4 i = 0; i < 3; i ++ ) {
451 absmax->rDetector[i] = fmax( fabs( demit1->rDetector[i] ), fabs( demit2->rDetector[i] ) );
452 absmax->vDetector[i] = fmax( fabs( demit1->vDetector[i] ), fabs( demit2->vDetector[i] ) );
453 }
454
455 return 0;
456
457} /* absmaxEmissionTime() */
458
459/* return maximal struct entry from 'demit' */
460REAL8
461maxErrInEmissionTime( const EmissionTime *demit )
462{
463 REAL8 maxdiff = 0;
464 maxdiff = fmax( maxdiff, fabs( demit->deltaT ) );
465 maxdiff = fmax( maxdiff, abs( demit->te.gpsSeconds ) );
466 maxdiff = fmax( maxdiff, 1e-9 * abs( demit->te.gpsNanoSeconds ) );
467 maxdiff = fmax( maxdiff, fabs( demit->tDot ) );
468 for ( UINT4 i = 0; i < 3; i ++ ) {
469 maxdiff = fmax( maxdiff, fabs( demit->rDetector[i] ) );
470 maxdiff = fmax( maxdiff, fabs( demit->vDetector[i] ) );
471 }
472 return maxdiff;
473}
474
475/** \endcond */
#define __func__
log an I/O error, i.e.
LALDetectorIndexGEO600DIFF
int k
void LALCheckMemoryLeaks(void)
int l
double e
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...
Definition: LALBarycenter.c:78
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.
double REAL8
#define XLAL_INIT_DECL(var,...)
uint32_t UINT4
int32_t INT4
void XLALFree(void *p)
REAL8 XLALGetTimeOfDay(void)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_MAIN(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int XLALClearErrno(void)
XLAL_SUCCESS
XLAL_EFUNC
XLAL_EINVAL
XLAL_EFAILED
XLAL_FAILURE
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
end
Basic input structure to LALBarycenter.c.
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)
REAL8 vDetector[3]
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 location[3]
INT4 gpsNanoSeconds
REAL8 acc[3]
acceleration-vector
REAL8 gps
REAL8 timestamp.
REAL8 vel[3]
velocity-vector
REAL8 pos[3]
position-vector