Satellite#

class cysgp4.Satellite(PyTle tle, PyObserver obs=None, PyDateTime pydt=None, double mjd_cache_resolution=MJD_RESOLUTION, unicode on_error=u'raise')#

Bases: object

Calculate position of a satellite at a given time.

The satellite is defined via a TLE (see PyTle). Furthermore, for apparent positions of the satellite, an observer (see PyObserver) needs to be defined.

The position calculations are lazy, i.e., only calculated if the newly requested time differs by a certain amount from the last time at which a calculation was performed. The granularity of this “cache” can be defined via the mjd_cache_resolution parameter.

Parameters:
tlePyTle

TLE instance of the satellite of interest.

obsPyObserver or None (default: None)

Observer instance. If None then the observer location is set to (0 deg, 0 deg, 0 km).

pydtPyDateTime or None (default: None)

Date and time at which to calculate the position. If None then the current datetime is used, as given by a call to utcnow().

mjd_cache_resolutiondouble (default: 0.001)

Granularity of the internal cache [s]. Satellite positions are calculated only if the newly requested datetime differs by more than this from the previous calculation.

on_errorstr, optional (either ‘raise’ or ‘coerce_to_nan’, default: ‘raise’)

If the underlying SGP C++ library throws an error (which often happens if one works with times that are strongly deviating from the TLE epoch), a Python RuntimeError is usually thrown. For batch processing, this is not always desirable. If on_error = 'coerce_to_nan' then C++ errors will be suppressed and the resulting position vectors will be converted to NaN-values instead.

Returns:
satSatellite object

Examples

The following demonstrates how a typical use of the Satellite class would look like:

>>> from cysgp4 import *

>>> pydt = PyDateTime.from_mjd(58805.57)
>>> lon_deg, lat_deg = 6.88375, 50.525
>>> alt_km = 0.366
>>> obs = PyObserver(lon_deg, lat_deg, alt_km)

>>> hst_tle = PyTle(
... 'HST',
... '1 20580U 90037B   19321.38711875  .00000471  00000-0  17700-4 0  9991',
... '2 20580  28.4699 288.8102 0002495 321.7771 171.5855 15.09299865423838',
... )

>>> sat = Satellite(hst_tle, obs, pydt)
>>> # can now query positions, also for different times
>>> sat.eci_pos().loc  # ECI cartesian position
(5879.5931344459295, 1545.7455647032068, 3287.4155452595)
>>> sat.eci_pos().vel  # ECI cartesian velocity
(-1.8205895517672226, 7.374044252723081, -0.20697960810978586)
>>> sat.geo_pos()  # geographic position
<PyCoordGeodetic: 112.2146d, 28.5509d, 538.0186km>
>>> sat.topo_pos()  # topocentric position
<PyCoordTopocentric: 60.2453d, -35.6844d, 8314.5683km, 3.5087km/s>

>>> # change time
>>> sat.mjd += 1 / 720.  # one minute later
>>> sat.topo_pos()
<PyCoordTopocentric: 54.8446d, -38.2749d, 8734.9195km, 3.4885km/s>

>>> # change by less than cache resolution (1 ms)
>>> sat.topo_pos().az, sat.topo_pos().el
(54.84463503781068, -38.274852915850126)
>>> sat.mjd += 0.0005 / 86400.  # 0.5 ms
>>> sat.topo_pos().az, sat.topo_pos().el
(54.84463503781068, -38.274852915850126)
>>> # change by another 0.5 ms triggers re-calculation
>>> sat.mjd += 0.00051 / 86400.
>>> sat.topo_pos().az, sat.topo_pos().el
(54.844568313870965, -38.274885794151324)

Constructs a new Satellite object from given TLE

Attributes Summary

mjd

Modified Julian Date (see also Class documentation).

pydt

Datetime (see also Class documentation).

Methods Summary

eci_pos(self)

ECI position of satellite.

geo_pos(self)

Geographic (geodetic) position of satellite.

topo_pos(self)

Topocentric position of satellite w.r.t.

Attributes Documentation

mjd#

Modified Julian Date (see also Class documentation).

pydt#

Datetime (see also Class documentation).

Methods Documentation

eci_pos(self)#

ECI position of satellite.

Lazily calculated, i.e., only if difference to the timestamp for which the previous calculation was performed is larger than the MJD cache resolution (see class documentation).

Returns:
eciPyEci

ECI position of satellite.

geo_pos(self)#

Geographic (geodetic) position of satellite.

Lazily calculated, i.e., only if difference to the timestamp for which the previous calculation was performed is larger than the MJD cache resolution (see class documentation).

Returns:
geoPyCoordGeodetic

Geographic position of satellite.

topo_pos(self)#

Topocentric position of satellite w.r.t. given observer.

Lazily calculated, i.e., only if difference to the timestamp for which the previous calculation was performed is larger than the MJD cache resolution (see class documentation).

Returns:
topoPyCoordTopocentric

Topocentric position of satellite w.r.t. given observer.