- OCaml 98%
- Shell 2%
coordinate #
Reference frames, time scales and map projections for satellite operations.
SGP4 gives a satellite's position in TEME, an inertial frame tied to the
equator of date; a ground station wants its elevation and azimuth; an imaging
payload wants the latitude and longitude it is looking at; and a Sentinel-2
scene arrives in UTM eastings and northings. coordinate converts between
those.
The Earth's rotation axis moves slowly: it precesses over about 26,000
years and nods (nutation) with a main period of 18.6 years. The equator "of
date" is the equator as it lies at the instant of the observation, while
J2000 freezes it at noon on 1 January 2000. TEME (True Equator, Mean
Equinox) uses the true equator of date and a mean equinox, the frame SGP4's
equations happen to produce, so Coordinate.teme_to_j2000_at applies the
IAU-76 precession and the leading 13 terms of the IAU-1980 nutation for the
given instant to reach J2000.
coordinate covers TEME, ECEF (Earth-fixed), J2000 (EME2000) and geodetic
coordinates on the WGS-84 ellipsoid, Greenwich sidereal time, the local
east-north-up frame of a ground station, the low-precision solar ephemeris and
the Earth's shadow cone from Vallado, the ground point of an off-nadir
boresight, and UTM projections that agree with PROJ to 1e-8 m.
Positions are Vec3.t vectors in kilometres and angles are in radians, except
in a Coordinate.geodetic record, whose latitude and longitude are in
degrees and whose altitude is in kilometres.
Install #
$ opam install coordinate
If opam cannot find the package, add the overlay repository first:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install coordinate
Usage #
(* Convert SGP4 TEME output to geodetic coordinates. *)
let report_position ~unix_time (teme_pos : Vec3.t) =
let gmst = Coordinate.gmst_of_unix unix_time in
let ecef = Coordinate.ecef_of_teme ~gmst teme_pos in
let geo = Coordinate.geodetic_of_ecef ecef in
Fmt.pr "Lat: %.4f Lon: %.4f Alt: %.1f km@."
geo.lat geo.lon geo.alt
API #
- Constants:
earth_radius,earth_flattening,earth_mu,earth_j2,earth_rotation_rateandastronomical_unit, from WGS-84 and the IAU. - Time:
gmst_of_unixandgast_of_unix(sidereal time), and Julian date conversions. - Frames:
ecef_of_temeandteme_of_ecef,ecef_of_j2000andj2000_of_ecef(rotations by a sidereal angle), andteme_to_j2000_atandj2000_to_teme_at(IAU-76 precession and IAU-1980 nutation). - Geodetic:
geodetic_of_ecef,ecef_of_geodeticandgeodetic_of_teme. - Sun and shadow:
sun_mod,sun_ecef,subsolarandshadow. Coordinate.Topocentric: the east-north-up frame at a point, whose up is the ellipsoid normal, with the elevation and azimuth of a target.ground_point: where a boresight from a spacecraft meets the ellipsoid.Coordinate.Projection: WGS-84 geographic coordinates (EPSG 4326) and the sixty UTM zones, by EPSG code. Polar stereographic projections are not implemented.
The tests in test/interop/proj/ check the UTM projection against values
printed by PROJ's cs2cs.
License #
ISC. See LICENSE.md.