src.api.utils.time_utils module
- src.api.utils.time_utils.astropy_time_to_datetime_utc(time_obj: Time) datetime[source]
Convert an astropy Time object to a timezone-aware Python datetime (UTC).
- Parameters:
time_obj – Astropy Time object to convert
- Returns:
datetime.datetime object with UTC timezone
- src.api.utils.time_utils.calculate_lst(longitude: float, jd: float) float[source]
Calculate Local Sidereal Time (LST) based on longitude and Julian Day (JD).
This function calculates the Greenwich Sidereal Time (GST) and then adjusts it based on the given longitude to calculate the LST.
- Parameters:
longitude (float) – The longitude in degrees.
jd (float) – The Julian Day.
- Returns:
The LST in radians.
- Return type:
float
- src.api.utils.time_utils.ensure_datetime(date_value: Any) datetime[source]
Ensure that the input is a datetime object with timezone info.
- Parameters:
date_value – A datetime object, string representing a date/time, or
float (Julian date) –
- Returns:
A datetime object with timezone info
- Raises:
TypeError – If the input cannot be converted to a datetime object
- src.api.utils.time_utils.get_ut1_utc(jd_utc: float) float[source]
Get UT1-UTC value for a given JD using IERS (Bulletin A/B).
Uses Astropy’s IERS_Auto table, which interpolates from the official Earth orientation data (and auto-downloads if needed).
- Parameters:
jd_utc (float) – Julian Day in UTC
- Returns:
UT1-UTC in seconds
- Return type:
float
- src.api.utils.time_utils.jd_to_gst(jd_utc: float, nutation: float) float[source]
Convert Julian Day (UTC) to Greenwich Apparent Sidereal Time (GAST).
- Parameters:
jd_utc (float) – The Julian Day in UTC time scale.
nutation (float) – The equation of the equinoxes in degrees.
- Returns:
The GAST in radians.
- Return type:
float