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_timeastropy.time.Time
- Time to be converted. 
 
- astropy_time
- Returns:
- time_nsecint
- 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_timethen this method returns- min_nsec. If input time comes after- max_timethen it returns- max_nsec.
 - nsec_to_astropy(time_nsec: int) Time¶
- Convert nanoseconds since epoch to astropy time. - Parameters:
- time_nsecint
- Nanoseconds since epoch. 
 
- time_nsec
- Returns:
- astropy_timeastropy.time.Time
- Time to be converted. 
 
- astropy_time
 - Notes - Usually the input time for this method is the number returned from - astropy_to_nsecwhich 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, time2astropy.time.Time
- Times to compare. 
- precision_nsecfloat, 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