egemenimre / ccsds-ndm

CCSDS Navigation Data Messages Read/Write Library
GNU General Public License v3.0
35 stars 4 forks source link

Multi-line COMMENT in OEM partly put in wrong section #17

Open mhuang001 opened 2 years ago

mhuang001 commented 2 years ago

Input is from "Figure 5-1" of "CCSDS RECOMMENDED STANDARD FOR ORBIT DATA MESSAGES" (CCSDS 502.0-B-2 the "Blue book", Issue November 2009) https://public.ccsds.org/Pubs/502x0b2c1e2.pdf The part that has problems:

META_STOP
COMMENT This file was produced by M.R. Somebody, MSOO NAV/JPL, 1996NOV 04. It is
COMMENT to be used for DSN scheduling purposes only.
1996-12-18T12:00:00.331 2789.619 -280.045 -1746.755 4.73372 -2.49586 -1.04195
...

to reproduce, line5 and 6 below show the current parse result which is wrong:

fnm = 'oem_fig5_1.kvn'
contents = readfile(fnm)
ndm = NdmIo().from_string(contents)
assert ndm.body.segment[0].metadata.comment == []
assert ndm.body.segment[0].data.comment == [
    'This file was produced by M.R. Somebody, MSOO NAV/JPL, 1996NOV 04. It is']
assert ndm.body.segment[1].metadata.comment == [
    'to be used for DSN scheduling purposes only.']
assert ndm.body.segment[1].data.comment == []
assert ndm.body.segment[2].metadata.comment == []
assert ndm.body.segment[2].data.comment == [
        'This block begins after trajectory correction maneuver TCM-3.']

this should pass but is getting an AssertionError:

assert ndm.body.segment[0].data.comment == [
        'This file was produced by M.R. Somebody, MSOO NAV/JPL, 1996NOV 04. It is',
        'to be used for DSN scheduling purposes only.']
egemenimre commented 2 years ago

This is an unfortunate by-product of the COMMENT structure of the KVN and there is no easy solution. Consider the following example from the standards document:

OBJECT_NAME     = MARS SPIRIT
OBJECT_ID       = 2004-003A
CENTER_NAME     = EARTH
TIME_SYSTEM     = UTC
COMMENT           GEOCENTRIC, CARTESIAN, EARTH FIXED

COMMENT OBJECT_ID: 2004-003
COMMENT  $ITIM  = 2004 JAN 14 22:26:18.400000, $ original launch time 14:36

COMMENT           Generated by JPL
COMMENT           Current attitude for orbit 20 and attitude maneuver
COMMENT           planning data.

COMMENT           Attitude state quaternion
EPOCH           = 2004-02-14T14:28:15.1172
Q_FRAME_A       = INSTRUMENT_A
Q_FRAME_B       = ITRF-97
Q_DIR           = A2B

QC              = 0.47832
Q1              = 0.03123
Q2              = 0.78543
Q3              = 0.39158

Now, there are a lot of comment lines and they clearly belong to different blocks. The KVN format does not (and, by definition, cannot) specify which comment belongs where.

When reading the COMMENT blocks into the code I have to make certain assumptions. If I allow multiple lines of COMMENT, then all these comments in this example should either belong to the Metadata block above, or the Quaternion block below - and I have no means of knowing which is which! I make certain assumptions, but they will definitely be wrong on certain occasions.

Clearly, the behaviour you highlighted is not acceptable - the second comment line spurred an empty data block. I will have to look at it in greater detail in the weekend.