leap_seconds¶
- class erfa.leap_seconds[source]¶
Bases:
object
Leap second management.
This singleton class allows access to ERFA’s leap second table, using the methods ‘get’, ‘set’, and ‘update’.
One can also check expiration with ‘expires’ and ‘expired’.
Note that usage of the class is similar to a
ScienceState
class, but it cannot be used as a context manager.Attributes Summary
Whether the leap second table is valid beyond the present.
The expiration date of the current ERFA table.
Methods Summary
get
()Get the current leap-second table used internally.
set
([table])Set the ERFA leap second table.
update
(table)Add any leap seconds not already present to the ERFA table.
validate
(table)Validate a leap-second table.
Attributes Documentation
- expired¶
Whether the leap second table is valid beyond the present.
- expires¶
The expiration date of the current ERFA table.
This is either a date inferred from the last table used to update or set the leap-second array, or a number of days beyond the last leap second.
Methods Documentation
- classmethod set(table=None)[source]¶
Set the ERFA leap second table.
Note that it is generally safer to update the leap-second table than to set it directly, since most tables do not have the pre-1970 changes in TAI-UTC that are part of the built-in ERFA table.
- Parameters:
- Raises:
- ValueError
If the leap seconds in the table are not on the 1st of January or July, or if the sorted TAI-UTC do not increase in increments of 1.
- classmethod update(table)[source]¶
Add any leap seconds not already present to the ERFA table.
This method matches leap seconds with those present in the ERFA table, and extends the latter as necessary.
If the ERFA leap seconds file was corrupted, it will be reset.
If the table is corrupted, the ERFA file will be unchanged.
- Parameters:
- tablearray_like or
LeapSeconds
Array or table with TAI-UTC from leap seconds. Should have ‘year’, ‘month’, and ‘tai_utc’ columns.
- tablearray_like or
- Returns:
- n_updateint
Number of items updated.
- Raises:
- ValueError
If the leap seconds in the table are not on the 1st of January or July, or if the sorted TAI-UTC do not increase in increments of 1.
- classmethod validate(table)[source]¶
Validate a leap-second table.
- Parameters:
- tablearray_like
Must have ‘year’, ‘month’, and ‘tai_utc’ entries. If a ‘day’ entry is present, it will be checked that it is always 1. If
table
has an ‘expires’ attribute, it will be interpreted as an expiration date.
- Returns:
- Raises:
- ValueError
If the leap seconds in the table are not on the 1st of January or July, or if the sorted TAI-UTC do not increase in increments of 1.