Orbit Ephemeris Messages (OEM)¶
API reference for the reader and writer of CCSDS Orbit Ephemeris Messages: tables of position and velocity at a sequence of times, as exchanged between operators and agencies (CCSDS 502.0-B-3).
For a worked example, see the Orbit Ephemeris Message tutorial.
An OEM differs from the OMM of the same standard: an OMM is one set of mean elements that needs SGP4 to give a state, while an OEM is the trajectory itself and is only interpolated.
OEM.from_fileandOEM.from_textread the KVN (text) and XML encodings, message versions 1.0 to 3.0.- Positions and velocities are converted from the file's kilometers to meters and m/s; covariances to m², m²/s and m²/s².
- States stay in the frame the file names.
OEMSegment.framegives the matchingsatkit.frame, where there is one, for use withframetransform. interpuses the method and degree the file recommends (Lagrange or Hermite), or the ones passed to it, and never interpolates across segments.OEM.from_propagationsamples the result ofpropagateinto a message, andto_textandto_filewrite any message in the KVN encoding.
import satkit as sk
# An OEM normally comes from a file: sk.OEM.from_file("ISS.OEM_J2K_EPH.txt")
lines = [
"CCSDS_OEM_VERS = 2.0",
"CREATION_DATE = 2024-01-01T00:00:00",
"ORIGINATOR = EXAMPLE",
"META_START",
"OBJECT_NAME = DEMOSAT",
"OBJECT_ID = 2024-001A",
"CENTER_NAME = EARTH",
"REF_FRAME = EME2000",
"TIME_SYSTEM = UTC",
"START_TIME = 2024-01-01T00:00:00",
"STOP_TIME = 2024-01-01T00:03:00",
"INTERPOLATION = HERMITE",
"INTERPOLATION_DEGREE = 7",
"META_STOP",
"2024-01-01T00:00:00 7000.000 0.000 0.0 0.000000 7.546053 0.0",
"2024-01-01T00:01:00 6985.363 452.448 0.0 -0.487742 7.530274 0.0",
"2024-01-01T00:02:00 6941.512 903.003 0.0 -0.973444 7.483003 0.0",
"2024-01-01T00:03:00 6868.631 1349.782 0.0 -1.455075 7.404436 0.0",
]
oem = sk.OEM.from_text("\n".join(lines))
for seg in oem.segments:
print(seg.object_name, seg.ref_frame, seg.start_time, seg.stop_time, len(seg))
seg = oem.segments[0]
print(seg.pos.shape, seg.vel.shape) # (4, 3) arrays, meters and m/s
# Interpolate, with the method and degree the file recommends
times = [seg.start_time + sk.duration(seconds=s) for s in range(0, 180, 30)]
states = oem.interp(times) # (6, 6): x, y, z (m), vx, vy, vz (m/s)
# EME2000 states to Earth-fixed
if seg.frame is not None and seg.center_name == "EARTH":
pos_itrf, vel_itrf = sk.frametransform.transform_state(
seg.frame, sk.frame.ITRF, times[0], states[0, :3], states[0, 3:]
)
Writing one from a propagation:
import numpy as np
import satkit as sk
t0 = sk.time(2024, 1, 1)
r = 7.0e6
state = np.array([r, 0, 0, 0, np.sqrt(sk.consts.mu_earth / r), 0])
result = sk.propagate(state, t0, t0 + sk.duration(hours=2))
# One state every 60 seconds, in the GCRF with UTC epochs
oem = sk.OEM.from_propagation(result, 60, object_name="DEMOSAT", object_id="2024-001A")
text = oem.to_text() # or oem.to_file("demosat.oem")
print(text.splitlines()[0])
# CCSDS_OEM_VERS = 2.0
In Rust the reader and writer are the satkit::oem module, behind the oem Cargo feature (on by default).
OEM
¶
CCSDS Orbit Ephemeris Message (OEM): a tabulated trajectory
An OEM is a table of position and velocity vectors of one object at a sequence of times, with the reference frame, central body and time system they are expressed in (CCSDS 502.0-B). It is the usual format for exchanging ephemerides between operators and agencies: NASA publishes the ISS trajectory as one, and Space-Track accepts operator ephemerides in it.
Load one with OEM.from_file or OEM.from_text; both read the KVN
(text) and XML encodings of message versions 1.0 to 3.0. The message is a
list of segments (OEMSegment), each with its own metadata and
states, and interp interpolates the state at any time a segment covers.
len(oem) is the number of segments.
OEM.from_propagation makes one from the result of satkit.propagate,
and to_text and to_file write a message in the KVN encoding.
The file gives kilometers and km/s; satkit returns meters and m/s, as
everywhere else. States stay in the frame the file names
(OEMSegment.ref_frame): nothing is rotated on reading. Epochs are
read in the segment's TIME_SYSTEM (UTC, TAI, TT, GPS, TDB or UT1) and
are ordinary satkit.time objects.
Example
oem = satkit.OEM.from_text(
"CCSDS_OEM_VERS = 2.0\n"
"CREATION_DATE = 2024-01-01T00:00:00\n"
"ORIGINATOR = EXAMPLE\n"
"META_START\n"
"OBJECT_NAME = DEMOSAT\n"
"OBJECT_ID = 2024-001A\n"
"CENTER_NAME = EARTH\n"
"REF_FRAME = EME2000\n"
"TIME_SYSTEM = UTC\n"
"START_TIME = 2024-01-01T00:00:00\n"
"STOP_TIME = 2024-01-01T00:02:00\n"
"META_STOP\n"
"2024-01-01T00:00:00 7000.000 0.000 0.0 0.000000 7.546053 0.0\n"
"2024-01-01T00:01:00 6985.363 452.448 0.0 -0.487742 7.530274 0.0\n"
"2024-01-01T00:02:00 6941.512 903.003 0.0 -0.973444 7.483003 0.0\n"
)
seg = oem.segments[0]
print(seg.object_name, seg.ref_frame, len(seg))
# DEMOSAT EME2000 3
state = oem.interp(satkit.time(2024, 1, 1, 0, 0, 30))
print(state[:3] / 1e3) # position, km
# [6996.34... 226.34... 0. ]
version
property
¶
CCSDS_OEM_VERS: version of the message format, e.g. "2.0"
comments
property
¶
COMMENT lines of the header
classification
property
¶
CLASSIFICATION of the header (version 3), or None
creation_date
property
¶
CREATION_DATE: when the message was written (UTC)
originator
property
¶
ORIGINATOR: who produced the message
message_id
property
¶
MESSAGE_ID of the header (version 3), or None
segments
property
¶
The segments of the message, in file order; at least one
from_file(filename)
staticmethod
¶
Load an OEM from a file
The encoding (KVN or XML) is detected from the content, not the file
extension, as from_text does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | PathLike[str]
|
Path of the file |
required |
Returns:
| Type | Description |
|---|---|
OEM
|
the message |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
if the file does not exist; the exception names
the path. Another I/O failure raises the matching |
ValueError
|
if the content is not a valid OEM (see |
from_text(text)
staticmethod
¶
Parse an OEM from text
Text starting with CCSDS_OEM_VERS is read as KVN, text starting
with < as XML (a bare <oem> message, or the one inside an
<ndm> wrapper).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The content of an OEM file |
required |
Returns:
| Type | Description |
|---|---|
OEM
|
the message |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the text is neither encoding, a keyword does not
belong where it is, a mandatory keyword is missing, a value
cannot be read, a segment has no states or its epochs are not
strictly increasing, or |
from_propagation(result, step, *, object_name, object_id, originator='SATKIT')
staticmethod
¶
An OEM of the trajectory of a high-precision propagation
The message has one segment, in the GCRF with UTC epochs, holding the
state at the earlier end of the propagation, every step after it,
and the later end (so the last interval is shorter when step does
not divide the span). The two end states are the propagation's own;
the others come from its dense output. The metadata recommends Hermite
interpolation of degree 7, which is what interp then uses. A state
transition matrix in the result is not written.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
propresult
|
The result of |
required |
step
|
duration | timedelta | float
|
Time between states; a number is seconds |
required |
object_name
|
str
|
|
required |
object_id
|
str
|
|
required |
originator
|
str
|
|
'SATKIT'
|
Returns:
| Type | Description |
|---|---|
OEM
|
the message |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |
TypeError
|
if |
Example
t0 = satkit.time(2024, 1, 1)
r = 42164.0e3
v = np.sqrt(satkit.consts.mu_earth / r)
result = satkit.propagate(
np.array([r, 0, 0, 0, v, 0]), t0, t0 + satkit.duration(hours=6)
)
oem = satkit.OEM.from_propagation(
result, 300, object_name="DEMOSAT", object_id="2024-001A"
)
print(len(oem.segments[0]))
# 73
print(oem.to_text().splitlines()[0])
# CCSDS_OEM_VERS = 2.0
to_text()
¶
The message as text in the KVN ("keyword = value") encoding
Positions and velocities are written in the kilometers and km/s of the format, to the micrometer and the nanometer per second, and epochs to the microsecond in each segment's time system. Comments and covariances are kept. A message read from XML is written as KVN too.
Returns:
| Type | Description |
|---|---|
str
|
the content of an OEM file, which |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the message holds a value that is not finite |
to_file(filename)
¶
Write the message to a file in the KVN encoding
The content is that of to_text. An existing file is replaced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | PathLike[str]
|
Path of the file to write |
required |
Raises:
| Type | Description |
|---|---|
OSError
|
if the file cannot be written; the exception names the path |
ValueError
|
if the message holds a value that is not finite |
__len__()
¶
Number of segments
interp(time, *, method=None, degree=None)
¶
Interpolate the state at a single time
Each time is interpolated in the first segment whose usable span holds it, and the state is in that segment's frame. Segments are never interpolated across, so a time in a gap between two of them is out of range.
With no method or degree the interpolation is the one the file
recommends (OEMSegment.interpolation and
interpolation_degree). A file that names no method gets Hermite,
which uses the velocities and so holds its accuracy on sparse
ephemerides, and a missing degree is 7. A segment with fewer points
than the degree asks for uses all of them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
TimeScalar
|
Time at which to interpolate |
required |
method
|
Literal['lagrange', 'hermite'] | None
|
|
None
|
degree
|
int | None
|
Degree of the polynomial, at least 1. Default: the file's, or 7 |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
6-element state [x, y, z, vx, vy, vz] in meters and m/s |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a time is outside every segment's usable span, the file
names an interpolation method satkit does not have and |
TypeError
|
if time is not a time or a list, tuple or 1-D array of times |
OEMSegment
¶
One segment of an OEM: a metadata block and the states under it
Obtained from OEM.segments. A producer starts a new segment where the
states must not be interpolated across: a maneuver, or a change of frame
or central body.
Positions are in meters, velocities in m/s and accelerations in m/s², in
the frame ref_frame centered on center_name. len(segment) is
the number of states.
object_name
property
¶
OBJECT_NAME
object_id
property
¶
OBJECT_ID, normally the international designator ("1998-067A")
center_name
property
¶
CENTER_NAME: the origin of the frame, e.g. "EARTH"
ref_frame
property
¶
REF_FRAME as written, e.g. "EME2000", "ITRF2000", "TEME"
frame
property
¶
The satkit.frame that ref_frame names, or None
EME2000, GCRF, ICRF and TEME map to the frame of the
same name and every ITRF realization (ITRF2000, ITRF-93, ...)
to satkit.frame.ITRF, satkit making no distinction between them.
Other frames (TOD, MCI, ...) give None. The name alone does
not make the states Earth-centered: check center_name too.
ref_frame_epoch
property
¶
REF_FRAME_EPOCH: epoch of the frame, or None
time_system
property
¶
TIME_SYSTEM as written, e.g. "UTC"
time_scale
property
¶
The satkit.timescale that time_system names
Every epoch of the segment was read in it.
start_time
property
¶
START_TIME: epoch of the first state
stop_time
property
¶
STOP_TIME: epoch of the last state
useable_start_time
property
¶
USEABLE_START_TIME, or None
Start of the span the producer says is fit for interpolation.
useable_stop_time
property
¶
USEABLE_STOP_TIME: end of that span, or None
usable_span
property
¶
The span interp accepts, as (start, stop)
The USEABLE_START_TIME to USEABLE_STOP_TIME span where the
file gives one, and never past the first and last state.
interpolation
property
¶
INTERPOLATION as written, or None
The method the producer recommends: "LAGRANGE", "HERMITE", ...
interpolation_degree
property
¶
INTERPOLATION_DEGREE, or None
metadata_comments
property
¶
COMMENT lines of the metadata block
comments
property
¶
COMMENT lines at the start of the ephemeris data
time
property
¶
Epochs of the states, in increasing order
pos
property
¶
Positions, an (N, 3) array in meters
vel
property
¶
Velocities, an (N, 3) array in m/s
acc
property
¶
Accelerations, an (N, 3) array in m/s², or None
None unless every state of the segment gives one.
covariances
property
¶
Covariance matrices of the segment (empty if it has none)
Each is a dictionary with the keys time, ref_frame, cov
(a symmetric (6, 6) array in m², m²/s and m²/s²) and comments;
see OEMCovariance.
__len__()
¶
Number of states
interp(time, *, method=None, degree=None)
¶
Interpolate the state at a single time within the segment
As OEM.interp, restricted to this segment: a time outside
usable_span is a ValueError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
TimeScalar
|
Time at which to interpolate |
required |
method
|
Literal['lagrange', 'hermite'] | None
|
|
None
|
degree
|
int | None
|
Degree of the polynomial, at least 1. Default: the file's, or 7 |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
6-element state [x, y, z, vx, vy, vz] in meters and m/s |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a time is outside |
TypeError
|
if time is not a time or a list, tuple or 1-D array of times |
OEMCovariance
¶
A covariance matrix of an OEM segment, an item of OEMSegment.covariances
An ordinary dict (this class exists for type checking only).
time
instance-attribute
¶
Epoch of the covariance
ref_frame
instance-attribute
¶
COV_REF_FRAME: the frame of the matrix (for example "RTN"), or
None for the segment's ref_frame
cov
instance-attribute
¶
Symmetric (6, 6) covariance of [x, y, z, vx, vy, vz]: m² in the position block, m²/s in the cross blocks and m²/s² in the velocity block
comments
instance-attribute
¶
COMMENT lines of the covariance