tai_from_utc¶
-
lsst.ts.salobj.tai_from_utc(utc, format='unix')¶ Return TAI in unix seconds, given UTC or any
astropy.time.Time.Parameters: - utc :
float,strorastropy.time.Time UTC time in the specified format.
- format :
strorNone Format of the UTC time, as an
astropy.timeformat name, orNoneto have astropy guess. Ignored ifutcis an instance ofastropy.time.Time.
Returns: - tai_unix :
float TAI time in unix seconds.
Raises: - ValueError
If the date is earlier than 1972 (which is before integer leap seconds) or within one day of the expiration date of the leap second table (which is automatically updated).
Notes
If you have UTC in floating point format and performance is an issue, please call
tai_from_utc_unixto avoid the overhead of converting your time to anastropy.time.Time.This function will be deprecated once we upgrade to a version of
astropythat supports TAI seconds.tai_from_utc_unixwill remain.Leap Seconds on the Day Before a Leap Second
This routine may not behave as you expect on the day before a leap second. Specify the date in ISO format if you want the correct answer.
When UTC is expressed as unix time, Julian Day, or Modified Julian Day the answer is ambiguous, so the result can be off by up to a second from what you might expect. This function follows
astropy.timeand Standards of Fundamental Astronomy (SOFA) by shrinking or stretching unix time, Julian Day, and Modified Julian Day, as needed, so that exactly one day of 86400 seconds (of modified duration) elapses. This leads to TAI-UTC varying continuously on that day, instead of being an integer number of seconds. See https://github.com/astropy/astropy/issues/10055Also note that the behavior of the unix clock is not well defined on the day before a leap second. Both ntp and ptp can be configured to make the clock jump or smear in some way. https://developers.redhat.com/blog/2016/12/28/leap-second-i-belong-to-you/
In theory the datetime format could work as well as ISO format, but in practice it does not. The
datetimelibrary does not handle leap seconds, and the datetime representation inastropy.timeraises an exception if the date has 60 in the seconds field.On Linux an excellent way to get current TAI on the day of a leap second is to configure ntp or ptp to maintain a leap second table, then use the
CLOCK_TAIclock (which is only available on Linux).The leap second table is automatically updated.
- utc :