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 #include <math.h>
00065 #include <stdlib.h>
00066 #include <errno.h>
00067
00068
00069
00070 #include <lal/LALStdlib.h>
00071 #include <lal/Date.h>
00072 #include <lal/TimeDelay.h>
00073 #include <lal/SkyCoordinates.h>
00074 #include <lal/DetectorSite.h>
00075
00076
00077 NRCSID( LALTESTDELAYC, "$Id: TestDelay.c,v 1.14 2007/06/08 14:41:43 bema Exp $" );
00078
00079
00080
00081 #define DOUBLE_EPSILON 1.0536712127723507013e-08
00082
00083
00084 int lalDebugLevel = 0;
00085
00086 int main(int argc, char **argv)
00087 {
00088 static LALStatus stat;
00089 LALFrDetector frdet1;
00090 LALFrDetector frdet2;
00091 LALDetector detector1;
00092 LALDetector detector2;
00093 LIGOTimeGPS gps;
00094 SkyPosition source;
00095 REAL8 delay;
00096 REAL8 difference;
00097 DetTimeAndASource det1_and_source;
00098
00099 LALPlaceAndGPS det1_and_gps;
00100
00101
00102 if (argc > 1)
00103 lalDebugLevel = atoi(argv[1]);
00104
00105
00106
00107
00108
00109
00110 source.longitude = 0.;
00111 source.latitude = 0.;
00112 source.system = COORDINATESYSTEM_EQUATORIAL;
00113
00114
00115
00116
00117
00118 strcpy(frdet1.name, "TEST IFO 1");
00119 frdet1.vertexLongitudeRadians = 0.;
00120 frdet1.vertexLatitudeRadians = 0.;
00121 frdet1.vertexElevation = 0.;
00122 frdet1.xArmAltitudeRadians = 0.;
00123 frdet1.xArmAzimuthRadians = 0.;
00124 frdet1.yArmAltitudeRadians = LAL_PI_2;
00125 frdet1.yArmAzimuthRadians = 0.;
00126
00127 LALCreateDetector(&stat, &detector1, &frdet1, LALDETECTORTYPE_IFODIFF);
00128 if (stat.statusCode && lalDebugLevel > 0)
00129 {
00130 fprintf(stderr, "TestDelay: LALCreateDetector failed, line %i, %s\n",
00131 __LINE__, LALTESTDELAYC);
00132 REPORTSTATUS(&stat);
00133 return stat.statusCode;
00134 }
00135 if (lalDebugLevel > 2)
00136 REPORTSTATUS(&stat);
00137
00138
00139
00140
00141
00142
00143 if (fabs(detector1.location[0] - LAL_REARTH_SI)/LAL_REARTH_SI > 1.e-4 ||
00144 detector1.location[1] != 0. ||
00145 detector1.location[2] != 0.)
00146 {
00147 fprintf(stderr, "TestDelay: LALCreateDetector output is wrong, line %i, %s\n",
00148 __LINE__, LALTESTDELAYC);
00149 fprintf(stderr, "Got Det #1 location: (% 16.8e, % 16.8e, % 16.8e)\n",
00150 (float)detector1.location[0], (float)detector1.location[1],
00151 (float)detector1.location[2]);
00152 fprintf(stderr, "Expected: (% 16.8e, % 16.8e, % 16.8e)\n",
00153 (float)LAL_REARTH_SI, 0., 0.);
00154
00155 return(1);
00156 }
00157
00158 if (lalDebugLevel > 2)
00159 printf("Det #1 location: (%7.4e, %7.4e, %7.4e)\n",
00160 detector1.location[0], detector1.location[1],
00161 detector1.location[2]);
00162
00163
00164 strcpy(frdet2.name, "TEST IFO 2");
00165 frdet2.vertexLongitudeRadians = LAL_PI_2;
00166 frdet2.vertexLatitudeRadians = 0.;
00167 frdet2.vertexElevation = 0.;
00168 frdet2.xArmAltitudeRadians = 0.;
00169 frdet2.xArmAzimuthRadians = 0.;
00170 frdet2.yArmAltitudeRadians = 0.;
00171 frdet2.yArmAzimuthRadians = LAL_PI_2;
00172
00173 LALCreateDetector(&stat, &detector2, &frdet2, LALDETECTORTYPE_IFODIFF);
00174 if (stat.statusCode && lalDebugLevel > 0)
00175 {
00176 fprintf(stderr, "TestDelay: LALCreateDetector failed, line %i, %s\n",
00177 __LINE__, LALTESTDELAYC);
00178 REPORTSTATUS(&stat);
00179 return stat.statusCode;
00180 }
00181 if (lalDebugLevel > 2)
00182 REPORTSTATUS(&stat);
00183
00184
00185
00186
00187
00188 gps.gpsSeconds = 60858;
00189 gps.gpsNanoSeconds = 0;
00190
00191 det1_and_gps.p_detector = &detector1;
00192 det1_and_gps.p_gps = &gps;
00193
00194 det1_and_source.p_det_and_time = &det1_and_gps;
00195 det1_and_source.p_source = &source;
00196
00197 LALTimeDelayFromEarthCenter(&stat, &delay, &det1_and_source);
00198 if (stat.statusCode && lalDebugLevel > 0)
00199 {
00200 fprintf(stderr,
00201 "TestDelay: LALTimeDelayFromEarthCenter() failed, line %i, %s\n",
00202 __LINE__, LALTESTDELAYC);
00203 REPORTSTATUS(&stat);
00204 return stat.statusCode;
00205 }
00206 if (lalDebugLevel > 2)
00207 REPORTSTATUS(&stat);
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223 if (lalDebugLevel > 2)
00224 {
00225 printf("delay = %20.14e\n", delay);
00226 printf("Rearth / c = %20.14e\n", (REAL8)LAL_REARTH_SI /
00227 (REAL8)LAL_C_SI);
00228 }
00229
00230 difference = fabs(delay) - (REAL8)LAL_REARTH_SI / (REAL8)LAL_C_SI;
00231
00232 if (difference < DOUBLE_EPSILON)
00233 {
00234 return 0;
00235 }
00236 else
00237 {
00238 fprintf(stderr, "ERROR: computed delay differs from expected delay by amount greater than DOUBLE_EPSILON (% 14.8e); difference = % 14.8e\n",
00239 DOUBLE_EPSILON, difference);
00240 return 1;
00241 }
00242 }