25 #include <lal/LALStdlib.h>
27 #include <lal/AVFactories.h>
31 #define TESTLMSTC_DATESTRING 1
34 static BOOLEAN mstdate_ok_p(
const LALDate *p_date,
35 const LALDate *p_expected_date);
49 LALDate expected_mstdate;
51 LALPlaceAndDate place_and_date;
55 LALLeapSecAccuracy accuracy = LALLEAPSEC_STRICT;
66 date.unixDate.tm_sec = 0;
67 date.unixDate.tm_min = 0;
68 date.unixDate.tm_hour = 0;
69 date.unixDate.tm_mday = 16;
70 date.unixDate.tm_mon = 10;
71 date.unixDate.tm_year = 94;
72 date.residualNanoSeconds = 0;
78 LALUTCtoGPS(&stat, &gpstime, &
date, &accuracy);
81 fprintf(stderr,
"TestLMST: LALUTCtoGPS() failed, line %i, %s\n",
82 __LINE__, LALTESTLMSTC);
88 place_and_date.p_detector = &detector;
89 place_and_date.p_date = &
date;
91 LALGMST1(&stat, &gmstsecs, &
date, MST_SEC);
94 fprintf(stderr,
"TestLMST: LALGMST1() failed, line %i, %s\n",
95 __LINE__, LALTESTLMSTC);
100 LALSecsToLALDate(&stat, &mstdate, gmstsecs);
103 fprintf(stderr,
"TestLMST: LALSecsToLALDate() failed, line %i, %s\n",
104 __LINE__, LALTESTLMSTC);
114 expected_mstdate.residualNanoSeconds = 0.2738 * 1.e9;
115 expected_mstdate.unixDate.tm_sec = 21;
116 expected_mstdate.unixDate.tm_min = 39;
117 expected_mstdate.unixDate.tm_hour = 3;
119 if (!mstdate_ok_p(&mstdate, &expected_mstdate))
121 fprintf(stderr,
"TestLMST: ERROR: wrong sidereal time:\n");
123 sprintf(refstr,
" %02dh %02dm %02d", mstdate.unixDate.tm_hour,
124 mstdate.unixDate.tm_min, mstdate.unixDate.tm_sec);
125 sprintf(tmpstr,
"%.4fs", mstdate.residualNanoSeconds * 1.e-9);
126 strcat(refstr, tmpstr+1);
127 fprintf(stderr,
" GMST at 0h UTC on 1994-11-16:\n");
128 fprintf(stderr,
" get: %s\n", refstr);
130 sprintf(tmpstr,
" 03h 39m 21.2738s");
131 fprintf(stderr,
" expect: %s\n", tmpstr);
132 fprintf(stderr,
" but since we don't have the equation of equinoxes in, can\n");
133 fprintf(stderr,
" expect up to one sidereal second disagreement\n");
140 sprintf(refstr,
"%02dh %02dm %02d", mstdate.unixDate.tm_hour,
141 mstdate.unixDate.tm_min, mstdate.unixDate.tm_sec);
142 sprintf(tmpstr,
"%.4fs", mstdate.residualNanoSeconds * 1.e-9);
143 strcat(refstr, tmpstr+1);
144 printf(
"GMST at 0h UTC on 1994-11-16:\n");
145 printf(
" get: %s\n", refstr);
147 sprintf(tmpstr,
"03h 39m 21.2738s");
148 printf(
" expect: %s\n", tmpstr);
149 printf(
"but since we don't have the equation of equinoxes in, can\n");
150 printf(
"expect up to one sidereal second disagreement\n");
159 date.unixDate.tm_sec = 0;
160 date.unixDate.tm_min = 0;
161 date.unixDate.tm_hour = 0;
162 date.unixDate.tm_mday = 8;
163 date.unixDate.tm_mon = 7;
164 date.unixDate.tm_year = 94;
165 date.residualNanoSeconds = 0;
171 LALUTCtoGPS(&stat, &gpstime, &
date, &accuracy);
174 fprintf(stderr,
"TestLMST: LALUTCtoGPS() failed, line %i, %s\n",
175 __LINE__, LALTESTLMSTC);
181 place_and_date.p_detector = &detector;
182 place_and_date.p_date = &
date;
184 LALGMST1(&stat, &gmstsecs, &
date, MST_SEC);
187 fprintf(stderr,
"TestLMST: LALGMST1() failed, line %i, %s\n",
188 __LINE__, LALTESTLMSTC);
193 LALSecsToLALDate(&stat, &mstdate, gmstsecs);
196 fprintf(stderr,
"TestLMST: LALSecsToLALDate() failed, line %i, %s\n",
197 __LINE__, LALTESTLMSTC);
207 expected_mstdate.residualNanoSeconds = 0.9812*1.e9;
208 expected_mstdate.unixDate.tm_sec = 5;
209 expected_mstdate.unixDate.tm_min = 5;
210 expected_mstdate.unixDate.tm_hour = 21;
212 if (!mstdate_ok_p(&mstdate, &expected_mstdate))
214 fprintf(stderr,
"TestLMST: ERROR: wrong sidereal time:\n");
216 sprintf(refstr,
" %02dh %02dm %02d", mstdate.unixDate.tm_hour,
217 mstdate.unixDate.tm_min, mstdate.unixDate.tm_sec);
218 sprintf(tmpstr,
"%.4fs", mstdate.residualNanoSeconds * 1.e-9);
219 strcat(refstr, tmpstr+1);
220 fprintf(stderr,
" GMST at 0h UTC on 1994-08-08:\n");
221 fprintf(stderr,
" get: %s\n", refstr);
223 sprintf(tmpstr,
" 21h 05m 05.9812s");
224 fprintf(stderr,
" expect: %s\n", tmpstr);
225 fprintf(stderr,
" but since we don't have the equation of equinoxes in, can\n");
226 fprintf(stderr,
" expect up to one sidereal second disagreement\n");
233 sprintf(refstr,
"%02dh %02dm %02d", mstdate.unixDate.tm_hour,
234 mstdate.unixDate.tm_min, mstdate.unixDate.tm_sec);
235 sprintf(tmpstr,
"%.4fs", mstdate.residualNanoSeconds * 1.e-9);
237 printf(
"GMST at 0h UTC on 1994-08-08:\n");
238 strcat(refstr, tmpstr+1);
239 printf(
" get: %s\n", refstr);
241 sprintf(tmpstr,
"21h 05m 05.9812s");
242 printf(
" expect: %s\n", tmpstr);
243 printf(
"but since we don't have the equation of equinoxes in, can\n");
244 printf(
"expect up to one sidereal second disagreement\n");
256 date.unixDate.tm_sec = 0;
257 date.unixDate.tm_min = 0;
258 date.unixDate.tm_hour = 0;
259 date.unixDate.tm_mday = 11;
260 date.unixDate.tm_mon = 0;
261 date.unixDate.tm_year = 103;
262 date.residualNanoSeconds = 0;
268 LALUTCtoGPS(&stat, &gpstime, &
date, &accuracy);
271 fprintf(stderr,
"TestLMST: LALUTCtoGPS() failed, line %i, %s\n",
272 __LINE__, LALTESTLMSTC);
278 place_and_date.p_detector = &detector;
279 place_and_date.p_date = &
date;
281 LALGMST1(&stat, &gmstsecs, &
date, MST_SEC);
284 fprintf(stderr,
"TestLMST: LALGMST1() failed, line %i, %s\n",
285 __LINE__, LALTESTLMSTC);
290 LALSecsToLALDate(&stat, &mstdate, gmstsecs);
293 fprintf(stderr,
"TestLMST: LALSecsToLALDate() failed, line %i, %s\n",
294 __LINE__, LALTESTLMSTC);
304 expected_mstdate.residualNanoSeconds = 0.5980*1.e9;
305 expected_mstdate.unixDate.tm_sec = 21;
306 expected_mstdate.unixDate.tm_min = 20;
307 expected_mstdate.unixDate.tm_hour = 7;
309 if (!mstdate_ok_p(&mstdate, &expected_mstdate))
311 fprintf(stderr,
"TestLMST: ERROR: wrong sidereal time:\n");
313 sprintf(refstr,
" %02dh %02dm %02d", mstdate.unixDate.tm_hour,
314 mstdate.unixDate.tm_min, mstdate.unixDate.tm_sec);
315 sprintf(tmpstr,
"%.4fs", mstdate.residualNanoSeconds * 1.e-9);
316 strcat(refstr, tmpstr+1);
317 fprintf(stderr,
" GMST at 0h UTC on 2003-01-11:\n");
318 fprintf(stderr,
" get: %s\n", refstr);
320 sprintf(tmpstr,
" 07h 20m 21.5980s");
321 fprintf(stderr,
" expect: %s\n", tmpstr);
322 fprintf(stderr,
" but since we don't have the equation of equinoxes in, can\n");
323 fprintf(stderr,
" expect up to one sidereal second disagreement\n");
332 sprintf(refstr,
"%02dh %02dm %02d", mstdate.unixDate.tm_hour,
333 mstdate.unixDate.tm_min, mstdate.unixDate.tm_sec);
334 sprintf(tmpstr,
"%.4fs", mstdate.residualNanoSeconds * 1.e-9);
335 strcat(refstr, tmpstr+1);
337 printf(
"GMST at 0h UTC on 2003-01-11:\n");
338 printf(
" get: %s\n", refstr);
340 sprintf(tmpstr,
"07h 20m 21.5980s");
341 printf(
" expect: %s\n", tmpstr);
342 printf(
"but since we don't have the equation of equinoxes in, can\n");
343 printf(
"expect up to one sidereal second disagreement\n");
356 date.unixDate.tm_sec = 0;
357 date.unixDate.tm_min = 0;
358 date.unixDate.tm_hour = 0;
359 date.unixDate.tm_mday = 1;
360 date.unixDate.tm_mon = 4;
361 date.unixDate.tm_year = 103;
362 date.residualNanoSeconds = 0;
368 LALUTCtoGPS(&stat, &gpstime, &
date, &accuracy);
371 fprintf(stderr,
"TestLMST: LALUTCtoGPS() failed, line %i, %s\n",
372 __LINE__, LALTESTLMSTC);
378 place_and_date.p_detector = &detector;
379 place_and_date.p_date = &
date;
381 LALGMST1(&stat, &gmstsecs, &
date, MST_SEC);
384 fprintf(stderr,
"TestLMST: LALGMST1() failed, line %i, %s\n",
385 __LINE__, LALTESTLMSTC);
390 LALSecsToLALDate(&stat, &mstdate, gmstsecs);
393 fprintf(stderr,
"TestLMST: LALSecsToLALDate() failed, line %i, %s\n",
394 __LINE__, LALTESTLMSTC);
405 expected_mstdate.residualNanoSeconds = 0.6093*1.e9;
406 expected_mstdate.unixDate.tm_sec = 2;
407 expected_mstdate.unixDate.tm_min = 34;
408 expected_mstdate.unixDate.tm_hour = 14;
410 if (!mstdate_ok_p(&mstdate, &expected_mstdate))
412 fprintf(stderr,
"TestLMST: ERROR: wrong sidereal time:\n");
414 sprintf(refstr,
" %02dh %02dm %02d", mstdate.unixDate.tm_hour,
415 mstdate.unixDate.tm_min, mstdate.unixDate.tm_sec);
416 sprintf(tmpstr,
"%.4fs", mstdate.residualNanoSeconds * 1.e-9);
417 strcat(refstr, tmpstr+1);
418 fprintf(stderr,
" GMST at 0h UTC on 2003-04-01:\n");
419 fprintf(stderr,
" get: %s\n", refstr);
421 sprintf(tmpstr,
" 14h 34m 02.6093s ");
422 fprintf(stderr,
" expect: %s\n", tmpstr);
423 fprintf(stderr,
" but since we don't have the equation of equinoxes in, can\n");
424 fprintf(stderr,
" expect up to one sidereal second disagreement\n");
432 sprintf(refstr,
"%02dh %02dm %02d", mstdate.unixDate.tm_hour,
433 mstdate.unixDate.tm_min, mstdate.unixDate.tm_sec);
434 sprintf(tmpstr,
"%.4fs", mstdate.residualNanoSeconds * 1.e-9);
435 strcat(refstr, tmpstr+1);
437 printf(
"GMST at 0h UTC on 2003-04-01:\n");
438 printf(
" get: %s\n", refstr);
440 sprintf(tmpstr,
"14h 34m 02.6093s");
441 printf(
" expect: %s\n", tmpstr);
442 printf(
"but since we don't have the equation of equinoxes in, can\n");
443 printf(
"expect up to one sidereal second disagreement\n");
455 static BOOLEAN mstdate_ok_p(
const LALDate *p_date,
456 const LALDate *p_expected_date)
459 double secs, expected_secs;
461 secs = (double)((*p_date).unixDate.tm_sec) +
462 (*p_date).residualNanoSeconds / 1.e9;
463 expected_secs = (double)((*p_expected_date).unixDate.tm_sec) +
464 (*p_expected_date).residualNanoSeconds / 1.e9;
467 printf(
" secs = % 20.14e\n", secs);
468 printf(
"expected_secs = % 20.14e\n", expected_secs);
471 secs_ok_p = (fabs(secs - expected_secs) < 1.);
474 (*p_date).unixDate.tm_min == (*p_expected_date).unixDate.tm_min &&
475 (*p_date).unixDate.tm_hour == (*p_expected_date).unixDate.tm_hour);
void REPORTSTATUS(LALStatus *status)
unsigned char BOOLEAN
Boolean logical type, see Headers LAL(Atomic)Datatypes.h for more details.
double REAL8
Double precision real floating-point number (8 bytes).
LALFrDetector frDetector
The original LALFrDetector structure from which this was created.
REAL8 vertexLongitudeRadians
The geodetic longitude of the vertex in radians.
LAL status structure, see The LALStatus structure for more details.
INT4 statusCode
A numerical code identifying the type of error, or 0 for nominal status; Negative values are reserved...
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
INT4 gpsSeconds
Seconds since 0h UTC 6 Jan 1980.
INT4 gpsNanoSeconds
Residual nanoseconds.