Which utc to ut1 conversion is correct? Time.ut1 vs utc+get_delta_ut1_utc()

I’m trying to get a timestamp reported by my linux computer into UT1. My understanding is that for this distribution calling python’s time.time() gives me the unix time (the number of seconds ignoring leap seconds since the UTC epoch). I want to take this time and convert it to UT1. I see two ways to do this with astropy but it’s not clear to me which is correct as they seem to give different results.

Option 1

import time
from astropy.time import Time

unix_time = Time(time.time(), format='unix', scale='utc')
ut1_time = unix_time.ut1

Option 2

import time
from astropy.time import Time

unix_time = Time(time.time(), format='unix', scale='utc')
ut1_time = unix_time + unix_time.get_delta_ut1_utc()

Looking up UTC to UT1 conversions online implies Option 2 would be the normal approach. But that seems to assume the UTC implementation accounts for leap seconds which I believe is not the case here. Is that the reason these are giving me different results? I’m fairly new to UT1 so I may be missing some understanding.

I believe that you’re getting confused by the fact that format='unix' essentially ignores scale. You need to change to a different format to visualize that that the UT1 conversion did something in Option 1:

>>> unix_time
<Time object: scale='utc' format='unix' value=1720230761.72945>
>>> ut1_time
<Time object: scale='ut1' format='unix' value=1720230761.72945>

>>> unix_time.iso
'2024-07-06 01:52:41.729'
>>> ut1_time.iso
'2024-07-06 01:52:41.732'

The conversion from format='unix' to format='iso' takes into account the leap seconds.

Don’t do Option 2. You’re confusing the astropy.time.Time machinery if you do that.

Thanks @ayshih that makes sense, option 1 it is then.