return r_enu
# TODO: Verify if ecef_to_itrs is correct/necessary
# Not sure if the flattening of the Earth is necessary or not - if not this
# function can be removed
def ecef_to_itrs(r_ecef):
"""
Converts coordinates from Earth-Centered, Earth-Fixed (ECEF) to International
Terrestrial Reference System (ITRS). The conversion takes into account the
flattening of the Earth.
Args:
r_ecef (np.ndarray): A numpy array representing the coordinates in the
ECEF system.
Returns:
np.ndarray: A numpy array representing the coordinates in the ITRS system.
"""
# Convert ECEF to ITRS
r_itrs = np.zeros_like(r_ecef)
r_itrs[0] = r_ecef[0] / (1 + 1 / 298.257223563) # a / (1 + 1 / f)
r_itrs[1] = r_ecef[1]
r_itrs[2] = r_ecef[2]
return r_itrs
# TODO: Verify if itrs_to_gcrs is correct
# The results of this function in combination with the other coordinate system updates
# for SGP4 give results similar to, but not identical to, the Skyfield results, so each
# new conversion needs to be individually verified
def itrs_to_gcrs(r_itrs, julian_date):
"""
Converts coordinates from the International Terrestrial Reference System (ITRS)
to the Geocentric Celestial Reference System (GCRS).
The conversion takes into account the nutation and the Greenwich Sidereal Time
(GST) at the given Julian date.
Args:
r_itrs (np.ndarray): A numpy array representing the coordinates in the ITRS
system.
julian_date (float): The Julian date at which to perform the conversion.
Returns:
np.ndarray: A numpy array representing the coordinates in the GCRS system.
"""
# Convert ITRS to GCRS
r_gcrs = np.zeros_like(r_itrs)
dpsi, deps = iau2000b(julian_date)
nutation_arcsec = dpsi / 10000000 # Convert from arcseconds to degrees
nutation = nutation_arcsec / 3600
theta_gst = jd_to_gst(julian_date, nutation)
r_gcrs[0] = r_itrs[0] * np.cos(theta_gst) - r_itrs[1] * np.sin(theta_gst)
r_gcrs[1] = r_itrs[0] * np.sin(theta_gst) + r_itrs[1] * np.cos(theta_gst)
r_gcrs[2] = r_itrs[2]
return r_gcrs
# TODO: Verify if enu_to_az_el is correct
# The results of this function in combination with the other coordinate system updates
# for SGP4 give results similar to, but not identical to, the Skyfield results, so each
# new conversion needs to be individually verified
def enu_to_az_el(r_enu: np.ndarray) -> Tuple[float, float]:
"""
Convert ENU (East, North, Up) coordinates to azimuth and elevation.
The results of this function in combination with the other coordinate system updates
for SGP4 give results similar to, but not identical to, the Skyfield results, so each
new conversion needs to be individually verified
https://github.com/iausathub/satchecker/blob/c5a9a3b0fbe274986a361d37c20d86114d8fddba/src/api/utils/coordinate_systems.py#L143