I am working on creating a small Python script that pulls TLE definitions from Celestrak and/or the Space-Track API and looks for close conjunctions in the sky as seen by an earth station. To future-proof the script, I would like to avoid using the traditional TLE/3LE text format so that there are no issues when 18 SDS starts issuing six digit identifiers. Both Celestrak and Space-Track recommend this approach for new development.
I am pulling down the data in JSON format. Here is a snippet from Celestrak (Space-Track/18 SDS has a very similar format, except it gives the elements as string literals rather than JSON integer/number objects):
{
"OBJECT_NAME": "ISS (ZARYA)",
"OBJECT_ID": "1998-067A",
"EPOCH": "2024-07-09T11:26:59.754336",
"MEAN_MOTION": 15.49695979,
"ECCENTRICITY": 0.0010507,
"INCLINATION": 51.6384,
"RA_OF_ASC_NODE": 204.9033,
"ARG_OF_PERICENTER": 46.5485,
"MEAN_ANOMALY": 119.156,
"EPHEMERIS_TYPE": 0,
"CLASSIFICATION_TYPE": "U",
"NORAD_CAT_ID": 25544,
"ELEMENT_SET_NO": 999,
"REV_AT_EPOCH": 46200,
"BSTAR": 0.00021577,
"MEAN_MOTION_DOT": 0.00011765,
"MEAN_MOTION_DDOT": 0
}
To convert this JSON object to a TLE object in Orekit, I wrote the following function (note the float() and int() casts are there to handle the string literals from the Space-Track API):
def create_orekit_tle(tle_elems):
launch_year = int(tle_elems['OBJECT_ID'][0:4])
launch_num = int(tle_elems['OBJECT_ID'][5:8])
launch_piece = tle_elems['OBJECT_ID'][8:]
ephem_type = 0 # always zero for public TLEs
epoch = datetime_to_absolutedate(datetime.datetime.fromisoformat(tle_elems['EPOCH']))
tle = TLE(int(tle_elems['NORAD_CAT_ID']), java.lang.Character(tle_elems['CLASSIFICATION_TYPE']), launch_year, launch_num, \
java.lang.String(launch_piece), ephem_type, int(tle_elems['ELEMENT_SET_NO']), epoch, \
np.radians(float(tle_elems['MEAN_MOTION'])), np.radians(float(tle_elems['MEAN_MOTION_DOT'])), \
np.radians(float(tle_elems['MEAN_MOTION_DDOT'])), float(tle_elems['ECCENTRICITY']), \
np.radians(float(tle_elems['INCLINATION'])), np.radians(float(tle_elems['ARG_OF_PERICENTER'])), \
np.radians(float(tle_elems['RA_OF_ASC_NODE'])), np.radians(float(tle_elems['MEAN_ANOMALY'])), \
int(tle_elems['REV_AT_EPOCH']), float(tle_elems['BSTAR']) )
return tle
This isn’t working - this is the error I get:
InvalidArgsError Traceback (most recent call last)
Cell In[4], line 1
----> 1 tle = exclusiontool.create_orekit_tle(tle_dict[25544])
File ~\Documents\Python Scripts\exclusiontool\exclusiontool.py:85, in create_orekit_tle(tle_elems)
83 ephem_type = 0 # always zero for public TLEs
84 epoch = datetime_to_absolutedate(datetime.datetime.fromisoformat(tle_elems['EPOCH']))
---> 85 tle = TLE(int(tle_elems['NORAD_CAT_ID']), java.lang.Character(tle_elems['CLASSIFICATION_TYPE']), launch_year, launch_num, \
86 java.lang.String(launch_piece), ephem_type, int(tle_elems['ELEMENT_SET_NO']), epoch, \
87 np.radians(float(tle_elems['MEAN_MOTION'])), np.radians(float(tle_elems['MEAN_MOTION_DOT'])), \
88 np.radians(float(tle_elems['MEAN_MOTION_DDOT'])), float(tle_elems['ECCENTRICITY']), \
89 np.radians(float(tle_elems['INCLINATION'])), np.radians(float(tle_elems['ARG_OF_PERICENTER'])), \
90 np.radians(float(tle_elems['RA_OF_ASC_NODE'])), np.radians(float(tle_elems['MEAN_ANOMALY'])), \
91 int(tle_elems['REV_AT_EPOCH']), float(tle_elems['BSTAR']) )
92 return tle
InvalidArgsError: (<class 'org.orekit.propagation.analytical.tle.TLE'>, '__init__', (25544, <Character: U>, 1998, 67, <String: A>, 0, 999, <AbsoluteDate: 2024-07-09T11:26:59.754336Z>, 0.270472972384669, 2.0533798649713286e-06, 0.0, 0.0010507, 0.9012601004618398, 0.8124245868645804, 3.576237233201697, 2.0796645235063633, 46200, 0.00021577))
Any thoughts? Note that I originally had the classification
and launchPiece
arguments as Python string types. I tried converting them to java.lang.Character
and java.lang.String
objects respectively, but no luck.