OrbitEphemerisMessage

See also

Module Ephemeris Components

Module OEM Data Types

class oem.OrbitEphemerisMessage(header, segments)

Bases: object

Python representation of an Orbit Ephemeris Message.

This class provides the primary interface between the OEM module and an OEM file.

header

Object containing the OEM header section.

Type:HeaderSection

Examples

The OrbitEphemerisMessage class can load directly from a file:

>>> ephemeris = OrbitEphemerisMessage.open(file_path)

An OEM is made up of one or more data segments available through an iterator:

>>> for segment in ephemeris:
...     for state in segment:
...         # Iterate through states
...         pass
...     for covariance in segment.covariances:
...         # Iterate through covariances
...         pass

It is also possible to iterate through the states and covariances in all segments with the .states and .covariances properties.

To determine if a particular epoch is contained in the useable time range of any of the segments in an ephemeris, use in:

>>> epoch in ephemeris
True

To sample a state at an arbitrary epoch, simply call the ephemeris with an astropy Time object

>>> epoch = Time("2020-01-01T00:00:00", scale="utc")
>>> ephemeris(epoch)
State(2020-01-01T00:00:00.000)

Note that this type of sampling is only supported if the time system of the target ephemeris is supported by astropy Time objects.

The save_as method enables saving of copies of an OEM in both KVN and XML formats.

>>> oem.save_as("new.oem", file_format="xml")

To convert directly between KVN and XML formats, use the convert class method. For example, to convert a KVN OEM to XML:

>>> oem.convert("input.oem", "output.oem", "xml")
classmethod convert(in_file_path, out_file_path, file_format)

Convert an OEM to a particular file format.

This method will succeed and produce an output file even if the input file is already in the desired format. Comments are not preserved.

Parameters:
  • in_file_path (str or Path) – Path to original ephemeris.
  • out_file_path (str or Path) – Desired path for converted ephemeris.
  • file_format (str) – Desired output format. Options are ‘kvn’ and ‘xml’.
copy()

Create an independent copy of this instance.

covariances

Return a list of covariances in all segments.

classmethod open(file_path)

Open an Orbit Ephemeris Message file.

This method supports both KVN and XML formats.

Parameters:file_path (str or Path) – Path of file to read.
Returns:New OEM instance.
Return type:OrbitEphemerisMessage
resample(step_size, in_place=False)

Resample ephemeris data.

Replaces the existing ephemeris state data in this OEM with new states sampled at the desired sampling interval. The new sampling applies to all segments contained in this OEM.

Parameters:
  • step_size (float) – Sample step size in seconds.
  • in_place (bool, optional) – Toggle in-place resampling. Default is False.
Returns:

Resampled OEM. Output is an indepedent

instance if in_place is True.

Return type:

OrbitEphemerisMessage

Examples

Open an ephemeris file, convert it to a 60-second sampling interval and save the result to a new file:

>>> oem = OrbitEphemerisMessage.open("input.oem")
>>> oem.resample(60, in_place=True)
>>> oem.save_as("output.oem")

To do the same thing without in-place operations:

>>> oem = OrbitEphemerisMessage.open("input.oem")
>>> new_oem = oem.resample(60)
>>> new_oem.save_as("output.oem")
save_as(file_path, file_format='kvn')

Write OEM to file.

Parameters:
  • file_path (str or Path) – Desired path for output ephemeris.
  • file_format (str, optional) – Type of file to output. Options are ‘kvn’ and ‘xml’. Default is ‘kvn’.
states

Return a list of states in all segments.

steps(step_size)

Sample Ephemeris at equal time intervals.

This method returns a generator producing states at equal time intervals spanning the useable duration of all segments in the parent OEM.

Parameters:step_size (float) – Sample step size in seconds.
Yields:State – Sample state.

Examples

Sample states at 60-second intervals:

>>> for state in oem.steps(60):
...     pass

Note that spacing between steps will only be constant within segments; when crossing from one segment to another the spacing will vary. To avoid this behavior with multi-segment OEMs, use the segment interface directly:

>>> for segment in oem:
...    for state in segment.steps(60):
...        pass