<div dir="ltr">Hi Russell,<div><br></div><div>I think what you want is:</div><div><br></div><div>In [1]: from astropy.time import Time</div><div>In [2]: date = '2019-08-24 00:00:00'<br></div><div>In [3]: dt = Time(date, scale='utc') - Time(date, scale='tai')<br>In [4]: dt.sec<br>Out[4]: 36.99999999999779<br></div><div><br></div><div>- Tom</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 23, 2019 at 6:46 PM Russell Owen <<a href="mailto:rowen@uw.edu">rowen@uw.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We do some work with TAI times as unix seconds. Possibly controversial, but it’s what we use.<br>
<br>
We sometimes need to convert normal unix times (UTC) to this standard.<br>
<br>
This naive solution does not work:<br>
<br>
def bogus_tai_from_utc(utc):<br>
    “””Failed attempt to return TAI in unix seconds given UTC in unix seconds.<br>
<br>
    This fails because given an astropy.time.Time astropy_time:<br>
    astropy_time.tai.unix == astropy_time.utc.unix<br>
    """<br>
    return astropy.time.Time(utc, format=“unix”, scale=“utc”).tai.unix<br>
<br>
Is there a nice way to ask AstroPy the value of TAI-UTC in seconds, given a UTC?<br>
If so, this would be perfect:<br>
<br>
tai_from_utc(utc):<br>
    tai_minus_utc = …? (presently 37 seconds)<br>
    return utc + tai_minus_utc<br>
<br>
The following ugly code works, but has error at the microsecond level and may not work at leap seconds:<br>
<br>
tai_minus_utc = (astropy_utc.tai.mjd - astropy_utc.utc.mjd)*24*60*60 <br>
<br>
Regards,<br>
<br>
Russell<br>
_______________________________________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@python.org" target="_blank">AstroPy@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/astropy</a><br>
</blockquote></div>