HOPS
HOPS class reference
htime.h
Go to the documentation of this file.
1 /*
2  * $Id: htime.h 3802 2008-12-21 01:12:04Z gbc $
3  *
4  * Hete time utilities, hacked for Ibex, hacked for Hops.
5  *
6  * Copyright (C) 1998-2010 by MIT & gbc.
7  */
8 
9 #ifndef HTIME_H
10 #define HTIME_H
11 
12 /* set this nonzero for HETE */
13 #define HETE_PECULIAR 0
14 
15 #include "hetetimecode.h"
16 #include <time.h>
17 #include <sys/time.h>
18 #include <math.h>
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <string.h>
22 
23 //now needs hops_config in order to determine if long HTLdbl is supported
24 #include "time_float_type.h"
25 
26 //upper limit on number of weeks count, this is ~157 years
27 #define MAX_WEEKS 8192
28 
29 
30 /*
31  * various environment variables are littered about, based on history:
32  * HETE_OPS - root of ops tree for HETE
33  * HETE_TIME_EPOCH - epoch of HETE digital watch
34  * IBEX_DATACALSC - directory for s/c calibration
35  * IBEX_OPS - root of ops tree for IBEX
36  * IBEX_TIME_EPOCH - epoch of IBEX
37  * HOPS_VDIF_EPOCH - epoch of VDIF times
38  * HOPS_JULIAN_EPOCH - epoch of julian dates/times
39  * since the IBEX clock was never really calculated, most of this
40  * machinery wasn't really used for IBEX--the IBEX clock is essentially
41  * synonymous with GPS.
42  *
43  * and all this needs to become more general....
44  */
45 
46 /*
47  * Basic calibration %s is HETE_OPS and %1x is the digital watch id.
48 #define TAI_UTC_DATA "%s/data/calibration/sc/tai-utc.dat"
49 #define Ht_LIFETIMES "%s/data/calibration/sc/gps-dw%1x.dat"
50  */
51 #define TAI_UTC_DATA "%s/%s/tai-utc.dat"
52 #define Ht_LIFETIMES "%s/%s/gps-dw%1x.dat"
53 #define Ht_IBEXTIMES "%s/%s/gps-sc%1x.dat"
54 #define Ht_DATACALSC "data/calibration/sc"
55 
56 /*
57  * Time in the pizza boxes and on HETE is maintained as a
58  * count of microseconds. It is initialized at boot to the
59  * value maintained by a digital watch.
60  *
61  * CF: hetetimecode.h
62  */
63 typedef time_code HTime; /* S/C Clock: epoch + 3words */
64 
65 /*
66  * The epoch will switch between these cases:
67  * HETE: 3 words are count of us on flight clock
68  * IBEX: 2 words are 32-bit count of MET (~GPS) seconds, 1 word of MET ms.
69  */
70 
71 /*
72  * Atomic time is encoded as HTLdbl precision floating point, representing
73  * seconds relative to the GPS epoch of 0000.0 6 January 1980 UTC.
74  * The resolution of this encoding is 1/8 microsecond for the time of
75  * the HETE mission.
76  *
77  * CF: http://tycho.usno.navy.mil
78  */
79 
80 typedef HTLdbl GTime; /* Time in s since GPS epoch */
81 typedef HTLdbl HtErr; /* approximate error estimate */
82 
83 /*
84  * For operational convenience, the unix timeval structure is
85  * useful for many timekeeping operations. It currently differs
86  * from the GPS standard only by some number of leap seconds:
87  *
88  * As of 1 March 1999,
89  * TAI is ahead of UTC by 32 seconds.
90  * TAI is ahead of GPS by 19 seconds.
91  * GPS is ahead of UTC by 13 seconds.
92  * As of 19 Feb 2008 we have another ls (2006) so
93  * TAI is ahead of UTC by 33 seconds.
94  * TAI is ahead of GPS by 19 seconds.
95  * GPS is ahead of UTC by 14 seconds.
96  * As of Aug 2008 we'll have a new one in 2009 so
97  * TAI is ahead of UTC by 34 seconds.
98  * TAI is ahead of GPS by 19 seconds.
99  * GPS is ahead of UTC by 15 seconds.
100  *
101  * Expect the next leapsecond in January or July 2009, maybe....
102  *
103  * CF: sys/time.h
104  */
105 #define TAI_GPS_DELTA 19/*seconds*/
106 #define JD_GPS_EPOCH (2444239.5 + 5.0)/*days*/
107 #define JD_UNIX_EPOCH (2440587.5)/*days*/
108 /*
109  * To see ticking clocks:
110  * http://www.leapsecond.com/java/gpsclock.htm
111  * which expresses 4 time systems in a civilian time representation.
112  *
113  * http://tycho.usno.navy.mil/systime.html
114  * is a good reference on time systems. As is
115  * http://en.wikipedia.org/wiki/Ephemeris_time
116  * and other wiki articles. For more general work TDT (terrestrial
117  * dynamical time aka TT) is useful, and
118  *
119  * 1977 Jan 1.0003725 TT == 1977 Jan 1.0000000 TAI == JD 2443144.5
120  *
121  * so that TT - TAI == 32.184 s (0.0003725 day)
122  * and TAI - GPS == 19.000 s (always)
123  * and TAI - UTC == 33.000 s (as I type this in Feb 2008) abd
124  * and GPS - UTC == 14.000 s (as I type this in Feb 2008), so
125  * TT - UTC == 65.184 s (")
126  * TT - GPS == 51.184 s (always)
127  *
128  * http://maia.usno.navy.mil/
129  * has the current data.
130  * https://cdf.gsfc.nasa.gov/html/CDFLeapSeconds.txt
131  * is a copy
132  */
133 #define TDT_TAI_DELTA 32.184/*seconds*/
134 #define TDT_GPS_DELTA 51.184/*seconds*/
135 
136 /* this is a reference time where the above are correct */
137 #define J2000_EPOCH 630763200.000000
138 /* the SPICE ephemeris time origin lies at this time in gps epoch: */
139 #define SPICE_ET_ORIGIN 630763148.816000
140 /* i.e. 51.184 second earlier */
141 
142 /* for breaking symmetry on similar large numbers */
143 #define SPICE_ET_TYPE_GPS 0
144 #define SPICE_ET_TYPE_TAI 1
145 #define SPICE_ET_TYPE_TDT 2
146 #define SPICE_ET_TYPE_TDB 3
147 #define SPICE_ET_TYPE_UTC 4
148 
149 /*
150  * HOPS rootcode is number of 4-sec periods since midnight Jan1 1979.
151  * -q K 19790101_000000
152  * -q K 2018-02-26T15:45:04
153  */
154 #define HOPS_ROOT_EPOCH 283996800
155 #define HOPS_ROOT_BREAK 1519659904
156 
157 /*
158  * Support routine for ephemeris time, returning leapseconds since
159  * the J2000 ephemeris, and a convenience function pinning down
160  * leapseconds within a year. (Note, Jan 1 leap seconds are part
161  * of the previous year--the calendar year starts a second later.)
162  */
165 
166 /*
167  * in the spice leap second kernel
168  * DELTET/DELTA_T_A = 32.184
169  * DELTET/DELTA_AT = ( ... 32, 33, 34 ... )
170  */
171 
172 typedef struct timeval UTime; /* UNIX time: tv_sec,tv_usec */
173 
174 /*
175  * Note that the Unix system time may be provided in HTime format:
176  *
177  * 0020 0000 0000 0000 = Thu Jan 1 00:00:00 1970
178  * 0020 4000 0000 0000 = Sat Mar 25 10:52:24 1972
179  * 0020 8000 0000 0000 = Mon Jun 17 21:44:48 1974
180  * 0020 c000 0000 0000 = Thu Sep 9 08:37:12 1976
181  * 0021 0000 0000 0000 = Sat Dec 2 19:29:36 1978
182  * 0021 4000 0000 0000 = Tue Feb 24 06:22:00 1981
183  * 0021 8000 0000 0000 = Thu May 19 17:14:25 1983
184  * 0021 c000 0000 0000 = Sun Aug 11 04:06:49 1985
185  * 0022 0000 0000 0000 = Tue Nov 3 14:59:13 1987
186  * 0022 4000 0000 0000 = Fri Jan 26 01:51:37 1990
187  * 0022 8000 0000 0000 = Sun Apr 19 12:44:01 1992
188  * 0022 c000 0000 0000 = Tue Jul 12 23:36:25 1994
189  * 0023 0000 0000 0000 = Fri Oct 4 10:28:50 1996 EPOCH_UNIX(3)
190  * 0023 4000 0000 0000 = Sun Dec 27 21:21:14 1998 EPOCH_UNIX(3)
191  * 0023 8000 0000 0000 = Wed Mar 21 08:13:38 2001 EPOCH_UNIX(3)
192  * 0023 c000 0000 0000 = Fri Jun 13 19:06:02 2003 EPOCH_UNIX(3)
193  * 0024 0000 0000 0000 = Mon Sep 5 05:58:26 2005 EPOCH_UNIX(4)
194  * 0024 4000 0000 0000 = Wed Nov 28 16:50:51 2007 EPOCH_UNIX(4)
195  * 0024 8000 0000 0000 = Sat Feb 20 03:43:15 2010 EPOCH_UNIX(4)
196  * 0024 c000 0000 0000 = Mon May 14 14:35:39 2012 EPOCH_UNIX(4)
197  *
198  * And since it's easy to get confused (2^20 us ~= 10^6 us)...
199  *
200  * ctime(...) lowest epoch byte: 0X 1X 2X
201  * 0x00000000 = Thu Jan 1 00:00:00 1970 NULL DW0 X
202  * 0x10000000 = Tue Jul 4 21:24:16 1978 UNSYNC DW1 X
203  * 0x20000000 = Mon Jan 5 18:48:32 1987 HUBSYNC DW2 X
204  * 0x30000000 = Sun Jul 9 16:12:48 1995 X DW3 ~UNIX(3)
205  * 0x40000000 = Sat Jan 10 13:37:04 2004 X DW4 ~UNIX(4)
206  * 0x50000000 = Fri Jul 13 11:01:20 2012 X DW5 ~UNIX(5)
207  * 0x60000000 = Thu Jan 14 08:25:36 2021 X DW6 ~UNIX(6)
208  * 0x70000000 = Wed Jul 18 05:49:52 2029 X DW7 ~UNIX(7)
209  * 0x7FFFFFFF = Tue Jan 19 03:14:08 2038 X X X
210  */
211 
212 /*
213  * Epoch 003X will be used for IBEX--see hetetimecode.h
214  */
215 #define THIS_IS_IBEX ((Ht_hete_epoch & 0x30) == 0x30)
216 #define EPOCH_IBEX(N) (0x30|(N))
217 
218 /*
219  * Processor lifetime management structure.
220  *
221  * This is used to create/maintain a linked list of lifetimes.
222  * Each lifetime represents a piecewise linear mapping among the
223  * sc clock, UTC, and GPS time. New lifetimes are begun when
224  * either the s/c has rebooted or a significant event occurs.
225  */
226 typedef struct sc_life HLife; /* a particular HETE lifetime */
227 struct sc_life {
228  GTime start; /* time of birth in GPS epoch */
229  HTLdbl span; /* effective lifetime in secs */
230  HTime birth; /* effective sc time of birth */
231  HTLdbl error; /* start--birth error in secs */
232  HTLdbl dsc_dt; /* effective d(sctime) / d(t) */
233  HTLdbl esc_dt; /* error in d(sctime) / d(t) */
234  HLife *last; /* pointer to a previous life */
235  HLife *next; /* pointer to subsequent life */
236  char comment[40]; /* describing this lifetime */
237  HLife *old; /* points to subsumed records */
238 };
239 
240 /* pointer to linked life list, or null if not available */
241 extern HLife *Ht_lifetimes;
242 extern IPP_word Ht_hete_epoch;
243 extern int Ht_tz_unset;
244 
245 /* how often (secs) to check calibration file; zero disables updates */
246 extern int Ht_update_interval;
247 
248 /* these are used by euridice */
249 extern int Ht_dwab_dwdelta;
250 extern HTLdbl Ht_dwab_dw_mult;
251 extern void Ht_dump_lives(char *file);
252 extern HLife *Ht_last_life;
253 extern char *Ht_life_file;
254 extern GTime Ht_gps_origin; /* origin for relative times */
255 extern int Ht_string_min_len; /* the string is at least this long */
256 
257 /* essential conversion primitives */
258 extern UTime Ht_HTC_to_UTC(HTime ht, HtErr *err);
259 extern GTime Ht_HTC_to_GPS(HTime ht, HtErr *err);
260 
261 extern HTime Ht_UTC_to_HTC(UTime ut, HtErr *err);
262 extern HTime Ht_GPS_to_HTC(GTime gt, HtErr *err);
263 
264 extern GTime Ht_UTC_to_GPS(UTime ut, HtErr *err);
265 extern UTime Ht_GPS_to_UTC(GTime gt, HtErr *err);
266 
267 /* where the result gets stored if err is a null ptr */
268 extern HTLdbl Ht_default_error;
269 
270 /* current time in each format */
271 extern HTime Ht_now_HTC(HtErr *err);
272 extern UTime Ht_now_UTC(HtErr *err);
273 extern GTime Ht_now_GPS(HtErr *err);
274 
275 #if HETE2_PECULIAR
276 /* estimate the current time based on a message header */
277 extern GTime Ht_IPP_to_GPS(IPP_header *hdr, HtErr *err);
278 #endif /* HETE2_PECULIAR */
279 
280 /* this forces an initialization which normally occurs implicitly */
281 extern void Ht_initialize(void);
282 extern void Ht_reset(void);
283 
284 /*
285  * Adding a new time format requires:
286  *
287  * Ht_STR_XXXX to define the string input format htime.h 1 line
288  * Ht_DS_XXXX to define the output format htime.h 1 line
289  * Xxxx some nickname for queries ht_timeis.c 1 line
290  * Xxxx nickname and strcmp() for it rtime.c 4 lines
291  * str() functions to encode/decode htime.c varies
292  * length an Ht_min_len() entry htime.c 1 line
293  */
294 
295 /* types of date-strings we can parse */
296 #define Ht_STR_NTYP 0x000 /* unknown typ */
297 #define Ht_STR_UTYP 0x100 /* a UT string */
298 #define Ht_STR_UTNX 0x101 /* a UNIX time */
299 #define Ht_STR_UTPS 0x102 /* a PASS date */
300 #define Ht_STR_USVN 0x103 /* a SVN date */
301 #define Ht_STR_UTDT 0x104 /* a DATE date */
302 #define Ht_STR_ISOT 0x105 /* an ISO time */
303 #define Ht_STR_ISON 0x106 /* an ISO (s) */
304 #define Ht_STR_ISOM 0x107 /* an ISO (ms) */
305 #define Ht_STR_UTRL 0x108 /* relative UT */
306 #define Ht_STR_HOPS 0x109 /* UNIX baseX6 */
307 #define Ht_STR_PLOG 0x10A /* Python Log */
308 #define Ht_STR_ADAT 0x10B /* Alt.DateFmt */
309 #define Ht_STR_UGPS 0x110 /* GPS in secs */
310 #define Ht_STR_UWKS 0x120 /* GPS wks+sec */
311 /* maestro formats */
312 #define Ht_STR_MAES 0x139 /* YYYY/MM:DD: */
313 #define Ht_STR_MY4D 0x13A /* M. YYYY.HH. */
314 #define Ht_STR_MY2D 0x13B /* Mae. YY.HH. */
315 #define Ht_STR_MY0D 0x13C /* Maestr. HH. */
316 #define Ht_STR_MY4C 0x13D /* M. YYYY:HH: */
317 #define Ht_STR_MY2C 0x13E /* Mae. YY:HH: */
318 #define Ht_STR_MY0C 0x13F /* Maestr. HH: */
319 #define Ht_STR_UGRB 0x140 /* GRB secs UT */
320 #define Ht_STR_JDAY 0x160 /* Julian Date */
321 #define Ht_STR_MODJ 0x161 /* Mod JulianD */
322 #define Ht_STR_PLAN 0x170 /* yyyydoy.hms */
323 #define Ht_STR_FILE 0x171 /* yyyy_doy_hm */
324 #define Ht_STR_FILH 0x172 /* _doy_hh_mm */
325 #define Ht_STR_Y2DS 0x180 /* yy/doy/sod */
326 #define Ht_STR_Y4DS 0x181 /*yyyy/doy/sod */
327 #define Ht_STR_YDOY 0x182 /*yyyy/doy.frd */
328 #define Ht_STR_PGMI 0x190 /* pygmi time */
329 #define Ht_STR_VEXT 0x1A0 /* vlbi (vex) */
330 #define Ht_STR_VDIF 0x1A1 /* vlbi (vdif) */
331 #define Ht_STR_RDBE 0x1A2 /* vlbi (rdbe) */
332 #define Ht_STR_HTYP 0x200 /* a HT string */
333 #if HETE2_PECULIAR
334 #define Ht_STR_HTTS 0x201 /* a timestamp */
335 #endif /* HETE2_PECULIAR */
336 #define Ht_STR_HT0x 0x202 /* sc_clock 0x */
337 #define Ht_STR_HT0X 0x204 /* sc_clock 0X */
338 #define Ht_STR_HT00 0x208 /* without 0xX */
339 #define Ht_STR_HT03 0x210 /* 3wds no 0xX */
340 #if HETE2_PECULIAR
341 #define Ht_STR_HT0E 0x210 /* epoch+clock */
342 #endif /* HETE2_PECULIAR */
343 #define Ht_STR_NULL 0x300 /* null string */
344 
345 #if HETE2_PECULIAR
346 #define Ht_HETE_TIME_HELP "\n\
347  ...\n\
348  time_code: (epoch time[2] time[1] time[0]:)\n\
349  0x0000 [0x0000 [0x0000 [0x0000]]]\n\
350  0X0000 [0X0000 [0X0000 [0X0000]]]\n\
351  0000 [0000 [0000 [0000]]]\n\
352  0000 000000000000\n\
353  timestamp: ticks\n\
354  (the epoch is implicit)\n\
355 "
356 #endif /* HETE2_PECULIAR */
357 
358 #define Ht_IBEX_TIME_HELP "\n\
359  Parse-able IBEX time formats:\n\
360 \n\
361  relative: +|- integer [us|ms|s|m|h|d|y]\n\
362  +|- float [us|ms|s|m|h|d|y]\n\
363  +|- integer [(s)i(dereal)|(sy)n(odic)] (lunar months)\n\
364 \n\
365  UNIX clock: secs\n\
366  GPS seconds: secs.[usecs]\n\
367  GPS time: weeks#secs[.usecs]\n\
368  (# == any non-space)\n\
369  PASS time: [19]990613_054700[.000000]\n\
370  DATE string: [Thu] Jun 13 05:47:00[.000000] UTC 1996\n\
371  (GMT may replace UTC) or the variant\n\
372  [Thu] 13 Jun 1996 05:47:00 AM UTC\n\
373  GRB time: YYMMDD+SOD (UTC)\n\
374  YDS time: YYYY/DOY/SOD (UTC)\n\
375  YY/DOY/SOD (UTC)\n\
376  PLAN time: YYYY/DOY.HHMMSS\n\
377  FILE time: YYYY_DOY_HHMM\n\
378  or YYYY_DOY_HH_MM\n\
379  MAESTRO time: YYYY/MM:DD:HH:MM:SS\n\
380  or [[YY]YY:]DOY:HH:MM:SS\n\
381  or [[YY]YY.]DOY.HH.MM.SS\n\
382  SVN time: YYYY-MM-DD HH:MM:SS[.uuuuuu][Z]\n\
383  ISO time: YYYY-MM-DDTHH:MM:SS[.uuuuuu][Z]\n\
384  MPS time: YYYY-MM-DDTHH:MM:SS[.mmm][Z]\n\
385  PIGMI time: YYYYMMDDHHMMSSmmm\n\
386  VLBI vex: [YY]YYyDOYdHHhMMmSS.ffffs\n\
387  VLBI s/e: EE@ssssssss.ffff (EE<64)\n\
388 \n\
389  time_code: (epoch time[2] time[1] time[0]:)\n\
390  0x0030 [0xXXXX [0xXXXX [0xXXXX]]] (w/epoch)\n\
391  0xXXXX [0xXXXX [0xXXXX]] (no epoch)\n\
392 \n\
393  Julian day: days.[fday] (both of these are restricted to\n\
394  Modified JD: days.[fday] the epoch 50000 < MJD < 70000)\n\
395 \n\
396  HOPS rootcode: unix clock base 26\n\
397 \n\
398 "
399 
400 /* in case you don't want to see the Z on output */
401 extern int Ht_suppress_Z;
402 
403 /* this returns one of these date-string defines */
404 extern int Ht_string_type(char *s);
405 
406 /* this forces the issue if you need it */
407 extern int Ht_asserted_string_type;
408 
409 extern HTime Ht_string_to_HTC(char *s, HtErr *err);
410 extern GTime Ht_string_to_GPS(char *s, HtErr *err);
411 extern UTime Ht_string_to_UTC(char *s, HtErr *err);
412 
413 /* more efficient for a special case */
414 extern UTime pass_str2ut(char *s);
415 
416 /* types of date-strings we can print... */
417 #define Ht_DS_UNIX 0 /* UNIX time secs */
418 #define Ht_DS_PASS 1 /* PASS datestamp */
419 #define Ht_DS_DATE 2 /* DATE datestamp */
420 #define Ht_DS_SECS 3 /* GPS time secs */
421 #define Ht_DS_Y2KP 4 /* PASS w/century */
422 #define Ht_DS_HT00 5 /* s/c clock no0x */
423 #if HETE2_PECULIAR
424 #define Ht_DS_I_TS 6 /* IPP timestamp */
425 #else /* HETE2_PECULIAR */
426 #define Ht_DS_YDOY 6 /* YEAR/DOY.f-day */
427 #endif /* HETE2_PECULIAR */
428 #define Ht_DS_GRBS 7 /* GRB seconds UT */
429 #define Ht_DS_HT03 8 /* s/c clock 3wds */
430 #define Ht_DS_JULD 9 /* the julian day */
431 #define Ht_DS_MJUL 10 /* mod julian day */
432 #define Ht_DS_Y2DS 11 /* yy/doy/sec.ms */
433 #define Ht_DS_Y4DS 12 /*year/doy/sec.ms */
434 #define Ht_DS_UWKS 13 /* GPS weeks/sow */
435 #define Ht_DS_USVN 14 /* SVN datestamp */
436 #define Ht_DS_USVZ 15 /* SVN w/no usecs */
437 #define Ht_DS_ISON 16 /* ISO time no us */
438 #define Ht_DS_ISOT 17 /* ISO time w/ us */
439 #define Ht_DS_PGMI 18 /* pigmi format */
440 #define Ht_DS_ISOM 19 /* ISO time w/ ms */
441 #define Ht_DS_MAES 20 /* for ze MAESTRO */
442 #define Ht_DS_PLAN 21 /* planning times */
443 #define Ht_DS_FILE 22 /* for file names */
444 #define Ht_DS_MY4D 23 /* MAESTRO YYYY. */
445 #define Ht_DS_MY4C 24 /* MAESTRO YYYY: */
446 #define Ht_DS_FILH 25 /* alt file names */
447 #define Ht_DS_HOPS 26 /* HOPS rootcode */
448 #define Ht_DS_UTRL 27 /* relative UTime */
449 #define Ht_DS_VEXT 28 /* vlbi vex time */
450 #define Ht_DS_VDIF 29 /* vlbi vdif time */
451 #define Ht_DS_RDBE 30 /* vlbi rdbe time */
452 #define Ht_DS_PLOG 31 /* Python logtime */
453 #define Ht_DS_ADAT 32 /* alternate date */
454 #define Ht_DS_NUMB 33 /* count of these */
455 
456 /* supplied as style argument to one of these */
457 extern char *Ht_HTC_to_string(HTime ht, int style);
458 extern char *Ht_UTC_to_string(UTime ut, int style);
459 extern char *Ht_GPS_to_string(GTime gt, int style);
460 
461 /* these are useful: straightforward conversions */
462 extern HTLdbl Ht_HTC_to_secs(HTime ht);
463 extern HTime Ht_secs_to_HTC(HTLdbl s);
464 
465 #if HETE_PECULIAR
466 /* MET was the 3 lower words, with epoch 0019 implicit */
467 extern HTLdbl Ht_HTC_to_MET(HTime ht);
468 extern HTime Ht_MET_to_HTC(HTLdbl s);
469 #endif /* HETE_PECULIAR */
470 
471 /*
472  * Ht_julday returns the Julian Day Number which begins at Noon of the
473  * calendar date specified by month mm, day id, and year iyyy, all
474  * being integer variables. The year after 1 BC (-1) is 1 AD (1).
475  */
476 
477 extern int Ht_julday(int mm, int id, int iyyy);
478 extern GTime Ht_julday_to_GPS(HTLdbl julian);
479 
480 extern GTime Ht_julian_to_GPS(HTLdbl julian);
481 extern HTLdbl Ht_GPS_to_julian(GTime gps);
482 extern GTime Ht_modjul_to_GPS(HTLdbl modjul);
483 extern HTLdbl Ht_GPS_to_modjul(GTime gps);
484 
485 /*
486  * The float point julian day here is really in the GPS epoch,
487  * unless you've explicity shifted it via HOPS_JULIAN_EPOCH.
488  * (This time can be specified in any format and serves only
489  * to specify an alternate leap second offset GTime<->UTime.)
490  * This function then returns the number of leap-seconds of offset.
491  * (Same as Ht_leapsecs_since_J2000("HOPS_JULIAN_EPOCH"), but the
492  * evaluation takes place once--afterwards the previous value is used.)
493  * You can set HOPS_JULIAN_EPOCH to "GPS" to explicitly get the default.
494  * You can set HOPS_JULIAN_EPOCH to "UTC" to put julian days into UTC.
495  * (I.e. the julian days track the calendar.) If you do that, this
496  * function returns Ht_JULIAN_EPOCH_IS_UTC which flags nonstandard handling.
497  */
498 extern int Ht_julian_epoch(void);
499 #define Ht_JULIAN_EPOCH_IS_UTC (-666)
500 
501 /* Other potentially interesting epochs are
502  * ~1958 when TAI starts and leap seconds = 0.
503  * 1972 TAI-UTC goes to integral leap seconds
504  * and some way to indicate Julian days of UTC
505  */
506 
507 /*
508  * The VDIF epochs are defined for 0 (J2000) through 63 (July 2031)
509  * and HOPS_VDIF_EPOCH should have one of those values.
510  */
511 extern int Ht_vdif_epoch(void);
512 
513 /*
514  * Julian UTC is not yet implemented...
515  */
516 
517 /*
518  * For working with SPICE and solar system precision timing
519  */
520 extern HTLdbl Ht_GPS_to_TDT(HTLdbl gps);
521 extern HTLdbl Ht_GPS_to_TAI(HTLdbl gps);
522 extern HTLdbl Ht_TDT_to_GPS(HTLdbl tdt);
523 extern HTLdbl Ht_TAI_to_GPS(HTLdbl tai);
524 extern HTLdbl Ht_TDT_to_TDB(HTLdbl tdt);
525 extern HTLdbl Ht_TDB_to_TDT(HTLdbl tdb);
526 
527 extern int Ht_ephem_type(char *);
528 extern char *Ht_convert_et_to_gps(char *arg, int eph_type);
529 extern void Ht_spice_sprintf(char *b, char *tla, HTLdbl t);
530 
531 /*
532  * And to generate relative timing;
533  * the first character is s, m, h, d, ...
534  * and the string is the origin.
535  * Ht_d_mult, Ht_d_orig are visible as diagnostics only.
536  */
537 extern int Ht_delta_setup(char *type, char *base);
538 extern HTLdbl Ht_delta_value(char *s, HTLdbl *pterror);
540 
541 /*
542  * For going from A-Z to _DS_ and _STR_ types.
543  */
544 extern int Ht_rtype_to_style(char *rtype);
545 extern int Ht_qtype_to_style(char *rtype);
546 extern void Ht_format_help(void);
547 
548 #endif /* HTIME_H */
549 
550 /*
551  * eof
552  */
int base
Definition: fourfit3.c:62
unsigned short IPP_word
Definition: hetetimecode.h:12
Definition: hetetimecode.h:15
int rtype
Definition: hops_time.h:16
void Ht_dump_lives(char *file)
Definition: lifetime.c:291
time_code HTime
Definition: htime.h:63
HTLdbl error
Definition: htime.h:231
UTime Ht_now_UTC(HtErr *err)
Definition: htime.c:982
HTLdbl Ht_TAI_to_GPS(HTLdbl tai)
Definition: eph_time.c:45
HTLdbl Ht_HTC_to_secs(HTime ht)
Definition: lifetime.c:550
HTLdbl Ht_d_orig
Definition: htime.h:539
UTime Ht_HTC_to_UTC(HTime ht, HtErr *err)
Definition: htime.c:966
int Ht_update_interval
Definition: lifetime.c:18
int Ht_tz_unset
Definition: lifetime.c:22
void Ht_reset(void)
Definition: lifetime.c:505
HTime Ht_now_HTC(HtErr *err)
Definition: htime.c:1004
void Ht_format_help(void)
Definition: rtype.c:19
GTime Ht_UTC_to_GPS(UTime ut, HtErr *err)
Definition: leapsec.c:168
UTime Ht_GPS_to_UTC(GTime gt, HtErr *err)
Definition: leapsec.c:293
HTLdbl Ht_default_error
Definition: htime.c:938
HTLdbl HtErr
Definition: htime.h:81
GTime start
Definition: htime.h:228
HTLdbl Ht_GPS_to_TDT(HTLdbl gps)
Definition: eph_time.c:29
GTime Ht_julday_to_GPS(HTLdbl julian)
Definition: leapsec.c:405
int Ht_asserted_string_type
Definition: lifetime.c:30
GTime Ht_HTC_to_GPS(HTime ht, HtErr *err)
Definition: lifetime.c:640
GTime Ht_leapsecs_since_J2000(GTime gt)
Definition: leapsec.c:202
GTime Ht_modjul_to_GPS(HTLdbl modjul)
Definition: leapsec.c:438
char * Ht_HTC_to_string(HTime ht, int style)
Definition: htime.c:1736
int Ht_delta_setup(char *type, char *base)
Definition: htime.c:717
IPP_word Ht_hete_epoch
Definition: lifetime.c:21
HTLdbl span
Definition: htime.h:229
HTime Ht_UTC_to_HTC(UTime ut, HtErr *err)
Definition: htime.c:954
HTLdbl Ht_TDB_to_TDT(HTLdbl tdb)
Definition: eph_time.c:66
HTLdbl Ht_GPS_to_julian(GTime gps)
Definition: leapsec.c:423
int Ht_julday(int mm, int id, int iyyy)
Definition: leapsec.c:344
HTime Ht_string_to_HTC(char *s, HtErr *err)
Definition: htime.c:1505
UTime pass_str2ut(char *s)
Definition: htime.c:397
HTLdbl Ht_GPS_to_TAI(HTLdbl gps)
Definition: eph_time.c:40
int Ht_vdif_epoch(void)
Definition: htime.c:889
HLife * Ht_lifetimes
Definition: lifetime.c:17
int Ht_dwab_dwdelta
Definition: lifetime.c:36
HLife * old
Definition: htime.h:237
void Ht_spice_sprintf(char *b, char *tla, HTLdbl t)
Definition: eph_time.c:112
HLife * next
Definition: htime.h:235
char * Ht_GPS_to_string(GTime gt, int style)
Definition: htime.c:1761
HTLdbl esc_dt
Definition: htime.h:233
int Ht_string_type(char *s)
Definition: htime.c:1142
HLife * last
Definition: htime.h:234
GTime Ht_string_to_GPS(char *s, HtErr *err)
Definition: htime.c:1513
HTLdbl GTime
Definition: htime.h:80
char * Ht_life_file
Definition: lifetime.c:35
HTLdbl Ht_dwab_dw_mult
Definition: lifetime.c:37
GTime Ht_julian_to_GPS(HTLdbl julian)
Definition: leapsec.c:418
HTLdbl Ht_GPS_to_modjul(GTime gps)
Definition: leapsec.c:445
HTLdbl dsc_dt
Definition: htime.h:232
HTLdbl Ht_TDT_to_TDB(HTLdbl tdt)
Definition: eph_time.c:59
GTime Ht_gps_origin
Definition: lifetime.c:25
int Ht_julian_epoch(void)
Definition: leapsec.c:271
HTLdbl Ht_leapsecs_from_year_start_to_gps(int year, GTime gps)
Definition: leapsec.c:255
GTime Ht_now_GPS(HtErr *err)
Definition: htime.c:992
HTime Ht_GPS_to_HTC(GTime gt, HtErr *err)
Definition: lifetime.c:658
HTLdbl Ht_TDT_to_GPS(HTLdbl tdt)
Definition: eph_time.c:34
char * Ht_UTC_to_string(UTime ut, int style)
Definition: htime.c:1539
HTime Ht_secs_to_HTC(HTLdbl s)
Definition: lifetime.c:574
char * Ht_convert_et_to_gps(char *arg, int eph_type)
Definition: eph_time.c:89
int Ht_rtype_to_style(char *rtype)
Definition: rtype.c:69
int Ht_qtype_to_style(char *rtype)
Definition: rtype.c:150
int Ht_suppress_Z
Definition: lifetime.c:28
HLife * Ht_last_life
Definition: lifetime.c:47
struct timeval UTime
Definition: htime.h:172
HTime birth
Definition: htime.h:230
UTime Ht_string_to_UTC(char *s, HtErr *err)
Definition: htime.c:1521
HTLdbl Ht_d_mult
Definition: lifetime.c:32
int Ht_ephem_type(char *)
Definition: eph_time.c:75
HTLdbl Ht_delta_value(char *s, HTLdbl *pterror)
Definition: htime.c:739
void Ht_initialize(void)
Definition: lifetime.c:496
int Ht_string_min_len
Definition: lifetime.c:26
Definition: htime.h:227
t
Definition: picking_aedit.py:14
double HTLdbl
Definition: time_float_type.h:22
Definition: vex.h:69