00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 #include <math.h>
00084 #include <lal/LALConstants.h>
00085 #include <lal/LALStdlib.h>
00086 #include <lal/LALError.h>
00087 #include <lal/Date.h>
00088 #include <lal/SkyCoordinates.h>
00089 #include <lal/TimeDelay.h>
00090 #include <lal/XLALError.h>
00091
00092 NRCSID( TIMEDELAYC, "$Id: TimeDelay.c,v 1.23 2008/04/29 20:14:26 kipp Exp $" );
00093
00094
00095 static double dotprod(const double vec1[3], const double vec2[3])
00096 {
00097 return vec1[0] * vec2[0] + vec1[1] * vec2[1] + vec1[2] * vec2[2];
00098 }
00099
00100
00101
00102 double
00103 XLALArrivalTimeDiff(
00104 const double detector1_earthfixed_xyz_metres[3],
00105 const double detector2_earthfixed_xyz_metres[3],
00106 const double source_right_ascension_radians,
00107 const double source_declination_radians,
00108 const LIGOTimeGPS *gpstime
00109 )
00110 {
00111 static const char func[] = "XLALArrivalTimeDiff";
00112 double delta_xyz[3];
00113 double ehat_src[3];
00114 const double greenwich_hour_angle = XLALGreenwichMeanSiderealTime(gpstime) - source_right_ascension_radians;
00115
00116 if(XLAL_IS_REAL8_FAIL_NAN(greenwich_hour_angle))
00117 XLAL_ERROR_REAL8(func, XLAL_EFUNC);
00118
00119
00120
00121
00122
00123
00124 ehat_src[0] = cos(source_declination_radians) * cos(greenwich_hour_angle);
00125 ehat_src[1] = cos(source_declination_radians) * -sin(greenwich_hour_angle);
00126 ehat_src[2] = sin(source_declination_radians);
00127
00128
00129
00130
00131
00132 delta_xyz[0] = detector2_earthfixed_xyz_metres[0] - detector1_earthfixed_xyz_metres[0];
00133 delta_xyz[1] = detector2_earthfixed_xyz_metres[1] - detector1_earthfixed_xyz_metres[1];
00134 delta_xyz[2] = detector2_earthfixed_xyz_metres[2] - detector1_earthfixed_xyz_metres[2];
00135
00136
00137
00138
00139
00140
00141
00142
00143 return dotprod(ehat_src, delta_xyz) / LAL_C_SI;
00144 }
00145
00146
00147
00148 void
00149 LALTimeDelay(
00150 LALStatus *stat,
00151 REAL8 *p_time_diff,
00152 const TwoDetsTimeAndASource *p_dets_time_and_source
00153 )
00154 {
00155 INITSTATUS(stat, "LALTimeDelay", TIMEDELAYC);
00156 ATTATCHSTATUSPTR(stat);
00157 ASSERT(p_time_diff, stat, TIMEDELAYH_ENUL, TIMEDELAYH_MSGENUL);
00158 ASSERT(p_dets_time_and_source, stat, TIMEDELAYH_ENUL, TIMEDELAYH_MSGENUL);
00159
00160 XLALPrintDeprecationWarning("LALTimeDelay", "XLALArrivalTimeDiff");
00161
00162 *p_time_diff = -XLALArrivalTimeDiff(p_dets_time_and_source->p_det_and_time1->p_detector->location, p_dets_time_and_source->p_det_and_time2->p_detector->location, p_dets_time_and_source->p_source->longitude, p_dets_time_and_source->p_source->latitude, p_dets_time_and_source->p_det_and_time1->p_gps);
00163
00164 ASSERT(!XLAL_IS_REAL8_FAIL_NAN(*p_time_diff), stat, DATEH_ERANGEGPSABS, DATEH_MSGERANGEGPSABS);
00165
00166 DETATCHSTATUSPTR(stat);
00167 RETURN(stat);
00168 }
00169
00170
00171
00172 double XLALTimeDelayFromEarthCenter(
00173 const double detector_earthfixed_xyz_metres[3],
00174 double source_right_ascension_radians,
00175 double source_declination_radians,
00176 const LIGOTimeGPS *gpstime
00177 )
00178 {
00179 const double earth_center[3] = {0.0, 0.0, 0.0};
00180
00181
00182
00183
00184
00185
00186 return XLALArrivalTimeDiff(detector_earthfixed_xyz_metres, earth_center, source_right_ascension_radians, source_declination_radians, gpstime);
00187 }
00188
00189
00190
00191 void LALTimeDelayFromEarthCenter(
00192 LALStatus *stat,
00193 REAL8 *p_time_diff,
00194 const DetTimeAndASource *p_det_time_and_source
00195 )
00196 {
00197 INITSTATUS(stat, "LALTimeDelayFromEarthCenter", TIMEDELAYC);
00198 ATTATCHSTATUSPTR(stat);
00199 ASSERT(p_time_diff, stat, TIMEDELAYH_ENUL, TIMEDELAYH_MSGENUL);
00200 ASSERT(p_det_time_and_source, stat, TIMEDELAYH_ENUL, TIMEDELAYH_MSGENUL);
00201
00202 XLALPrintDeprecationWarning("LALTimeDelayFromEarthCenter", "XLALTimeDelayFromEarthCenter");
00203
00204 *p_time_diff = XLALTimeDelayFromEarthCenter(p_det_time_and_source->p_det_and_time->p_detector->location, p_det_time_and_source->p_source->longitude, p_det_time_and_source->p_source->latitude, p_det_time_and_source->p_det_and_time->p_gps);
00205
00206 ASSERT(!XLAL_IS_REAL8_FAIL_NAN(*p_time_diff), stat, DATEH_ERANGEGPSABS, DATEH_MSGERANGEGPSABS);
00207
00208 DETATCHSTATUSPTR(stat);
00209 RETURN(stat);
00210 }
00211
00212
00213
00214 INT8
00215 XLALLightTravelTime(
00216 const LALDetector *aDet,
00217 const LALDetector *bDet
00218 )
00219
00220 {
00221 double deltaLoc[3];
00222
00223 deltaLoc[0] = aDet->location[0] - bDet->location[0];
00224 deltaLoc[1] = aDet->location[1] - bDet->location[1];
00225 deltaLoc[2] = aDet->location[2] - bDet->location[2];
00226
00227 return (INT8) (1e9 * sqrt(dotprod(deltaLoc, deltaLoc)) / LAL_C_SI);
00228 }