TimeConverter¶
- class lsst.daf.butler.time_utils.TimeConverter¶
Bases:
object
A singleton for mapping TAI times to integer nanoseconds.
This class allows some time calculations to be deferred until first use, rather than forcing them to happen at module import time.
Methods Summary
astropy_to_nsec
(astropy_time)Convert astropy time to nanoseconds since epoch.
nsec_to_astropy
(time_nsec)Convert nanoseconds since epoch to astropy time.
times_equal
(time1, time2[, precision_nsec])Check that times are equal within specified precision.
Methods Documentation
- astropy_to_nsec(astropy_time: Time) int ¶
Convert astropy time to nanoseconds since epoch.
Input time is converted to TAI scale before conversion to nanoseconds.
- Parameters:
- astropy_time
astropy.time.Time
Time to be converted.
- astropy_time
- Returns:
- time_nsec
int
Nanoseconds since epoch.
- time_nsec
Notes
Only the limited range of input times is supported by this method as it is defined useful in the context of Butler and Registry. If input time is earlier
min_time
then this method returnsmin_nsec
. If input time comes aftermax_time
then it returnsmax_nsec
.
- nsec_to_astropy(time_nsec: int) Time ¶
Convert nanoseconds since epoch to astropy time.
- Parameters:
- time_nsec
int
Nanoseconds since epoch.
- time_nsec
- Returns:
- astropy_time
astropy.time.Time
Time to be converted.
- astropy_time
Notes
Usually the input time for this method is the number returned from
astropy_to_nsec
which has a limited range. This method does not check that the number falls in the supported range and can produce output time that is outside of that range.
- times_equal(time1: Time, time2: Time, precision_nsec: float = 1.0) bool ¶
Check that times are equal within specified precision.
- Parameters:
- time1, time2
astropy.time.Time
Times to compare.
- precision_nsec
float
, optional Precision to use for comparison in nanoseconds, default is one nanosecond which is larger that round-trip error for conversion to/from integer nanoseconds.
- time1, time2