def export_omm(satrec, object_name): launch_year = int(satrec.intldesg[:2]) launch_year += 1900 + (launch_year < 57) * 100 object_id = '{0}-{1}'.format(launch_year, satrec.intldesg[2:]) return { "OBJECT_NAME": object_name, "OBJECT_ID": object_id, "CENTER_NAME": "EARTH", "REF_FRAME": "TEME", "TIME_SYSTEM": "UTC", "MEAN_ELEMENT_THEORY": "SGP4", "EPOCH": sat_epoch_datetime(satrec).strftime('%Y-%m-%dT%H:%M:%S.%f'), "MEAN_MOTION": satrec.no_kozai * _xpdotp, "ECCENTRICITY": satrec.ecco, "INCLINATION": satrec.inclo / _deg2rad, "RA_OF_ASC_NODE": satrec.nodeo / _deg2rad, "ARG_OF_PERICENTER": satrec.argpo / _deg2rad, "MEAN_ANOMALY": satrec.mo / _deg2rad, "EPHEMERIS_TYPE": satrec.ephtype, "CLASSIFICATION_TYPE": satrec.classification, "NORAD_CAT_ID": satrec.satnum, "ELEMENT_SET_NO": satrec.elnum, "REV_AT_EPOCH": satrec.revnum, "BSTAR": satrec.bstar, "MEAN_MOTION_DOT": satrec.ndot * (_xpdotp * 1440.0), "MEAN_MOTION_DDOT": satrec.nddot * (_xpdotp * 1440.0 * 1440), }
def test_december_32(): # ISS [Orbit 606], whose date is 2019 plus 366.82137887 days. # The core SGP4 routines handled this fine, but my hamfisted # attempt to provide a Python datetime for "convenience" ran # into an overflow. a = '1 25544U 98067A 19366.82137887 .00016717 00000-0 10270-3 0 9129' b = '2 25544 51.6392 96.6358 0005156 88.7140 271.4601 15.49497216 6061' correct_epoch = dt.datetime(2020, 1, 1, 19, 42, 47, 134368) # Legacy API. sat = io.twoline2rv(a, b, wgs72) assertEqual(sat.epoch, correct_epoch) correct_epoch = correct_epoch.replace(tzinfo=conveniences.UTC) # Modern API. sat = Satrec.twoline2rv(a, b) assertEqual(conveniences.sat_epoch_datetime(sat), correct_epoch)
def test_sat_epoch_datetime(): sat = Satrec.twoline2rv(LINE1, LINE2) datetime = conveniences.sat_epoch_datetime(sat) zone = conveniences.UTC assertEqual(datetime, dt.datetime(2000, 6, 27, 18, 50, 19, 733568, zone))