Skip to main content

Core utilities for coordinate conversions, distance calculations, geolocation, and orbital mechanics

Project description

GeoSol Research Logo

Utils

Utility functions available for any project.

This library is a general collection of utility functions and constants with minimal requirements. Requires Python 3.12+.

Installation

pip install gri-utils

For development:

git clone https://gitlab.com/geosol-foss/python/gri-utils.git
cd gri-utils
. .init_venv.sh

Quick Start

from gri_utils import conversion, distance, constants

# Convert LLA (lat, lon, alt) to ECEF XYZ
xyz = conversion.lla_to_xyz([40.0, -105.0, 1600.0])

# Surface distance between two points (Vincenty, accurate to ~0.5 mm)
d_m = distance.vincenty([40.0, -105.0], [41.0, -104.0])

# Coordinate deltas
enu = conversion.get_enu(xyz_from, xyz_to)
aer = conversion.get_aer(xyz_from, xyz_to)

# Earth constants
print(constants.ER_M)   # Earth equatorial radius (meters)
print(constants.C)       # Speed of light (m/s)

Constants

Common geolocation constants including Earth's equatorial and polar radii, eccentricity, flattening, and statistical scaling factors for sigma to 95% confidence conversions. Also provides a GeoEllipsoid dataclass and a pre-built WGS84 instance exposing .a, .b, .f, .e2, .n(lat_rad) (prime vertical) and .m(lat_rad) (meridional) radii of curvature.

See Constants README

Conversion

Coordinate system transformations between XYZ (ECEF), LLA (Lat/Lon/Alt), ENU, NED, AER, CCR, and ECI. Includes:

  • ECEF <-> ECI: Time-dependent transformations between Earth-fixed and inertial frames via GMST
  • Julian Date: Unix timestamp and datetime conversions to/from Julian Date
  • GMST: Greenwich Mean Sidereal Time calculations (IAU 2006 precession model)
  • Rotation matrices: xyz_enu_rotation, enu_xyz_rotation, xyz_ned_rotation, ned_xyz_rotation
  • Delta operations: get_*, translate_*, xyz_to_*, *_to_xyz for each coordinate type
  • Covariance matrix transformations: xyz_to_enu_cov, enu_to_xyz_cov, xyz_to_ned_cov, ned_to_xyz_cov
  • DMS conversions: Degrees/Minutes/Seconds <-> decimal degrees

All conversion functions support vectorized inputs for efficient batch processing of (N, 3) arrays. Covariance matrix functions support stacked (N, 3, 3) matrices.

See Conversion README

Distance

Surface distance calculations with multiple formulas: simple spherical approximation (fast, good for relative distances <500km), Haversine (standard spherical, ~0.5% error), and Vincenty (iterative oblate spheroid, accurate to ~0.5mm). Also includes central angle calculations and osculating sphere computations.

Most distance functions support vectorized inputs for efficient batch processing of (N, 2+) LLA or (N, 3) XYZ arrays.

See Distance README

Ellipsoids

Conversions between 2D/3D ellipse parameters (SMA, SMI, ORI, ALT) and covariance matrices. Includes sigma <-> 95% confidence scaling for scalars, vectors, and matrices.

See Ellipsoids README

Matrices

Matrix and vector rotation utilities for 2D and 3D operations around one or more axes. Also includes block diagonal matrix construction and decomposition utilities.

See Matrices README

Resources

Programming utilities including a memory/CPU usage measuring decorator and a Thread subclass that returns values from its target function.

See Resources README

Stats

Statistical utilities for confidence intervals and scale factor analysis. Includes Poisson CI (Garwood method), quantile CI (normal approximation to binomial), ratio CI (Walters logarithm method), and scale factor analysis for ellipse calibration.

See Stats README

Geolocation

Mathematical building blocks for geolocation solvers:

  • Whitened least squares: Generic Cholesky-whitened nonlinear solver with correlated measurement support
  • Predicted covariance: Analytical GDOP computation from Jacobian and measurement noise (no solver iteration needed)
  • Default initial guess: Projects collector centroid onto Earth surface for solver initialization

Observable-specific locators (TDOA, AOA, FDOA, hybrid) that wrap these primitives live in gri-geosim.

See Geolocation README

Observables

Sensor measurement simulation (forward problem - state to measurements):

  • Range: Euclidean distance from collector to emitter
  • AOA: Angle of Arrival direction cosines (ENU-based and quaternion-based for arbitrary sensor orientation)
  • TDOA: Time Difference of Arrival between two collectors
  • TDOA-dot: Time derivative of TDOA (s/s, frequency-independent form of FDOA)
  • FDOA: Frequency Difference of Arrival (Doppler)
  • PDOA: Phase Difference of Arrival for interferometer arrays
  • Gradients: Jacobians available for optimization workflows
  • Residual factories: Each observable provides a get_*_residual function for use with terrain intersection algorithms

Quaternions use scipy convention [x, y, z, w] (scalar-last).

See Observables README

Orbit

Two-body Keplerian orbit mechanics for orbital propagation and analysis:

  • Orbital Elements: Classical Keplerian parameters (SMA, eccentricity, inclination, RAAN, arg_periapsis, true_anomaly)
  • State Vectors: Position, velocity, acceleration at specific times
  • TLE Parsing: Two-Line Element data conversion to orbital elements
  • Orbit Fitting: Fit elements from position/velocity state or multiple observations
  • Propagation: elements_to_state for forward propagation
  • Properties: Period, apogee, perigee, specific energy, angular momentum

Note: Pure Keplerian mechanics only (no perturbations). For TLE propagation with J2/drag, use SGP4 library.

See Orbit README

Terrain

Pure math functions for terrain represented as XYZ surface grids (sheets) in ECEF coordinates:

  • Sheet operations: LLA-to-XYZ conversion, bicubic interpolation, resolution measurement
  • Sheet bounds: Radial bounding surfaces for fast ray rejection
  • Ray intersection: Adaptive-step ray-sheet intersection
  • Visibility/shadow: Shadow depth scalar field, visibility masks, shadow boundary contours
  • Marching squares: Iso-contour extraction from 2D scalar fields
  • Sheet intersection: Generic terrain intersection with observable iso-surfaces (range, TDOA, FDOA, AOA)
  • TerrainSource ABC: Abstract interface for terrain data providers (implemented by gri-terrain)
  • Sheet stitching: Mosaic multiple tiles into a single contiguous array
  • Adaptive intersection: Subsample-based efficient intersection for large terrain datasets

See Terrain README

Dependencies

  • numpy: Array operations and linear algebra
  • scipy: Scientific computing (coordinate conversions, optimization)
  • psutil: System resource monitoring (optional, for resources module)

Other Projects

Current list of other GRI FOSS Projects we are building and maintaining.

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gri_utils-0.3.5.tar.gz (249.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gri_utils-0.3.5-py3-none-any.whl (193.9 kB view details)

Uploaded Python 3

File details

Details for the file gri_utils-0.3.5.tar.gz.

File metadata

  • Download URL: gri_utils-0.3.5.tar.gz
  • Upload date:
  • Size: 249.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gri_utils-0.3.5.tar.gz
Algorithm Hash digest
SHA256 a7d0011ec93a26d13141797677823e46fe8938392b5f2b956e197ddd829309cf
MD5 cb2a4fba404e1473a3f64c9a74ede7c0
BLAKE2b-256 827b9057ddd04839d93f69d691786d3ed3e2bbe2d03eef0922542aa97c407a3b

See more details on using hashes here.

File details

Details for the file gri_utils-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: gri_utils-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 193.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gri_utils-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 378292f0cfddd5a60f1e35f31d5e9f7f21dbf64c8cfcd369de74dceb68f47b25
MD5 7b5865daf9d4ffd26064276d438c3703
BLAKE2b-256 802041b1845c3ac02f5fb4eed3e22fdad52d39ef4c1d0c6d06c7b0d4b0253c61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page