A library to make satellite propagation via TLEs or OMM possible in the web. Provides the functions necessary for SGP4/SDP4 calculations, as callable javascript. Also provides functions for coordinate transforms and essentials like doppler factor and shadow calculation.
Special thanks to all contributors for improving usability and bug fixes :)
Sites using the library can be found here.
npm install satellite.js// of course you would only import what you need; namespace import is here just for brevity
import * as satellite from 'satellite.js';
// Sample TLE
const tleLine1 = '1 25544U 98067A 19156.50900463 .00003075 00000-0 59442-4 0 9992',
tleLine2 = '2 25544 51.6433 59.2583 0008217 16.4489 347.6017 15.51174618173442';
// Initialize a satellite record
const satrec = satellite.twoline2satrec(tleLine1, tleLine2);
// Or sample OMM - preferred for new applications
const omm = {
"OBJECT_NAME": "HELIOS 2A",
"OBJECT_ID": "2004-049A",
"EPOCH": "2025-03-26T05:19:34.116960",
"MEAN_MOTION": 15.00555103,
"ECCENTRICITY": 0.000583,
"INCLINATION": 98.3164,
"RA_OF_ASC_NODE": 103.8411,
"ARG_OF_PERICENTER": 20.5667,
"MEAN_ANOMALY": 339.5789,
"EPHEMERIS_TYPE": 0,
"CLASSIFICATION_TYPE": "U",
"NORAD_CAT_ID": 28492,
"ELEMENT_SET_NO": 999,
"REV_AT_EPOCH": 8655,
"BSTAR": 0.00048021,
"MEAN_MOTION_DOT": 0.00005995,
"MEAN_MOTION_DDOT": 0
};
const satrecFromOmm = satellite.json2satrec(omm);
// Propagate satellite using time since epoch (in minutes).
const positionAndVelocity = satellite.sgp4(satrec, timeSinceTleEpochMinutes);
// Or you can use a JavaScript Date
const positionAndVelocity = satellite.propagate(satrec, new Date());
// if the result is `null`, it means that the propagation failed;
// consult `satrec.error` property for a specific reason.
if (positionAndVelocity === null) {
switch (satrec.error) {
// all possible values are listed in SatRecError enum:
case satellite.SatRecError.Decayed:
console.log('The satellite has decayed')
// ...
}
}
// The positionAndVelocity result is a pair of ECI coordinates.
// These are the base results from which all other coordinates are derived.
const positionEci = positionAndVelocity.position,
velocityEci = positionAndVelocity.velocity;
// Set the Observer at 122.03 West by 36.96 North, in RADIANS
const observerGd = {
longitude: satellite.degreesToRadians(-122.0308),
latitude: satellite.degreesToRadians(36.9613422),
height: 0.370
};
// You will need GMST for some of the coordinate transforms.
// http://en.wikipedia.org/wiki/Sidereal_time#Definition
const gmst = satellite.gstime(new Date());
// You can get ECF, Geodetic, Look Angles, and Doppler Factor.
const positionEcf = satellite.eciToEcf(positionEci, gmst),
observerEcf = satellite.geodeticToEcf(observerGd),
positionGd = satellite.eciToGeodetic(positionEci, gmst),
lookAngles = satellite.ecfToLookAngles(observerGd, positionEcf),
dopplerFactor = satellite.dopplerFactor(observerCoordsEcf, positionEcf, velocityEcf);
// The coordinates are all stored in key-value pairs.
// ECI and ECF are accessed by `x`, `y`, `z` properties.
const satelliteX = positionEci.x,
satelliteY = positionEci.y,
satelliteZ = positionEci.z;
// Look Angles may be accessed by `azimuth`, `elevation`, `rangeSat` properties.
const azimuth = lookAngles.azimuth,
elevation = lookAngles.elevation,
rangeSat = lookAngles.rangeSat;
// Geodetic coords are accessed via `longitude`, `latitude`, `height`.
const longitude = positionGd.longitude,
latitude = positionGd.latitude,
height = positionGd.height;
// Convert the RADIANS to DEGREES.
const longitudeDeg = satellite.degreesLong(longitude),
latitudeDeg = satellite.degreesLat(latitude);- TS Kelso's Columns for Satellite Times, Orbital Propagation Parts I and II a must!
- Wikipedia: Simplified Perturbations Model
- SpaceTrack Report #3, by Hoots and Roehrich.
The TypeScript in this library is heavily based (propagation procedures straight copied) from:
- The python sgp4 by Brandon Rhodes
- The C++ code by David Vallado, et al
The original PKG-INFO file from the python library is included.
The coordinate transforms are based off T.S. Kelso's columns:
And the coursework for UC Boulder's ASEN students
I would recommend anybody interested in satellite tracking or orbital propagation to read all of TS Kelso's columns. Without his work, this project would not be possible.
Get a free Space Track account and download your own up to date TLEs or OMM for use with this library.
See Contributing section on the site.
Like Brandon Rhodes before, there is as little difference as possible between this implementation and the prior works on SGP4 algorithm. This is to make adapting future changes suggested by Vallado much simpler. Thus, some of the code conventions used in this library are very weird.
Major thanks go to Brandon Rhodes, TS Kelso, David Vallado's team, and Professor Steve Petersen (AC6P) of UCSC.
The MIT License is chosen because this library is originally a derivative work off Brandon Rhodes sgp4, and that is licensed with MIT.
Shashwat Kandadai worked in the Dining Hall at UCSC for a month, which means he signed a form that gives UCSC partial ownership of anything he make while under their aegis, so it is included as owners of the copyright. Please email all complaints to help@ucsc.edu