Closed jester-xbmc closed 3 years ago
thanks for creating this btw !
You're welcome! I needed it for a project, and thought that wrapping it up as a separate stand-alone module might help my work benefit others who needed to generate low-level satellite locations.
it fails on fields = next(omm.parse_xml(f)) with StopIteration
I would need to see the input file f
to see whether it's empty or missing XML markup. Maybe you could double-check that you have just opened f
? A file can only be read once, and after that the operating system will return no further data no matter how many times you try re-using f
(unless you rewind its file pointer back to the beginning).
Thanks for your reply, kind warning, i'm a total n00b with python...
I'm using fp to read it, below content of the XML file as pulled down by the spacetrack python module
spacetrack line: dataomm = st.omm(norad_cat_id=49044, orderby='epoch desc', limit=1, format='xml')
loader: with open('omm_latest.xml', 'r') as fp: fields = next(omm.parse_xml(fp)) sat = Satrec() omm.initialize(sat, fields)
omm_latest.xml
<?xml version="1.0" encoding="utf-8"?>
<xml><item><CCSDS_OMM_VERS>2.0</CCSDS_OMM_VERS><COMMENT>GENERATED VIA SPACE-TRACK.ORG API</COMMENT><CREATION_DATE>2021-07-25T15:26:14</CREATION_DATE><ORIGINATOR>18 SPCS</ORIGINATOR><OBJECT_
NAME>ISS (NAUKA)</OBJECT_NAME><OBJECT_ID>2021-066A</OBJECT_ID><CENTER_NAME>EARTH</CENTER_NAME><REF_FRAME>TEME</REF_FRAME><TIME_SYSTEM>UTC</TIME_SYSTEM><MEAN_ELEMENT_THEORY>SGP4</MEAN_ELEMEN
T_THEORY><EPOCH>2021-07-25T09:40:10.153920</EPOCH><MEAN_MOTION>15.6612577</MEAN_MOTION><ECCENTRICITY>0.0053389</ECCENTRICITY><INCLINATION>51.6416</INCLINATION><RA_OF_ASC_NODE>154.1953</RA_O
F_ASC_NODE><ARG_OF_PERICENTER>112.1577</ARG_OF_PERICENTER><MEAN_ANOMALY>338.3158</MEAN_ANOMALY><EPHEMERIS_TYPE>0</EPHEMERIS_TYPE><CLASSIFICATION_TYPE>U</CLASSIFICATION_TYPE><NORAD_CAT_ID>49
044</NORAD_CAT_ID><ELEMENT_SET_NO>999</ELEMENT_SET_NO><REV_AT_EPOCH>60</REV_AT_EPOCH><BSTAR>-0.00030913</BSTAR><MEAN_MOTION_DOT>-0.00035582</MEAN_MOTION_DOT><MEAN_MOTION_DDOT>0</MEAN_MOTION
_DDOT><TLE_LINE0>0 ISS (NAUKA)</TLE_LINE0><TLE_LINE1>1 49044U 21066A 21206.40289530 -.00035582 00000-0 -30913-3 0 9992</TLE_LINE1><TLE_LINE2>2 49044 51.6416 154.1953 0053389 112.1577 3
38.3158 15.66125770 603</TLE_LINE2><SEMIMAJOR_AXIS>6748.140</SEMIMAJOR_AXIS><PERIOD>91.947</PERIOD><APOAPSIS>406.033</APOAPSIS><PERIAPSIS>333.977</PERIAPSIS><OBJECT_TYPE>PAYLOAD</OBJECT_T
YPE><DECAYED>0</DECAYED></item></xml>
I'm getting an error:
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 3, column 4
— because your XML above is wrapped at the 189th character, splitting some XML tags into two pieces. Maybe you need to fix your XML? Or was it the pasting that went wrong?
Interesting, I don't think this is a cut an paste error, just copy and pasting from console, could it be because of the way I write the file ?
dataomm = st.omm(norad_cat_id=args.norad_id, orderby='epoch desc', limit=1, format='xml')
with open('omm_latest.xml', 'w') as fp: for line in dataomm: fp.write(line)
I'll close this for now as it could be that XML formatting issue and not SGP4 :)
The XML from Celestrak has an element named "segment":
... <body><segment><metadata><OBJECT_NAME>VANGUARD 1</OBJECT_NAME> ...
I note that your XML lacks an element with that name. Instead it's in an <item>
, it looks like? If different XML sources are going to put satellites in different sorts of XML container elements, it's possible that the parse_xml()
method should take an optional extra argument that would let callers provide the XPath expression for finding the container elements of the particular satellite XML source that they're using.
Is there any way to get your XML source to provide a <segment>
?
Interesting, why would there be a difference, as the source for Celestrak is space-track.org (and this is where I get my XMLs, I prefer getting them directly )
Hi,
Playing around with your module (thanks for creating this btw !) I'm slowly moving from TLE to OMM
Using your example here https://pypi.org/project/sgp4/#OMM I tried to import an xml file (I use the spacetrack module to download an OMM file to disk for norad id 49044)
it fails on fields = next(omm.parse_xml(f)) with StopIteration
however if I switch over to csv, everything is working...