Skip to content

05. Leap Second Management

Shubham edited this page Mar 3, 2021 · 2 revisions

Deprecated in barycorrpy version >= 0.4.0

The leap second updates will now be managed by the Astropy IERS functionality.


When converting UTC to TDB (different time standards explained), we need to include for the leap second correction.
We do not use Astropy for this correction due to the lack of an efficient mechanism to update the files when a new leap second is announced. Leap seconds are hard coded into Astropy's ERFA routines, and thus to update for a new leap second the user would have to update Astropy and re-compile it.
In this routine utc_tdb.py, we incorporate this is a stand alone file which is checked every time the code is run.

The leap seconds are announced when the difference between UTC and TAI approaches 1.0 second and is generally published in either January or July. To correct for this, the leap second file is downloaded from here. Further a log file leapsec_log.txt is created to check for how old is the file, and when it needs to b e updated. This contains the date of last update.
If the user wants to manually download the leap second file, then they can replace the leap second file and manually edit the log file (in the same datetime format) with the UTC date of download.

Flowchart which shows how the leap second management routine works

The only exception to this would be if the time that is being converted from UTC to TDB, preceeds the time the file was last updated. In that case, since all the leap seconds till that date have already been included, no error will be given.

Eg. If the file was last updated on 2017 - December - 5 12:00, and the routine is being run to convert 2017 - November - 4 12:00 from UTC to TDB, then will not check for file staleness or prompt to download.

Running Leap Second Management (standalone)

Due to the strict adherence of Astropy to the ERFA/SOFA procedures, the leap seconds are hard coded into Astropy. Thus updating to account for the announcement of a new leap second involves re-installing / updating of Astropy by the user. To run our leap second management system -

import utc_tdb from barycorrpy  
JDTDB,JDTT,warning,error=utc_tdb.JDUTC_to_JDTDB(JDUTC,fpath=leap_dir,leap_update=leap_update)   

where - 
INPUT:
    utctime : Enter UTC time as Astropy Time Object. In UTC Scale.
    fpath : Path to where the file would be saved. Default is script directory.
    leap_update : If True, when the leap second file is more than 6 months old it will attempt to download a new one.
              If False, then will just give a warning message. Default is True.

OUTPUT:
    JDTDB : Julian Date Barycentric Dynamic Time (Astropy Time object)
    JDTT: Julian Date Terrestrial Dynamic time (Astropy Time object)
    warning,error : Warning and Error message if any from the routine