Working with Earth Satellites Using Astropy Coordinates¶
Satellite data is normally provided in the Two-Line Element (TLE) format (see here for a definition). These datasets are designed to be used in combination with a theory for orbital propagation model to predict the positions of satellites.
The history of such models is discussed in detail in Vallado et al (2006) who also provide a reference implementation of the SGP4 orbital propagation code, designed to be compatible with the TLE sets provided by the United States Department of Defense, which are available from a source like Celestrak.
The output coordinate frame of the SGP4 model is the True Equator, Mean Equinox
frame (TEME), which is one of the frames built-in to
TEME is an Earth-centered inertial frame (i.e., it does not rotate with respect
to the stars). Several definitions exist;
astropy uses the implementation described
in Vallado et al (2006).
Finding TEME Coordinates from TLE Data¶
There is currently no support in
astropy.coordinates for computing satellite orbits
from TLE orbital element sets. Full support for handling TLE files is available in
the Skyfield library, but some advice for dealing
with satellite data in
astropy is below.
You will need some external library to compute the position and velocity of the satellite from the
TLE orbital elements. The SGP4 library can do this. An example
of using this library to find the
TEME coordinates of a satellite is:
>>> from sgp4.api import Satrec >>> from sgp4.api import SGP4_ERRORS >>> s = '1 25544U 98067A 19343.69339541 .00001764 00000-0 38792-4 0 9991' >>> t = '2 25544 51.6439 211.2001 0007417 17.6667 85.6398 15.50103472202482' >>> satellite = Satrec.twoline2rv(s, t)
satellite object has a method,
satellite.sgp4, that will try to compute the TEME position
and velocity at a given time:
>>> from astropy.time import Time >>> t = Time(2458827.362605, format='jd') >>> error_code, teme_p, teme_v = satellite.sgp4(t.jd1, t.jd2) # in km and km/s >>> if error_code != 0: ... raise RuntimeError(SGP4_ERRORS[error_code])
Now that we have the position and velocity in kilometers and kilometers per second, we can create a
position in the
TEME reference frame:
>>> from astropy.coordinates import TEME, CartesianDifferential, CartesianRepresentation >>> from astropy import units as u >>> teme_p = CartesianRepresentation(teme_p*u.km) >>> teme_v = CartesianDifferential(teme_v*u.km/u.s) >>> teme = TEME(teme_p.with_differentials(teme_v), obstime=t)
Note how we are careful to set the observed time of the
TEME frame to
the time at which we calculated satellite position.
Transforming TEME to Other Coordinate Systems¶
For example, to find the overhead latitude, longitude, and height of the satellite:
>>> from astropy.coordinates import ITRS >>> itrs = teme.transform_to(ITRS(obstime=t)) >>> location = itrs.earth_location >>> location.geodetic GeodeticLocation(lon=<Longitude 160.34199789 deg>, lat=<Latitude -24.6609379 deg>, height=<Quantity 420.17927591 km>)
Or, if you want to find the altitude and azimuth of the satellite from a particular location:
>>> from astropy.coordinates import EarthLocation, AltAz >>> siding_spring = EarthLocation.of_site('aao') >>> aa = teme.transform_to(AltAz(obstime=t, location=siding_spring)) >>> aa.alt <Latitude 10.95229446 deg> >>> aa.az <Longitude 59.30081255 deg>