How to use the sgp4.earth_gravity.wgs72old 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
satrec.revnum         = TLE.orbit_number

    # 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
github consensys-space / trusat-orbit / satfit.py View on Github external
satrec.mo             = TLE.mean_anomaly_radians # rad

    # TODO: Once mean_motion_radians_per_minute is added to the DB, use it directly here
    satrec.no_kozai       = TLE.mean_motion_orbits_per_day * nocon # rad/min
    satrec.revnum         = TLE.orbit_num

    # Derived quantities
    satrec.jdsatepoch     = TLE.jdsatepoch  # Julian date
    satrec.epoch          = TLE.epoch       # Python datetime

    # SGP4 mode variables
    satrec.operationmode  = False
    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

    # FIXME: Can use jdSGP4epoch here directly with no subctraction, but need to trace all uses  (like the datetime comment above)
    rtn_code = sgp4init(satrec.whichconst, satrec.operationmode, satrec.satnum, 
             satrec.jdsatepoch-2433281.5, # 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")
github brandon-rhodes / python-sgp4 / sgp4 / model.py View on Github external
"""The Satellite class."""

from sgp4.earth_gravity import wgs72old, wgs72, wgs84
from sgp4.ext import days2mdhms, jday
from sgp4.functions import jday as jday2
from sgp4.io import twoline2rv
from sgp4.propagation import sgp4, sgp4init

WGS72OLD = 0
WGS72 = 1
WGS84 = 2
gravity_constants = wgs72old, wgs72, wgs84  # indexed using enum values above
minutes_per_day = 1440.

class Satrec(object):
    """Slow Python-only version of the satellite object."""

    # Approximate the behavior of the C-accelerated class by locking
    # down attribute access, to avoid folks accidentally writing code
    # against this class and adding extra attributes, then moving to a
    # computer where the C-accelerated class is used and having their
    # code suddenly produce errors.
    __slots__ = (
        'Om', 'a', 'alta', 'altp', 'am', 'argpdot', 'argpo', 'atime', 'aycof',
        'bstar', 'cc1', 'cc4', 'cc5', 'classification', 'con41', 'd2', 'd2201',
        'd2211', 'd3', 'd3210', 'd3222', 'd4', 'd4410', 'd4422', 'd5220',
        'd5232', 'd5421', 'd5433', 'dedt', 'del1', 'del2', 'del3', 'delmo',
        'didt', 'dmdt', 'dnodt', 'domdt', 'e3', 'ecco', 'ee2', 'elnum', 'em',