21 #include <lal/FileIO.h>
22 #include <lal/LALBarycenter.h>
23 #include <lal/LALInitBarycenter.h>
24 #include <lal/ConfigFile.h>
25 #include <lal/LALString.h>
31 #define SQ(x) ((x) * (x))
32 #define NORM3D(x) ( SQ( (x)[0]) + SQ( (x)[1] ) + SQ ( (x)[2] ) )
33 #define LENGTH3D(x) ( sqrt( NORM3D ( (x) ) ) )
95 if ( !timeCorrectionFile ) {
124 if ( numLines - 1 !=
tdat->nentriesT ) {
139 for (
j = 1;
j < numLines;
j++ ) {
140 if ( ( ret = sscanf( flines->
lines->
tokens[
j],
"%lf", &tvec[
j - 1] ) ) != 1 ) {
151 tdat->timeCorrs = tvec;
207 const CHAR *sunEphemerisFile
213 if ( !earthEphemerisFile || !sunEphemerisFile ) {
214 XLAL_ERROR_NULL(
XLAL_EINVAL,
"Invalid NULL input earthEphemerisFile=%p, sunEphemerisFile=%p\n", earthEphemerisFile, sunEphemerisFile );
218 if ( strstr( earthEphemerisFile,
"DE200" ) ) {
220 }
else if ( strstr( earthEphemerisFile,
"DE405" ) ) {
222 }
else if ( strstr( earthEphemerisFile,
"DE414" ) ) {
224 }
else if ( strstr( earthEphemerisFile,
"DE421" ) ) {
226 }
else if ( strstr( earthEphemerisFile,
"DE430" ) ) {
233 if ( strstr( sunEphemerisFile,
"DE200" ) ) {
235 }
else if ( strstr( sunEphemerisFile,
"DE405" ) ) {
237 }
else if ( strstr( sunEphemerisFile,
"DE414" ) ) {
239 }
else if ( strstr( sunEphemerisFile,
"DE421" ) ) {
241 }
else if ( strstr( sunEphemerisFile,
"DE430" ) ) {
248 if ( earth_etype != sun_etype )
250 earthEphemerisFile, sunEphemerisFile, earth_etype, sun_etype );
262 REAL8 avgE[3] = {499.0, 1
e-4, 2
e-11 };
263 REAL8 rangeE[3] = {25.0, 1
e-5, 3
e-12 };
278 edat->dtEtable = ephemV->
dt;
291 REAL8 avgS[3] = { 2.7, 4.2e-8, 7.0e-16 };
292 REAL8 rangeS[3] = { 2.5, 1.4e-8, 2.8e-16 };
302 edat->dtStable = ephemV->
dt;
328 if (
edat->filenameE ) {
332 if (
edat->filenameS ) {
336 if (
edat->ephemE ) {
340 if (
edat->ephemS ) {
375 }
else if (
edat->nentriesE > 1 &&
edat->ephemE[
edat->nentriesE - 1].gps >
end &&
edat->ephemE[
edat->nentriesE - 2].gps >=
end ) {
385 memcpy( new_ephemE,
edat->ephemE,
edat->nentriesE *
sizeof( *new_ephemE ) );
386 edat->ephemE = new_ephemE;
395 }
else if (
edat->nentriesS > 1 &&
edat->ephemS[
edat->nentriesS - 1].gps >
end &&
edat->ephemS[
edat->nentriesS - 2].gps >=
end ) {
405 memcpy( new_ephemS,
edat->ephemS,
edat->nentriesS *
sizeof( *new_ephemS ) );
406 edat->ephemS = new_ephemS;
421 if ( ( ret =
XLALCalloc( 1,
sizeof( *ret ) ) ) == NULL ) {
446 if ( ephemV->
data ) {
461 XLALPulsarFileResolvePath(
const char *fname )
483 char *fname_path = NULL;
490 sprintf( fname_gz,
"%s.gz", fname );
516 if ( 3 != sscanf( flines->
lines->
tokens[0],
"%d %le %u\n", &gpsYr, &
dt, &nEntries ) ) {
522 if ( nEntries != ( numLines - 1 ) / 4 && nEntries != ( numLines - 1 ) ) {
524 INT4 dataLines = nEntries != ( numLines - 1 ) ? ( numLines - 1 ) : ( numLines - 1 ) / 4;
525 XLAL_ERROR_NULL(
XLAL_EDOM,
"Inconsistent number of data-lines (%d) in file '%s' compared to header information (%d)\n", dataLines, fname, nEntries );
551 for (
UINT4 j = 0;
j < nEntries;
j++ ) {
555 if ( nEntries == ( numLines - 1 ) / 4 ) {
559 XLAL_CHECK_NULL( ret == 3,
XLAL_EDOM,
"Couldn't parse line %d of %s: read %d items instead of 3\n", i_line, fname, ret );
563 XLAL_CHECK_NULL( ret == 3,
XLAL_EDOM,
"Couldn't parse line %d of %s: read %d items instead of 3\n", i_line, fname, ret );
567 XLAL_CHECK_NULL( ret == 3,
XLAL_EDOM,
"Couldn't parse line %d of %s: read %d items instead of 3\n", i_line, fname, ret );
571 XLAL_CHECK_NULL( ret == 1,
XLAL_EDOM,
"Couldn't parse line %d of %s: read %d items instead of 1\n", i_line, fname, ret );
574 ret = sscanf( flines->
lines->
tokens[ i_line ],
"%le %le %le %le %le %le %le %le %le %le\n",
579 XLAL_CHECK_NULL( ret == 10,
XLAL_EDOM,
"Couldn't parse line %d of %s: read %d items instead of 10\n", i_line, fname, ret );
584 if ( gpsYr - ephemV->
data[
j].
gps > 3600 * 24 * 365 ) {
627 for (
j = 0;
j < numEntries;
j ++ ) {
629 length = LENGTH3D( ephemV->
data[
j].
pos );
630 if ( fabs( avg[0] - length ) >
range[0] )
631 XLAL_ERROR(
XLAL_EDOM,
"Position out of range in entry %d: vr=(%le, %le, %le), sqrt{|vr|} = %le [%g +- %g]\n",
634 length = LENGTH3D( ephemV->
data[
j].
vel );
635 if ( fabs( avg[1] - length ) >
range[1] )
636 XLAL_ERROR(
XLAL_EDOM,
"Velocity out of range in entry %d: vv=(%le, %le, %le), sqrt{|vv|} = %le, [%g +- %g]\n",
639 length = LENGTH3D( ephemV->
data[
j].
acc );
640 if ( fabs( avg[2] - length ) >
range[2] )
641 XLAL_ERROR(
XLAL_EDOM,
"Acceleration out of range in entry %d: va=(%le, %le, %le), sqrt{|va|} = %le, [%g +- %g]\n",
int XLALParseDataFile(LALParsedDataFile **cfgdata, const CHAR *fname)
void XLALDestroyParsedDataFile(LALParsedDataFile *cfgdata)
#define XLAL_FILE_RESOLVE_PATH(fname)
void XLALDestroyEphemerisVector(EphemerisVector *ephemV)
Destructor for EphemerisVector, NULL robust.
EphemerisVector * XLALReadEphemerisFile(const CHAR *fname)
XLAL function to read ephemeris-data from one file, returning a EphemerisVector.
EphemerisType
Enumerated type denoting the JPL solar system ephemeris to be used in calculating barycentre time cor...
TimeCorrectionData * XLALInitTimeCorrections(const CHAR *timeCorrectionFile)
An XLAL interface for reading a time correction file containing a table of values for converting betw...
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 XLALCheckEphemerisRanges(const EphemerisVector *ephemEarth, REAL8 avg[3], REAL8 range[3])
Function to check rough consistency of ephemeris-data with being an actual 'Earth' ephemeris: ie chec...
void XLALDestroyTimeCorrectionData(TimeCorrectionData *tcd)
Destructor for TimeCorrectionData struct, NULL robust.
EphemerisVector * XLALCreateEphemerisVector(UINT4 length)
simple creator function for EphemerisVector type
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void * XLALCalloc(size_t m, size_t n)
void * XLALMalloc(size_t n)
char char * XLALStringDuplicate(const char *s)
#define XLAL_ERROR_NULL(...)
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_NULL(assertion,...)
int XLALGPSCmp(const LIGOTimeGPS *t0, const LIGOTimeGPS *t1)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
Generic ephemeris-vector type, holding one timeseries of pos, vel, acceleration.
REAL8 dt
spacing in seconds between consecutive instants in ephemeris table.
UINT4 length
number of ephemeris-data entries
PosVelAcc * data
array containing pos,vel,acc as extracted from ephem file.
Structure holding a REAL8 time, and a position, velocity and acceleration vector.
REAL8 acc[3]
acceleration-vector
REAL8 gps
REAL8 timestamp.
REAL8 vel[3]
velocity-vector
REAL8 pos[3]
position-vector
This structure will contain a vector of time corrections used during conversion from TT to TDB/TCB/Te...
CHAR * timeEphemeris
File containing the time ephemeris.
REAL8 * timeCorrs
Array of time delays for converting TT to TDB/TCB from the Time table (seconds).