astrix.functs module¶
Array and logic functions for Astrix.
Should not have any dependencies on core Astrix types to avoid circular dependencies. Backend utility imports are allowed.
Guiding principles: - Functions should be backend-agnstic where possible. - Functions should be JIT-compatible, where possible. - Data validation is not performed here, assume inputs are valid.
- ecef2geodet(ecef)[source]¶
Use pyproj to convert from WGS84 coordinates to geodetic (Cartesian Earth Centered Earth Fixed (ECEF) to latitude, longitude, altitude).
- Parameters:
ecef (
Any) – Nx3 array of ECEF x,y,z points in [m]- Returns:
Nx3 array of geodetic latitude [deg], longitude [deg], altitude [m]
- Return type:
ndarray
- ensure_1d(x, backend=None)[source]¶
Ensure the input array is 1-dimensional. Scalars are converted to shape (1,).
- Return type:
Any- Parameters:
x (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | float | list[float])
backend (Any | None)
- ensure_2d(x, n=None, backend=None)[source]¶
Ensure the input array is 2-dimensional. If n is given, ensure the second dimensionn has size n.
- Return type:
Any- Parameters:
x (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | float | list[float] | list[list[float]])
n (int | None)
backend (Any | None)
- finite_diff_2pt(xd, fd, backend=None)[source]¶
Simple 2-point finite difference derivative of fd w.r.t. xd at the sample nodes. Uses forward difference at the first point, backward difference at the last point, and central difference in the interior.
- Parameters:
xd (
Any)fd (
Any)backend (
Any|None)
- Returns:
dfdx
- Return type:
Any
Notes
Must have xd.shape[0] >= 2. No bounds checking is performed
- geodet2ecef(geodet)[source]¶
Use pyproj to convert from WGS84 geodetic coordinates to Cartesian ECEF. Inputs are latitude, longitude (degrees) and altitude (meters).
- Parameters:
geodet (
Any) – Nx3 array of [lat, lon, alt]- Returns:
Nx3 array of ECEF x,y,z points in [m]
- Return type:
ndarray
- great_circle_distance(geodet1, geodet2, backend=None, ignore_elev=False)[source]¶
Uses haversine formual for cirular distance Accounts for change in altitude using euclidian norm
Ref: http://www.movable-type.co.uk/scripts/latlong.html
Can choose to ignore change in elevation for great circle distance at constant altitude
- Parameters:
geodet1 (
Any) – Nx3 array of lat, long, alt [deg, deg, m]geodet2 (
Any) – Nx3 array of lat, long, alt [deg, deg, m]backend (
Any|None)ignore_elev (
bool) – If True, ignore elevation change. Defaults to False.
- Returns:
Array of distances [m] between each pair of points
- Return type:
Any
- interp_haversine(secs, secs_data, ecef_data, backend=None)[source]¶
Interpolate ECEF trajectory data to given times using great-circle (haversine) interpolation. This is more accurate for long distances than linear interpolation in ECEF space. Approximates the Earth as a sphere (reasonable for interpolation).
- Parameters:
secs (
Any) – 1D array of times [s] to interpolate at.secs_data (
Any) – 1D array of times [s] of the data points.ecef_data (
Any) – Nx3 array of ECEF x,y,z points [m] of the data points.backend (
Any|None) – Backend to use (numpy, jax, etc.). Defaults to None.
- Returns:
Mx3 array of interpolated ECEF x,y,z points [m] at times secs.
- Return type:
Any
Notes
This function is not compatible with Jax JIT or grad due to the use of pyproj.
secs_data must be strictly increasing and within the bounds of secs.
ecef_data and secs_data must have the same length along axis 1.
Uses WGS84 Earth radius for haversine calculations.
- is_increasing(x, backend=None)[source]¶
Check if the input array is strictly increasing along the first axis.
- Return type:
bool- Parameters:
x (Any)
backend (Any | None)
- ned_rotation(geodet, xp=None)[source]¶
Get the orientation of the local North-East-Down (NED) frame relative to the ECEF frame at given geodetic locations.
This rotation represents the NED-to-ECEF orientation. Applying this rotation to a vector in NED coordinates transforms it to ECEF coordinates.
- Parameters:
geodet (
Any) – Nx3 array of lat, long, alt [deg, deg, m]xp (Any | None)
- Returns:
scipy Rotation object representing the NED frame orientation
- Return type: