Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# 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))
log.error("mean motion less than 0.0")
return False
elif (satrec.error == 3):
# 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")
return False
elif (satrec.error == 2):