From 800c38ec92cd8389eb73c8f8aa37685f3a6f46e4 Mon Sep 17 00:00:00 2001 From: Florian Bender Date: Thu, 8 Sep 2016 21:38:43 +0100 Subject: [PATCH] Allow different gravity model when parsing TLEs Implements an optional fourth parameter to `KeplerianElements.from_tle()` to enable using a different gravity model than the default `wgs72` one. Accepts any `namedtuple` with the same entries as the gravity models provided by SGP4. Example usage: ``` from sgp4.earth_gravity import wgs84 # ... other imports and definitions, incl. line1, line2, and earth ... ke = KeplerianElements.from_tle(line1, line2, earth, gravity_model=wgs84) ``` --- orbital/elements.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orbital/elements.py b/orbital/elements.py index 35d1e30..afd4bf1 100644 --- a/orbital/elements.py +++ b/orbital/elements.py @@ -152,11 +152,11 @@ def from_state_vector(cls, r, v, body, ref_epoch=J2000): return self @classmethod - def from_tle(cls, line1, line2, body): + def from_tle(cls, line1, line2, body, gravity_model=wgs72): """Create object by parsing TLE using SGP4.""" # Get state vector at TLE epoch - sat = sgp4.io.twoline2rv(line1, line2, wgs72) + sat = sgp4.io.twoline2rv(line1, line2, gravity_model) r, v = sgp4.propagation.sgp4(sat, 0) ref_epoch = time.Time(sat.epoch, scale='utc')