SGP4/SDP4 satellite orbit propagator
README.md

sgp4 #

The SGP4 and SDP4 orbit propagators (Spacetrack Report No. 3) in pure OCaml.

The orbits of tracked satellites are published as Two-Line Element sets
(TLEs). A TLE holds mean elements, orbital elements averaged over the
short-period perturbations and fitted so that one model, SGP4, reproduces the
observations, so the position of a satellite at a given time is only as good as
the SGP4 implementation that propagates it; a generic Keplerian propagator gives
the wrong answer. sgp4 implements the model with Vallado's 2006 corrections:
SGP4 for near-Earth objects, with an orbital period under 225 minutes, and SDP4
for deep-space objects at or above it. init picks the model from the period,
and positions and velocities come out in TEME (True Equator, Mean Equinox), the
Earth-centred frame the model is defined in.

Installation #

Install with opam:

$ opam install sgp4

If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install sgp4

Usage #

Parse a TLE, build the propagator state, then ask for the position and
velocity some minutes after the TLE epoch:

open Sgp4

(* Parse TLE and propagate *)
let tle_string =
  "ISS (ZARYA)\n\
   1 25544U 98067A   21073.51041667  .00001264  00000-0  29621-4 0  9993\n\
   2 25544  51.6442  21.2413 0002180  62.8608  47.5454 15.48915328273145"

let propagate_iss minutes_since_epoch =
  match parse_tle_string tle_string with
  | Error e -> Error e
  | Ok tle -> (
      match init tle with
      | Error e -> Error e
      | Ok state -> propagate state tle minutes_since_epoch)

Testing #

The test suite propagates the 33 satellites of the Vallado et al. (2006) test
set and compares the results with python-sgp4's tcppver.out. A second suite
uses traces from
NASA GMAT R2026a.
It propagates the ISS TLE that GMAT's own SGP4 propagator was given, converts
the result from TEME to J2000, and requires the two to agree within 1 km over
a day. It also parses a GMAT ephemeris computed with a high-fidelity force
model (20x20 gravity, MSISE90 drag, solar radiation pressure and lunisolar
perturbations) and checks its radius and speed stay within physical bounds.

References #

  • F. R. Hoots and R. L. Roehrich, "Spacetrack Report No. 3: Models for
    Propagation of NORAD Element Sets", 1980.
  • D. A. Vallado, P. Crawford, R. Hujsak and T. S. Kelso, "Revisiting
    Spacetrack Report #3", AIAA 2006-6753, 2006.

Licence #

ISC. See LICENSE.md.