Parse and encode CCSDS Orbit Ephemeris Messages (OEM).
Supports both the KVN (Keyword=Value Notation) and XML formats per CCSDS 502.0-B. An OEM carries one or more segments, each a metadata block plus a time-ordered list of Cartesian state samples (optionally with acceleration) and optional covariance blocks. The header, metadata and every comment are kept: header and metadata comments in their blocks, and the comments among the state lines and covariance matrices at their positions, which the writers restore.
parse/1 auto-detects the format from the first non-whitespace character: a
leading < is treated as XML, anything else as KVN. Date/time fields are
preserved as raw strings exactly as written; the message round-trips through
the canonical struct without calendar rewriting.
Examples
{:ok, oem} = Sidereon.CCSDS.OEM.parse(kvn_string)
[segment | _] = oem.segments
segment.metadata.object_name
[state | _] = segment.states
state.position_km # {x, y, z} in km
# KVN output (default)
{:ok, kvn} = Sidereon.CCSDS.OEM.encode(oem)
# XML output
{:ok, xml} = Sidereon.CCSDS.OEM.encode(oem, format: :xml)
# Round-trip through XML
{:ok, oem2} = Sidereon.CCSDS.OEM.parse(xml)
Summary
Types
Failure reason from the OEM readers and writers, with every field the core
refusal carries (Sidereon.CCSDS.Error.oem/0): a missing or invalid field, a
malformed value, a keyword repeated with a different value, a unit that
contradicts the standard's table, a document holding several messages, a
keyword the standard does not define at its position, a KVN line that is not
blank, a comment or an assignment, text a writer cannot write so that its
reader returns it unchanged, or (writers only) fields that do not form a
message, such as a covariance without exactly 21 lower-triangle values.
A CCSDS OEM. comments are the header comments. skipped_states lists the
KVN ephemeris data lines the reader skipped; the writers do not write them.
A Cartesian triple {x, y, z}.
Functions
Encode an OEM.
Encode an OEM to KVN text explicitly. Returns {:ok, text} or
{:error, reason}.
Encode an OEM to XML text explicitly. Returns {:ok, text} or
{:error, reason}.
Parse an OEM in either KVN or XML format.
Parse an OEM in KVN format explicitly. Skips format auto-detection.
Parse an OEM in XML format explicitly. Skips format auto-detection.
Types
@type error() :: Sidereon.CCSDS.Error.oem()
Failure reason from the OEM readers and writers, with every field the core
refusal carries (Sidereon.CCSDS.Error.oem/0): a missing or invalid field, a
malformed value, a keyword repeated with a different value, a unit that
contradicts the standard's table, a document holding several messages, a
keyword the standard does not define at its position, a KVN line that is not
blank, a comment or an assignment, text a writer cannot write so that its
reader returns it unchanged, or (writers only) fields that do not form a
message, such as a covariance without exactly 21 lower-triangle values.
@type t() :: %Sidereon.CCSDS.OEM{ ccsds_oem_vers: String.t(), classification: String.t() | nil, comments: [String.t()], creation_date: String.t() | nil, message_id: String.t() | nil, originator: String.t() | nil, segments: [Sidereon.CCSDS.OEM.Segment.t()], skipped_states: [Sidereon.CCSDS.OEM.SkippedState.t()] }
A CCSDS OEM. comments are the header comments. skipped_states lists the
KVN ephemeris data lines the reader skipped; the writers do not write them.
A Cartesian triple {x, y, z}.
Functions
Encode an OEM.
Returns {:ok, text}, or {:error, reason} for a message the writer cannot
write so that its reader returns it unchanged (see error/0).
Options
:format-:kvn(default) or:xml
Encode an OEM to KVN text explicitly. Returns {:ok, text} or
{:error, reason}.
Encode an OEM to XML text explicitly. Returns {:ok, text} or
{:error, reason}.
Parse an OEM in either KVN or XML format.
Format is auto-detected from the first non-whitespace character: < routes to
the XML parser, anything else to the KVN parser.
Returns {:ok, %Sidereon.CCSDS.OEM{}} or {:error, reason}.
Parse an OEM in KVN format explicitly. Skips format auto-detection.
Parse an OEM in XML format explicitly. Skips format auto-detection.