LAL  7.5.0.1-b72065a
TimeDelay.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007 Jolien Creighton, and David Chin, and Steven
3  * Fairhurst, and Kipp Cannon, and Alexander Dietz, and Drew Keppel
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13  * Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include <math.h>
21 #include <lal/LALConstants.h>
22 #include <lal/LALDatatypes.h>
23 #include <lal/LALDetectors.h>
24 #include <lal/Date.h>
25 #include <lal/TimeDelay.h>
26 #include <lal/XLALError.h>
27 
28 
29 /* scalar product of two 3-vectors */
30 static double dotprod(const double vec1[3], const double vec2[3])
31 {
32  return vec1[0] * vec2[0] + vec1[1] * vec2[1] + vec1[2] * vec2[2];
33 }
34 
35 /** UNDOCUMENTED */
36 double
38  const double detector1_earthfixed_xyz_metres[3],
39  const double detector2_earthfixed_xyz_metres[3],
40  const double source_right_ascension_radians,
41  const double source_declination_radians,
42  const LIGOTimeGPS *gpstime
43 )
44 {
45  double delta_xyz[3];
46  double ehat_src[3];
47  const double greenwich_hour_angle = XLALGreenwichMeanSiderealTime(gpstime) - source_right_ascension_radians;
48 
49  if(XLAL_IS_REAL8_FAIL_NAN(greenwich_hour_angle))
51 
52  /*
53  * compute the unit vector pointing from the geocenter to the
54  * source
55  */
56 
57  ehat_src[0] = cos(source_declination_radians) * cos(greenwich_hour_angle);
58  ehat_src[1] = cos(source_declination_radians) * -sin(greenwich_hour_angle);
59  ehat_src[2] = sin(source_declination_radians);
60 
61  /*
62  * position of detector 2 with respect to detector 1
63  */
64 
65  delta_xyz[0] = detector2_earthfixed_xyz_metres[0] - detector1_earthfixed_xyz_metres[0];
66  delta_xyz[1] = detector2_earthfixed_xyz_metres[1] - detector1_earthfixed_xyz_metres[1];
67  delta_xyz[2] = detector2_earthfixed_xyz_metres[2] - detector1_earthfixed_xyz_metres[2];
68 
69  /*
70  * Arrival time at detector 1 - arrival time at detector 2. This
71  * is positive when the wavefront arrives at detector 1 after
72  * detector 2 (and so t at detector 1 is greater than t at detector
73  * 2).
74  */
75 
76  return dotprod(ehat_src, delta_xyz) / LAL_C_SI;
77 }
78 
79 
80 /**
81  * Compute difference in arrival time of the same signal at detector and at center of Earth-fixed frame.
82  */
84  const double detector_earthfixed_xyz_metres[3],
85  double source_right_ascension_radians,
86  double source_declination_radians,
87  const LIGOTimeGPS *gpstime
88 )
89 {
90  static const double earth_center[3] = {0.0, 0.0, 0.0};
91 
92  /*
93  * This is positive when the wavefront arrives at the detector
94  * after arriving at the geocentre.
95  */
96 
97  return XLALArrivalTimeDiff(detector_earthfixed_xyz_metres, earth_center, source_right_ascension_radians, source_declination_radians, gpstime);
98 }
99 
100 
101 /**
102  * Compute the light travel time between two detectors and returns the answer in \c INT8 nanoseconds.
103  */
104 INT8
106  const LALDetector *aDet,
107  const LALDetector *bDet
108 )
109 
110 {
111  double deltaLoc[3];
112 
113  deltaLoc[0] = aDet->location[0] - bDet->location[0];
114  deltaLoc[1] = aDet->location[1] - bDet->location[1];
115  deltaLoc[2] = aDet->location[2] - bDet->location[2];
116 
117  return (INT8) (1e9 * sqrt(dotprod(deltaLoc, deltaLoc)) / LAL_C_SI);
118 }
static double dotprod(const double vec1[3], const double vec2[3])
Definition: TimeDelay.c:30
#define LAL_C_SI
Speed of light in vacuum, m s^-1.
Definition: LALConstants.h:198
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
double XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
Compute difference in arrival time of the same signal at detector and at center of Earth-fixed frame.
Definition: TimeDelay.c:83
double XLALArrivalTimeDiff(const double detector1_earthfixed_xyz_metres[3], const double detector2_earthfixed_xyz_metres[3], const double source_right_ascension_radians, const double source_declination_radians, const LIGOTimeGPS *gpstime)
UNDOCUMENTED.
Definition: TimeDelay.c:37
INT8 XLALLightTravelTime(const LALDetector *aDet, const LALDetector *bDet)
Compute the light travel time between two detectors and returns the answer in INT8 nanoseconds.
Definition: TimeDelay.c:105
#define XLAL_ERROR_REAL8(...)
Macro to invoke a failure from a XLAL routine returning a REAL8.
Definition: XLALError.h:752
#define XLAL_IS_REAL8_FAIL_NAN(val)
Tests if val is a XLAL REAL8 failure NaN.
Definition: XLALError.h:393
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
Definition: XLALError.h:462
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
Convenience wrapper, calling XLALGreenwichSiderealTime() with the equation of equinoxes set to 0.
Detector structure.
Definition: LALDetectors.h:278
REAL8 location[3]
The three components, in an Earth-fixed Cartesian coordinate system, of the position vector from the ...
Definition: LALDetectors.h:279
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
Definition: LALDatatypes.h:458