OPM Parser Builder Function Usage

Hi,

Is there any Python example of how to use the Parser Builder function for reading a OPM file and extracting info from it?

I have been trying to write a small code to read an OPM file but have run into some problems. My code is represented below:

import os
import orekit
orekit.initVM()

import personal_mpd_core.constants as C

from org.orekit.data import DataSource, DataContext
from org.orekit.files.ccsds.ndm.odm.opm import OpmParser
from org.orekit.files.ccsds.ndm import ParserBuilder
from org.orekit.files.ccsds.ndm import ParsedUnitsBehavior
from org.orekit.utils import IERSConventions

dir_path = os.getcwd()
file_path = os.path.join(dir_path, "..","data", "JAXA_OPM_test.txt")
data_file_path = os.path.abspath(file_path)

file = DataSource(data_file_path)

parser = ParserBuilder().withMu(398600e9).withDefaultMass(350.0).buildOpmParser()
opmfile = parser.parseMessage(file)
pv = opmfile.getPVCoordinates()

But I am running into the following error:

AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_17910/2870927543.py in <module>
      2 parser = ParserBuilder().withMu(398600e9).withDefaultMass(350.0).buildOpmParser()
      3 opmfile = parser.parseMessage(file)
----> 4 pv = opmfile.getPVCoordinates()

AttributeError: 'Object' object has no attribute 'getPVCoordinates'

The example OPM file that I am using is:

CCSDS_OPM_VERS = 3.0
COMMENT Generated by GSOC, R. Kiehlhing
COMMENT Current intermediate orbit IO2 and maneuver planning data

CREATION_DATE = 2021-06-03T05:33:00.000
ORIGINATOR = GSOC

OBJECT_NAME = EUTELSAT W4
OBJECT_ID = 2021-028A
CENTER_NAME = EARTH
REF_FRAME = TOD
TIME_SYSTEM = UTC

COMMENT State Vector
EPOCH = 2021-06-03T00:00:00.000
X = 6555.9942
Y = -40218.5751
Z = -82.9177
X_DOT = 3.11548208
Y_DOT = 0.47042605
Z_DOT = -0.00100195

COMMENT Keplerian elements
SEMI_MAJOR_AXIS = 41399.5123
ECCENTRICITY = 0.002046211
INCLINATION = 0.117746
RA_OF_ASC_NODE = 17.607474
ARG_OF_PERICENTER = 218.242943
TRUE_ANOMALY = 81.492239
MEAN_MOTION = 39860.4415

COMMENT Spacecraft parameters
MASS = 1913.00
SOLAR_RAD_AREA = 10.000
SOLAR_RAD_COEFF = 1.300
DRAG_AREA = 10.000
DRAG_COEFF = 2.300

COMMENT 2 planned maneuvers

COMMENT First maneuver: AMF-3
COMMENT Non-impulsive, thrust direction fixed in inertial frame
MAN_EPOCH_IGNITION = 2021-06-03T09:00:34.1
MAN_DURATION = 132.60
MAN_DELTA_MASS = -18.418
MAN_REF_FRAME = EME2000
MAN_DV_1 = 0.065700
MAN_DV_2 = 0.068316
MAN_DV_3 = 0.089344

COMMENT Second maneuver: first station acquisition maneuver
COMMENT Impulsive, thrust direction fixed in RTN frame
MAN_EPOCH_IGNITION = 2021-06-05T18:59:21.0
MAN_DURATION = 0.00
MAN_DELTA_MASS = 0.00
MAN_REF_FRAME = RTN
MAN_DV_1 = 0.0017500
MAN_DV_2 = 0.0001300
MAN_DV_3 = 0.0000000

Any help would be appreciated.

Cheers
Suraj

Hi Suraj,

Yes this is one of the quirks with the (JCC based) Python wrapper. You sometimes need to cast_ types that has multiple ancestors to the one you really want to use. The way to find it with these errors is to check what original type that method is from in the source and then cast it to that.

it seems like the getPVCoordinates is part of the Opm class, which would indicate that

pv = Opm.cast_(opmfile).getPVCoordinates()

may work..

Greetz

Note that this quirk is not needed for the newer jpype version of orekit “orekit_jpype”, so if you are just beginning your project, I would recommend that version.

1 Like

Thanks @petrus.hyvonen . I tried it now and it is working!

As for orekit jpype version, does it require any separate installation? Thanks.