[AstroPy] How to compute TAI-UTC using Astropy?
aldcroft at head.cfa.harvard.edu
Sat Aug 24 17:12:16 EDT 2019
I think what you want is:
In : from astropy.time import Time
In : date = '2019-08-24 00:00:00'
In : dt = Time(date, scale='utc') - Time(date, scale='tai')
In : dt.sec
On Fri, Aug 23, 2019 at 6:46 PM Russell Owen <rowen at uw.edu> wrote:
> 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
> 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_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
> AstroPy mailing list
> AstroPy at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the AstroPy