libera_utils.time#
Module for dealing with time and time conventions
Some convention for this module
1. Only decorate direct spiceypy wrapper functions with the ensure_spice decorator. They should directly call a spiceypy function.
2. All spiceypy wrapper functions should read as <spiceypyfunc>_wrapper. We really only use these to allow array inputs for spiceypy functions that aren’t already vectorized in C and to wrap them in ensure_spice.
All functions should have robust type-hinting.
Functions
|
Helper function to convert a satellite time given as an CCSDS Day Segmented Time Code (CDS) form as 8 byte integer to a timezone aware datetime object |
|
Convert ephemeris times to UTC ISO strings. |
|
Convert ephemeris time to a python datetime object by first converting it to a UTC timestamp. |
|
Convert ephemeris time to a custom formatted timestamp (default is lowercase version of ISO). |
|
Convert ephemeris times to SCLK string https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/sce2s_c.html Decorated wrapper for spiceypy.sce2s that will automatically furnish the latest metakernel and retry if the first call raises an exception. |
|
Convert SCLK strings to ephemeris time. |
|
Convert UTC ISO strings to ephemeris times. |
- libera_utils.time.convert_cds_integer_to_datetime(satellite_time: int)#
Helper function to convert a satellite time given as an CCSDS Day Segmented Time Code (CDS) form as 8 byte integer to a timezone aware datetime object
- Parameters:
satellite_time (int) – A 64-bit unsigned integer that represents CDS time
- Returns:
cds_time
- Return type:
- libera_utils.time.et2utc_wrapper(et: float | Collection[float] | ndarray, fmt: str, prec: int) str | Collection[str] #
Convert ephemeris times to UTC ISO strings. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/et2utc_c.html Decorated wrapper for spiceypy.et2utc that will automatically furnish the latest metakernel and retry if the first call raises an exception.
- Parameters:
et (Union[float, Collection[float], numpy.ndarray]) – The ephemeris time value to be converted to UTC.
fmt (str) – Format string defines the format of the output time string. See CSPICE docs.
prec (int) – Number of digits of precision for fractional seconds.
- Returns:
UTC time string(s)
- Return type:
Union[numpy.ndarray, str]
- libera_utils.time.et_2_datetime(et: float | Collection[float] | ndarray) datetime | ndarray #
Convert ephemeris time to a python datetime object by first converting it to a UTC timestamp.
- Parameters:
et (float or Collection or numpy.ndarray) – Ephemeris times to be converted.
- Returns:
Object representation of ephemeris times.
- Return type:
- libera_utils.time.et_2_timestamp(et: float | Collection[float] | ndarray, fmt: str = '%Y%m%dT%H%M%S.%f') str | Collection[str] #
Convert ephemeris time to a custom formatted timestamp (default is lowercase version of ISO).
- libera_utils.time.sce2s_wrapper(et: float | Collection[float] | ndarray) str | ndarray #
Convert ephemeris times to SCLK string https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/sce2s_c.html Decorated wrapper for spiceypy.sce2s that will automatically furnish the latest metakernel and retry if the first call raises an exception.
- Parameters:
et (Union[float, Collection[float], numpy.ndarray]) – Ephemeris time
- Returns:
SCLK string
- Return type:
- libera_utils.time.scs2e_wrapper(sclk_str: str | Collection[str]) float | ndarray #
Convert SCLK strings to ephemeris time. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/scs2e_c.html Decorated wrapper for spiceypy.scs2e that will automatically furnish the latest metakernel and retry if the first call raises an exception.
- Parameters:
sclk_str (Union[str, Collection[str]]) – Spacecraft clock string
- Returns:
Ephemeris time
- Return type:
Union[float, numpy.ndarray]
- libera_utils.time.utc2et_wrapper(iso_str: str | Collection[str]) float | ndarray #
Convert UTC ISO strings to ephemeris times. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/utc2et_c.html Decorated wrapper for spiceypy.utc2et that will automatically furnish the latest metakernel and retry if the first call raises an exception.