Skip to content

Commit

Permalink
Document how to load satellites from JSON OMM file
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-rhodes committed Feb 15, 2025
1 parent b3afb27 commit f6cf651
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
31 changes: 21 additions & 10 deletions sgp4/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,30 @@
Reading OMM data takes two steps, because OMM supports several different
text formats. First, parse the input text to recover the field names
and values that it stores; second, build a Python satellite object from
those field values. For example, to load OMM from XML:
those field values. The fastest and most efficient format is usually
CSV, since the column names are only given once, on the first line:
>>> with open('sample_omm.xml') as f:
... fields = next(omm.parse_xml(f))
>>> sat = Satrec()
>>> omm.initialize(sat, fields)
>>> with open('sample_omm.csv') as f:
... for fields in omm.parse_csv(f):
... sat = Satrec()
... omm.initialize(sat, fields)
Or, to load OMM from CSV:
The JSON format is more verbose because it repeats the field names over
again in every single record:
>>> with open('sample_omm.csv') as f:
... fields = next(omm.parse_csv(f))
>>> sat = Satrec()
>>> omm.initialize(sat, fields)
>>> import json
>>> with open('sample_omm.json') as f:
... record_list = json.load(f)
>>> for fields in record_list:
... sat = Satrec()
... omm.initialize(sat, fields)
The most verbose format is XML:
>>> with open('sample_omm.xml') as f:
... for fields in omm.parse_xml(f):
... sat = Satrec()
... omm.initialize(sat, fields)
Either way, the satellite object should wind up properly initialized and
ready to start producing positions.
Expand Down
19 changes: 19 additions & 0 deletions sgp4/sample_omm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[{
"OBJECT_NAME": "VANGUARD 1",
"OBJECT_ID": "1958-002B",
"EPOCH": "2025-02-14T14:36:48.662784",
"MEAN_MOTION": 10.85873516,
"ECCENTRICITY": 0.1841322,
"INCLINATION": 34.2493,
"RA_OF_ASC_NODE": 19.2327,
"ARG_OF_PERICENTER": 100.1057,
"MEAN_ANOMALY": 281.1229,
"EPHEMERIS_TYPE": 0,
"CLASSIFICATION_TYPE": "U",
"NORAD_CAT_ID": 5,
"ELEMENT_SET_NO": 999,
"REV_AT_EPOCH": 39027,
"BSTAR": 0.00035436,
"MEAN_MOTION_DOT": 2.64e-6,
"MEAN_MOTION_DDOT": 0
}]

0 comments on commit f6cf651

Please sign in to comment.