setInterpolationDegree in OEM Template

Hello!

I am currently generating OEM files using the latest CCSDS framework found in v11.1 with the Python-wrapped version of Orekit. However, I am having an issue getting the Interpolation Degree set correctly. According to the API docs for v11.0, the .setInterpolationDegree() method should be set to an integer value of which I am setting to 5. However, upon OEM generation, the INTERPOLATION_DEGREE field defaults to 1–I am also setting the default interpolation degree in the template by issuing the integer of 5 to the OemMetadata class.

Has anyone ran into this issue? If so, what did you do to solve it?

    # Setup the OEM template
    header = Header(3.0)
    header.setCreationDate(datetime_to_absolutedate(dt.datetime.now()))
    template = OemMetadata(5) # This should set the default interpolation order to 5, however it does not. 
    template.addComment('This file was generated by {}'.format(gp.getuser()))
    template.setTimeSystem(TimeSystem.UTC)
    template.setObjectID(str(object_id))
    template.setObjectName(object_name)
    template.setCenter(BodyFacade('EARTH', CelestialBodyFactory.getCelestialBodies().getEarth()))
    template.setReferenceFrame(FrameFacade.map(FramesFactory.getEME2000()))
    template.setInterpolationDegree(5) # see comment on L132
    template.setInterpolationMethod(InterpolationMethod.LAGRANGE)

Hi @Kozak

Welcome to the Orekit forum!

Could you try to update your Orekit version to the latest version which is 11.2?
There is no API change between 11.1 and 11.2 versions. Therefore, your code will not need to be updated.

If it doesn’t solve your problem. Could you please provide a working example enabling to reproduce your issue?
For OEM generation, you can also look at the Phasing tutorial which generates an OEM file at the end of the computations.
It’s in Java, but the translation to Python for the OEM generation part is easy and close to what you should already have.

Thank you and best regards,
Bryan

Hey Bryan,

I updated to 11.2 and it still isn’t update the field correctly. I’ve attached the section of my code that generates the state vectors and the OEM below.

    # Loop through the SVs and create a Cartesian orbit that is appended to a Java ArrayList   
    for time, x, y, z, x_vel, y_vel, z_vel in propagated_ephemeris.state_vectors[:, :]:
        position = Vector3D(x, y, z)
        velocity = Vector3D(x_vel, y_vel, z_vel)
        date = datetime_to_absolutedate(time)
        orbit = CartesianOrbit(TimeStampedPVCoordinates(date, position, velocity), FramesFactory.getEME2000(), Constants.WGS84_EARTH_MU)
        spacecraft_state = SpacecraftState(orbit)
        java_state_list.add(spacecraft_state)

    # Store ephemerides in an EphemerisFile for recall later on
    ephemeris_file = OrekitEphemerisFile()
    norad_java_int = Integer(object_id)
    satellite = ephemeris_file.addSatellite(norad_java_int.toString())
    satellite.addNewSegment(java_state_list)

    # Setup the OEM template
    header = Header(3.0)
    header.setCreationDate(datetime_to_absolutedate(dt.datetime.now()))
    template = OemMetadata(5) # This should set the default interpolation order to 5, however it does not. 
    template.addComment('This file was generated by {}'.format(gp.getuser()))
    template.setTimeSystem(TimeSystem.UTC)
    template.setObjectID(str(object_id))
    template.setObjectName(object_name)
    template.setCenter(BodyFacade('EARTH', CelestialBodyFactory.getCelestialBodies().getEarth()))
    template.setReferenceFrame(FrameFacade.map(FramesFactory.getEME2000()))
    template.setInterpolationDegree(5) # see comment on L132
    template.setInterpolationMethod(InterpolationMethod.LAGRANGE)


    # Begin writing the ephemeris to a Java string
    oem_string = StringWriter()
    writer = EphemerisWriter(WriterBuilder().buildOemWriter(), header, template, FileFormat.KVN, 'dummy', 60)
    writer.write(oem_string, ephemeris_file)

Inadvertently stumbled upon a fix. I used the addNewSegment method that accepts an integer for interpolation. Curiously, the integer has to reflect 6 to obtain an INTERPOLATION_DEGREE of 5, but it works.

the off by one is the difference between polynomial degree and the number of points. E.g. linear (degree 1) interpolation requires 2 points. Orekit tends to use number of points because it is a bit more clear when including velocity or acceleration, but OEM uses degree.

Hey Evan,

Thanks for the explanation. I’m familiar with degrees of interpolation, but points is a new way of thinking of things for me. I’ll make note of this for future use.