astrix.functs module

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 ((N,) strictly increasing array of x-locations, must have N>=2)

  • fd ((N, ...) array of function values; derivative is taken along axis 0)

  • backend (optional, backend to use (numpy, jax, etc.))

Returns:

dfdx

Return type:

(N, …) array of derivatives at each xd[i]

Notes

Must have xd.shape[0] >= 2. No bounds checking is performed

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 (Array) – Nx3 array of lat, long, alt [deg, deg, m]

  • geodet2 (Array) – Nx3 array of lat, long, alt [deg, deg, m]

  • backend (Backend, optional)

  • ignore_elev (bool, optional) – If True, ignore elevation change. Defaults to False.

Returns:

Array of distances [m] between each pair of points

Return type:

Array

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 (Array) – 1D array of times [s] to interpolate at.

  • secs_data (Array) – 1D array of times [s] of the data points.

  • ecef_data (Array) – Nx3 array of ECEF x,y,z points [m] of the data points.

  • backend (Backend, optional) – 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:

Array

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.

ned_rotation(geodet, xp=None)[source]

Get the rotation from ECEF base to the North-East-Down frame at given geodetic locations.

Parameters:
  • pos_geodet (Array) – Nx3 array of lat, long, alt [deg, deg, m]

  • geodet (Any)

  • xp (Any | None)

Returns:

scipy Rotation object representing the NED frame rotation

Return type:

Rotation