How to use the sgp4.earth_gravity.wgs72 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 galactics / beyond / beyond / propagators / sgp4.py View on Github external
"""Initialize the propagator

        Args:
            orbit (Orbit)
        """

        self._orbit = orbit
        tle = Tle.from_orbit(orbit)
        lines = tle.text.splitlines()

        if len(lines) == 3:
            _, line1, line2 = lines
        else:
            line1, line2 = lines

        self.tle = twoline2rv(line1, line2, wgs72)
github pysat / pysat / pysat / instruments / pysat_sgp4.py View on Github external
# TLEs (Two Line Elements for ISS)
    # format of TLEs is fixed and available from wikipedia...
    # lines encode list of orbital elements of an Earth-orbiting object
    # for a given point in time
    line1 = ('1 25544U 98067A   18135.61844383  .00002728  00000-0  48567-4 0  9998')
    line2 = ('2 25544  51.6402 181.0633 0004018  88.8954  22.2246 15.54059185113452')
    # use ISS defaults if not provided by user
    if TLE1 is not None:
        line1 = TLE1
    if TLE2 is not None:
        line2 = TLE2

    # create satellite from TLEs and assuming a gravity model
    # according to module webpage, wgs72 is common
    satellite = twoline2rv(line1, line2, wgs72)

    # grab date from filename
    parts = os.path.split(fnames[0])[-1].split('-')
    yr = int(parts[0])
    month = int(parts[1])
    day = int(parts[2][0:2])
    date = pysat.datetime(yr, month, day)

    # create timing at 1 Hz (for 1 day)
    times = pds.date_range(start=date, end=date+pds.DateOffset(seconds=86399),
                           freq='1S')
    # reduce requirements if on testing server
    # TODO Remove this when testing resources are higher
    on_travis = os.environ.get('ONTRAVIS') == 'True'
    if on_travis:
        times = times[0:100]
github bwinkel / pycraf / pycraf / satellite / satellite.py View on Github external
'''

    try:
        import sgp4
        from sgp4.earth_gravity import wgs72
        from sgp4.io import twoline2rv, Satellite
    except ImportError:
        raise ImportError(
            'The "sgp4" package is necessary to use this function.'
            )

    tle_string_list = tle_string.split('\n')
    satname = tle_string_list[0]
    if satname[0:2] == '0 ':  # remove leading 0 if present
        satname = satname[2:]
    satellite = twoline2rv(tle_string_list[1], tle_string_list[2], wgs72)

    return satname, satellite
github consensys-space / trusat-orbit / satfit.py View on Github external
# 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")
            return False
        elif (satrec.error == 2):
            log.error("sgp4init error {}".format(satrec.error))
            log.error("mean motion less than 0.0")
            return False
github brandon-rhodes / python-sgp4 / tmp.py View on Github external
def trad(jd_array, fr_array):
    from sgp4.earth_gravity import wgs72
    from sgp4.io import twoline2rv
    from sgp4.propagation import sgp4

    sats = []
    lines = iter(text.splitlines())
    for name in lines:
        line1 = next(lines)
        line2 = next(lines)
        sat = twoline2rv(line1, line2, wgs72)
        sats.append(sat)

    sats = sats[:20]  # first 20 sats

    print(len(sats), 'pure Python sats')
    print(len(jd_array), 'and', len(fr_array), 'times')

    zipped_times = list(zip(jd_array, fr_array))

    for sat in sats:
        for jd, fr in zipped_times:
            t = (jd - sat.jdsatepoch + fr) * 1440.0
            r, v = sgp4(sat, t)
        #     print(r)
github aerospaceresearch / orbitdeterminator / orbitdeterminator / propagation / sgp4_prop.py View on Github external
def kep_to_sat(kep,epoch,bstar=0.21109E-4,whichconst=wgs72,afspc_mode=False):
    """kep_to_sat(kep,epoch,bstar=0.21109E-4,whichconst=wgs72,afspc_mode=False)

       Converts a set of keplerian elements into a Satellite object.

       Args:
           kep(1x6 numpy array): the osculating keplerian elements at epoch
           epoch(float): the epoch
           bstar(float): bstar drag coefficient
           whichconst(float): gravity model. refer pypi sgp4 documentation
           afspc_mode(boolean): refer pypi sgp4 documentation

      Returns:
           Satellite object: an sgp4 satellite object encapsulating the arguments
    """

    deg2rad  =  np.pi / 180.0;         #    0.0174532925199433
github aerospaceresearch / orbitdeterminator / orbitdeterminator / kep_determination / custom_prop.py View on Github external
def kep_to_sat(kep,epoch,bstar=0.21109E-4,whichconst=wgs72,afspc_mode=False):
    """kep_to_sat(kep,epoch,bstar=0.21109E-4,whichconst=wgs72,afspc_mode=False)

       Converts a set of keplerian elements into a Satellite object.

       Args:
           kep(1x6 numpy array): the osculating keplerian elements at epoch
           epoch(float): the epoch
           bstar(float): bstar drag coefficient
           whichconst(float): gravity model. refer pypi sgp4 documentation
           afspc_mode(boolean): refer pypi sgp4 documentation

      Returns:
           Satellite object: an sgp4 satellite object encapsulating the arguments
    """

    deg2rad  =  np.pi / 180.0;         #    0.0174532925199433