src.api.utils.coordinate_systems module

src.api.utils.coordinate_systems.az_el_to_ra_dec(az: float, el: float, lat: float, lon: float, jd: float) tuple[float, float][source]

Convert azimuth and elevation to right ascension and declination.

This function calculates the right ascension and declination based on the azimuth, elevation, latitude, longitude, and Julian Day.

Parameters:
  • az (float) – The azimuth in degrees.

  • el (float) – The elevation in degrees.

  • lat (float) – The latitude in degrees.

  • lon (float) – The longitude in degrees.

  • jd (float) – The Julian Day.

Returns:

The right ascension and declination in degrees.

Return type:

tuple[float, float]

src.api.utils.coordinate_systems.calculate_current_position(lat, long, height)[source]

Calculates the current position in the WGS84 reference frame.

This function uses the WGS84 model to calculate the current position based on the given latitude, longitude, and height. The result is cached for faster subsequent calls with the same arguments.

Parameters:
  • lat (float) – The latitude in degrees.

  • long (float) – The longitude in degrees.

  • height (float) – The height in meters above the WGS84 ellipsoid.

Returns:

A Topos object representing the current position.

Return type:

Topos

src.api.utils.coordinate_systems.ecef_to_eci(r_ecef: list[float], theta_gst: float) ndarray[source]

Convert ECEF (Earth-Centered, Earth-Fixed) coordinates to ECI (Earth-Centered Inertial) coordinates.

This function applies a rotation matrix to transform the coordinates from the ECEF frame to the ECI frame.

Parameters:
  • r_ecef (list[float]) – The ECEF coordinates.

  • theta_gst (float) – The Greenwich Sidereal Time angle in degrees.

Returns:

The ECI coordinates.

Return type:

np.ndarray

src.api.utils.coordinate_systems.ecef_to_enu(r_ecef: list[float], lat: float, lon: float) ndarray[source]

Convert ECEF (Earth-Centered, Earth-Fixed) coordinates to ENU (East, North, Up) coordinates.

This function applies a rotation matrix to transform the coordinates from the ECEF frame to the ENU frame.

Parameters:
  • r_ecef (list[float]) – The ECEF coordinates.

  • lat (float) – The latitude of the location.

  • lon (float) – The longitude of the location.

Returns:

The ENU coordinates.

Return type:

np.ndarray

src.api.utils.coordinate_systems.ecef_to_itrs(r_ecef)[source]

Converts coordinates from Earth-Centered, Earth-Fixed (ECEF) to International Terrestrial Reference System (ITRS). The conversion takes into account the flattening of the Earth.

Parameters:
  • r_ecef (np.ndarray) – A numpy array representing the coordinates in the

  • system. (ECEF) –

Returns:

A numpy array representing the coordinates in the ITRS system.

Return type:

np.ndarray

src.api.utils.coordinate_systems.enu_to_az_el(r_enu: ndarray) tuple[float, float][source]

Convert ENU (East, North, Up) coordinates to azimuth and elevation.

This function calculates the azimuth and elevation based on the ENU coordinates.

Parameters:

r_enu (np.ndarray) – The ENU coordinates.

Returns:

The azimuth and elevation in degrees.

Return type:

tuple[float, float]

src.api.utils.coordinate_systems.get_earth_sun_positions(t: float | Time) tuple[ndarray, ndarray][source]

Computes the positions of Earth and Sun at a given time.

This function uses Skyfield to get the positions of Earth and Sun in kilometers at a specified time. The time can be provided either as a float representing Julian date or as a Skyfield Time object. The results are cached to improve performance on subsequent calls.

Parameters:

t (float | Time) – The time at which to compute the positions. Can be a float representing Julian date or a Skyfield Time object.

Returns:

A tuple containing two numpy arrays representing

the positions of Earth and Sun in kilometers.

Return type:

tuple[np.ndarray, np.ndarray]

src.api.utils.coordinate_systems.get_phase_angle(topocentric_gcrs_norm: ndarray, sat_gcrs: ndarray, julian_date: float) float[source]

Computes the phase angle between a satellite and the Sun as seen from Earth.

This function calculates the phase angle, which is the angle between the vector from the satelliteto the Sun and the vector from the satellite to the Earth. The phase angle is useful in determining the illumination of the satellite.

Parameters:
  • topocentric_gcrs_norm (np.ndarray) – Normalized vector representing the topocentric position in GCRS coordinates.

  • sat_gcrs (np.ndarray) – Vector representing the satellite’s position in GCRS coordinates.

  • julian_date (float) – The Julian date at which to compute the phase angle.

Returns:

The phase angle in degrees

Return type:

float

src.api.utils.coordinate_systems.icrf2radec(pos, unit_vector=False, deg=True)[source]

Convert ICRF xyz or xyz unit vector to Right Ascension and Declination. Geometric states on unit sphere, no light travel time/aberration correction.

Parameters:
  • pos (numpy.ndarray) – A 3D vector of unit length in the ICRF frame. If unit_vector is False, pos is assumed to be a position vector and will be normalized. If unit_vector is True, pos is assumed to already be a unit vector. The shape should be [n, 3].

  • unit_vector (bool, optional) – If True, pos is assumed to be a unit vector. If False, pos is assumed to be a position vector and will be normalized. Default is False.

  • deg (bool, optional) – If True, the angles are returned in degrees. If False, the angles are returned in radians. Default is True.

Returns:

  • ra (numpy.ndarray) – The Right Ascension of the position, in degrees if deg is True, or in radians if deg is False. If pos was a 2D array, this will be a 1D array of the same length.

  • dec (numpy.ndarray) – The Declination of the position, in degrees if deg is True, or in radians if deg is False. If pos was a 2D array, this will be a 1D array of the same length.

src.api.utils.coordinate_systems.is_illuminated(sat_gcrs: ndarray, julian_date: float) bool[source]

Determines if a satellite is illuminated by the sun.

This function calculates the angle between the satellite and the sun to determine if the satellite is illuminated.

Parameters:
  • sat_gcrs (np.ndarray) – The position of the satellite in the GCRS frame.

  • julian_date (float) – The Julian date to check if the satellite is illuminated.

Returns:

True if the satellite is illuminated, False otherwise.

Return type:

bool

src.api.utils.coordinate_systems.is_illuminated_vectorized(sat_gcrs_list: list[ndarray], julian_dates: list[float]) list[bool][source]

Vectorized version of is_illuminated that processes multiple satellite positions at once.

This function batches the Earth-Sun position calculations and vectorizes the computations.

Parameters:
  • sat_gcrs_list (list[np.ndarray]) – List of satellite positions in the GCRS frame.

  • julian_dates (list[float]) – List of Julian dates corresponding to each

  • position. (satellite) –

Returns:

List of illumination states for each satellite position.

Return type:

list[bool]

src.api.utils.coordinate_systems.is_in_fov(ra_points: ndarray, dec_points: ndarray, ra_center: float, dec_center: float, fov_radius: float) ndarray[source]

Determines if a point is in the field of view.

Parameters:
  • ra (np.ndarray) – The right ascension of the points in degrees.

  • dec (np.ndarray) – The declination of the points in degrees.

  • ra_center (float) – The right ascension of the center of the field of view in

  • degrees.

  • dec_center (float) – The declination of the center of the field of view in

  • degrees.

  • fov_radius (float) – The radius of the field of view in degrees.

Returns:

True if the point is in the field of view, False otherwise.

Return type:

bool

src.api.utils.coordinate_systems.itrs_to_gcrs(r_itrs, julian_date)[source]

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.

Parameters:
  • 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:

A numpy array representing the coordinates in the GCRS system.

Return type:

np.ndarray

src.api.utils.coordinate_systems.load_earth_sun() tuple[source]

Loads the Earth and Sun ephemeris data from the DE430t.bsp file.

This function uses the Skyfield library to load the ephemeris data for Earth and Sun from the DE430t.bsp file. The loaded data is cached to improve performance on subsequent calls.

Returns:

A tuple containing the Earth and Sun objects from the ephemeris data.

Return type:

tuple

src.api.utils.coordinate_systems.radec2icrf(ra, dec, deg=True)[source]

Convert Right Ascension and Declination to ICRF xyz unit vector. Geometric states on unit sphere, no light travel time/aberration correction. Parameters: ———– ra … Right Ascension [deg] dec … Declination [deg] deg … True: angles in degrees, False: angles in radians Returns: ——– x,y,z … 3D vector of unit length (ICRF)

src.api.utils.coordinate_systems.teme_to_ecef(r_teme: list[float], theta_gst: float) ndarray[source]

Convert TEME (True Equator, Mean Equinox) coordinates to ECEF (Earth-Centered, Earth-Fixed) coordinates.

This function applies a rotation matrix to transform the coordinates from the TEME frame to the ECEF frame.

Parameters:
  • r_teme (list[float]) – The TEME coordinates.

  • theta_gst (float) – The Greenwich Sidereal Time angle.

Returns:

The ECEF coordinates.

Return type:

np.ndarray

src.api.utils.coordinate_systems.tle_to_icrf_state(tle_line_1, tle_line_2, jd)[source]

Converts Two-Line Element (TLE) set to International Celestial Reference Frame (ICRF) state.

This function uses the Skyfield library to convert a TLE set into a state vector in the ICRF. The state vector includes the position and velocity of the satellite.

Parameters:
  • tle_line_1 (str) – The first line of the TLE set.

  • tle_line_2 (str) – The second line of the TLE set.

  • jd (float or astropy.time.core.Time) – The Julian date at which to calculate the state. If 0, the function will use the epoch specified in the TLE set.

Returns:

A 1D array containing the ICRF position (in km) and velocity (in km/s) of the satellite.

Return type:

np.ndarray