[AstroPy] How to compute TAI-UTC using Astropy?
Russell Owen
rowen at uw.edu
Fri Aug 23 18:37:49 EDT 2019
We do some work with TAI times as unix seconds. Possibly controversial, but it’s what we use.
We sometimes need to convert normal unix times (UTC) to this standard.
This naive solution does not work:
def bogus_tai_from_utc(utc):
“””Failed attempt to return TAI in unix seconds given UTC in unix seconds.
This fails because given an astropy.time.Time astropy_time:
astropy_time.tai.unix == astropy_time.utc.unix
"""
return astropy.time.Time(utc, format=“unix”, scale=“utc”).tai.unix
Is there a nice way to ask AstroPy the value of TAI-UTC in seconds, given a UTC?
If so, this would be perfect:
tai_from_utc(utc):
tai_minus_utc = …? (presently 37 seconds)
return utc + tai_minus_utc
The following ugly code works, but has error at the microsecond level and may not work at leap seconds:
tai_minus_utc = (astropy_utc.tai.mjd - astropy_utc.utc.mjd)*24*60*60
Regards,
Russell
More information about the AstroPy
mailing list