astra.cdm module

ASTRA Core Conjunction Data Message (CDM) Parser.

Implements structural parsing for standard CCSDS CDMs provided by Space-Track and the US Space Force. XML is parsed with defusedxml to mitigate XXE and billion-laughs risks on untrusted input.

class astra.cdm.CDMObject(object_designator, object_name, position_xyz, velocity_xyz, covariance_matrix)[source]

Bases: object

Represents a single object inside a CDM (Object1 or Object2).

object_designator

Unique identifier (e.g. NORAD ID).

Type:

str

object_name

Common name of the object.

Type:

str

position_xyz

Cartesian position vector in km (J2000/GCRF).

Type:

tuple[float, float, float]

velocity_xyz

Cartesian velocity vector in km/s (J2000/GCRF).

Type:

tuple[float, float, float]

covariance_matrix

21-element upper triangular RTN covariance in and m²/s.

Type:

list[float]

object_designator
object_name
position_xyz
velocity_xyz
covariance_matrix
class astra.cdm.ConjunctionDataMessage(message_id, creation_date, tca_time, miss_distance_m, relative_velocity_m_s, collision_probability, object_1, object_2)[source]

Bases: object

Represents the complete payload of a CCSDS XML CDM.

message_id

Unique message identifier.

Type:

str

creation_date

UTC timestamp of message generation.

Type:

datetime.datetime

tca_time

UTC timestamp of Time of Closest Approach.

Type:

datetime.datetime

miss_distance_m

Scalar distance at TCA in meters.

Type:

float

relative_velocity_m_s

Scalar relative speed at TCA in m/s.

Type:

float

collision_probability

Probability of collision (Pc) in range [0, 1].

Type:

float | None

object_1

The primary object in the conjunction.

Type:

astra.cdm.CDMObject

object_2

The secondary object in the conjunction.

Type:

astra.cdm.CDMObject

message_id
creation_date
tca_time
miss_distance_m
relative_velocity_m_s
collision_probability
object_1
object_2
astra.cdm.parse_cdm_xml(xml_string)[source]

Parses a standard CCSDS XML Conjunction Data Message.

Parameters:

xml_string – Raw XML response from Space-Track or local CDM file.

Returns:

ConjunctionDataMessage object containing structured geometry and covariance.

Raises:

AstraError – If the XML format is invalid or missing critical CDM tags.

astra.cdm.export_cdm_xml(cdm, originator='ASTRA-CORE')[source]

Serialise a ConjunctionDataMessage to a CCSDS XML CDM string.

Produces a standards-compliant XML document that can be shared with mission-control systems or Space-Track partners. This completes the read-write symmetry: parse_cdm_xml(export_cdm_xml(cdm)) == cdm.

Parameters:
  • cdm – The ConjunctionDataMessage to serialise.

  • originator – Originator identifier written into the XML header.

Returns:

A UTF-8 XML string conforming to CCSDS 508.0-B-1 CDM schema.

Example:

xml_str = export_cdm_xml(event_cdm, originator="ISRO-ISTRAC")
with open("conjunction.xml", "w") as f:
    f.write(xml_str)
astra.cdm.parse_cdm_kvn(kvn_string)[source]

Parse a CCSDS KVN (Key-Value Notation) Conjunction Data Message.

Supports the KVN subset of CDMs as specified in CCSDS 508.0-B-1. Each line has the form KEY = VALUE. Object blocks are delimited by OBJECT = OBJECT1 / OBJECT = OBJECT2 keywords.

Parameters:

kvn_string – Raw KVN CDM text.

Returns:

ConjunctionDataMessage with parsed geometry and covariance.

Raises:

AstraError – If mandatory fields are missing or values are invalid.

Example:

with open("conjunction.kvn") as f:
    cdm = parse_cdm_kvn(f.read())
print(cdm.tca_time, cdm.miss_distance_m)
astra.cdm.export_cdm_kvn(cdm, originator='ASTRA-CORE')[source]

Serialise a ConjunctionDataMessage to a CCSDS KVN CDM string.

Produces a standards-compliant KVN document (CCSDS 508.0-B-1) that is interoperable with legacy mission-control systems (ODAS, older STK pipelines) that do not support XML CDMs. Completes the read-write API symmetry: parse_cdm_kvn(export_cdm_kvn(cdm)) round-trips losslessly. :param cdm: The ConjunctionDataMessage to serialise. :param originator: Originator identifier written into the KVN header.

Returns:

A KVN string conforming to CCSDS 508.0-B-1 CDM schema.

Example:

kvn_str = export_cdm_kvn(event_cdm, originator="ISRO-ISTRAC")
with open("conjunction.kvn", "w") as f:
    f.write(kvn_str)