Problem when Parsing OEM

Hi!

I recently updated Orekit from 10.3 to 11.3. So I changed the way I was parsing OEMs.
In order to get the segments (or blocks) from the OEM, before I did .getEphemeridesBlock() from a OEMfile.

Now, I’m doing the following:

oem_parser = ParserBuilder().buildOemParser()
oem_f = DataSource(file)
oem = oem_parser.parse(oem_f)
segments=oem.getSegments()
print(segments)

It seems that I actually get the segments on an ArrayList()

[org.orekit.files.ccsds.ndm.odm.oem.OemSegment@65bb9029, org.orekit.files.ccsds.ndm.odm.oem.OemSegment@1bfe3203, ... ]

but then when I try to access the methods of the OemSegment this is what I get for example for the .getMetadata().

print(segments.get(0).getMetadata())
AttributeError: 'Object' object has no attribute 'getMetadata'

Same for every other method.

In order to really have access to the segments of the OEM, I have to do the following:

sats=oem.getSatellites()
segments = sats.get('XXX').getSegments()

And with this I have access to the OemSegment methods.

However, doesn’t make sense that I need to know the ID of the satellite to get the segments in a OEM, so I had to hardcode it, because I was not being able to get the keys on ‘sats’.
I never have more than 1 satellite ephemerides in a OEM, don’t know actually if that can happen.
I’m attaching here the OEM file I’m parsing

file.oem (1.1 MB)

So my questions are:

  • Am I doing something wrong on the first approach where I don’t get the satellites?
  • Is there a way to get the keys on ‘sats’?
  • Shouldn’t we be able to get the segments directly, without doing the getSatellites() first?

Hey there,

Try casting your segment first:
segment = OemSegment.cast_(oem.getSegments().get(0))

Best,
Romain.

Hi @Serrof !
That worked, thank you!

Out of curiosity, when should we use the .cast_()?
What are we actually doing, when we use it?

Best regards,
João Pedro Silva

That’s a drawback from the Python wrapper.
From what I understand, you need to cast each time you want to use a method that is inherited from a parent class. You’ll get a similar error as the one you had here if you don’t.

Best,
Romain

Hi,
Yes it is a drawback, and it comes when a class has several parents and then the wrapper will only use one of the parents as the standard set of methods. It is part of the wrapping layer and not easily changed.

This appears more in some parts of the library than others, the file handling is particularly intensive.

The practical solution if this error occurs is to find that method in the documentation and see which class that one would like to access it from.

Best Regards
/Petrus