How to use the sgp4.earth_gravity.wgs84 function in sgp4

To help you get started, we’ve selected a few sgp4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github consensys-space / trusat-orbit / satfit_performance.py View on Github external
# Derived quantities
    satrec.jdsatepoch     = TLE.jdsatepoch     # Julian date
    satrec.jdSGP4epoch    = satrec.jdsatepoch - 2433281.5
    # satrec.epoch_datetime = TLE.epoch_datetime # Python datetime

    # Pass the source tle_id through the SGP4 class variable, for TLE genealogy
    satrec.parent_tle_id = 0 # int(TLE.tle_id)

    # SGP4 mode variables
    satrec.operationmode  = u'i' # Unicode for cython
    satrec.error          = 0

    if (gravconst == "wgs72old"):
        whichconst = earth_gravity.wgs72old
    elif (gravconst == "wgs84"):
        whichconst = earth_gravity.wgs84
    else:
        # Most popular const used by TLEs
        whichconst = earth_gravity.wgs72
    # satrec.whichconst     = whichconst  # Python extension: remembers its consts
    # satrec.whichconst = gravconst
    rtn_code = sgp4init("wgs72", satrec.operationmode, satrec.satnum, 
             satrec.jdSGP4epoch, # epoch time in days from jan 0, 1950. 0 hr
             satrec.bstar, satrec.ndot, satrec.nddot, satrec.ecco, satrec.argpo, 
             satrec.inclo, satrec.mo, satrec.no_kozai, satrec.nodeo, satrec)
    if (rtn_code is not True):
        if (satrec.error == 1):
            log.error("sgp4init error {}".format(satrec.error))
            log.error("mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er")
            return False
        elif (satrec.error == 2):
            log.error("sgp4init error {}".format(satrec.error))
github satellogic / orbit-predictor / orbit_predictor / predictors / tle.py View on Github external
def _propagate_eci(self, when_utc=None):
        """Return position and velocity in the given date using ECI coordinate system."""
        tle = self.source.get_tle(self.sate_id, when_utc)
        logger.debug("Propagating using ECI. sate_id: %s, when_utc: %s, tle: %s",
                     self.sate_id, when_utc, tle)
        tle_line_1, tle_line_2 = tle.lines
        sgp4_sate = twoline2rv(tle_line_1, tle_line_2, wgs84)
        timetuple = when_utc.timetuple()[:6]
        position_eci, velocity_eci = sgp4_sate.propagate(*timetuple)
        return position_eci, velocity_eci
github satellogic / orbit-predictor / orbit_predictor / constants.py View on Github external
from math import pi, radians

from sgp4.earth_gravity import wgs84


AU = 149597870.700  # km

LIGHT_SPEED_KMS = 299792.458  # km / s

OMEGA = 2 * pi / (86400 * 365.2421897)  # rad / s
MU_E = wgs84.mu  # km3 / s2
R_E_KM = wgs84.radiusearthkm  # km
R_E_MEAN_KM = 6371.0087714  # km
F_E = 1 / 298.257223560
J2 = wgs84.j2
OMEGA_E = 7.292115e-5  # rad / s
ALPHA_UMB = radians(0.264121687)  # rad - from Vallado, section 5.3
ALPHA_PEN = radians(0.269007205)  # rad - from Vallado, section 5.3
github satellogic / orbit-predictor / orbit_predictor / predictors / accurate.py View on Github external
def _propagator(self):
        tle_line_1, tle_line_2 = self.tle.lines
        return twoline2rv(tle_line_1, tle_line_2, wgs84)
github satellogic / orbit-predictor / orbit_predictor / sources.py View on Github external
def get_predictor_from_tle_lines(tle_lines):
    db = MemoryTLESource()
    sgp4_sat = twoline2rv(tle_lines[0], tle_lines[1], wgs84)
    db.add_tle(sgp4_sat.satnum, tuple(tle_lines), sgp4_sat.epoch)
    predictor = TLEPredictor(sgp4_sat.satnum, db)
    return predictor
github satellogic / orbit-predictor / orbit_predictor / constants.py View on Github external
from math import pi, radians

from sgp4.earth_gravity import wgs84


AU = 149597870.700  # km

LIGHT_SPEED_KMS = 299792.458  # km / s

OMEGA = 2 * pi / (86400 * 365.2421897)  # rad / s
MU_E = wgs84.mu  # km3 / s2
R_E_KM = wgs84.radiusearthkm  # km
R_E_MEAN_KM = 6371.0087714  # km
F_E = 1 / 298.257223560
J2 = wgs84.j2
OMEGA_E = 7.292115e-5  # rad / s
ALPHA_UMB = radians(0.264121687)  # rad - from Vallado, section 5.3
ALPHA_PEN = radians(0.269007205)  # rad - from Vallado, section 5.3