Quicktour

Installation

pip install ccsds-ndm-py

Parsing Messages

Generic Parsing

Use the top-level functions when you want to handle any message type dynamically.

import ccsds_ndm

# Returns an Oem, Opm, etc.
ndm = ccsds_ndm.from_file("example.oem")

Type-Specific Parsing

If you know the file type (e.g., OPM), you can parse it directly into the struct.

from ccsds_ndm import Opm

# Returns an Opm object directly
opm = Opm.from_file("example.opm")

Data Access

Once parsed, you can access the nested data structures.

# Assuming 'ndm' is an Oem object
for segment in ndm.segments:
    meta = segment.metadata
    print(f"Object: {meta.object_name} ({meta.object_id})")

    # State vectors are in segment.data.state_vector
    for sv in segment.data.state_vector:
        print(f"Epoch: {sv.epoch}, X: {sv.x}")

Writing Messages

You can convert the in-memory structures back to KVN or XML.

# Convert to XML string
xml_string = ndm.to_str("xml")

# Write to KVN file
ndm.to_file("output.kvn", "kvn")