Intepolator Order Bug in OEM writer?

Hello all,
First time posting. I made short script in matlab to acquaint myself with orbit propagation, and CCDS OEM generation in orekit. The OEM file I generated does not appear to honor the interpolator order I specified (7) and always outputs 1.

Here is the excerpt from the matlab script (should be recognizable in java or pyhon):

% Initialize the OEM metadata
import org.orekit.files.ccsds.ndm.odm.oem.OemMetadata
import org.orekit.files.ccsds.ndm.odm.oem.InterpolationMethod
import org.orekit.files.ccsds.definitions.BodyFacade
import org.orekit.files.ccsds.definitions.FrameFacade
import org.orekit.files.ccsds.definitions.TimeSystem
import org.orekit.bodies.CelestialBodyFactory

oemInterpolationDegree=7;

oemMeta = OemMetadata(int32(oemInterpolationDegree));
oemMeta.setInterpolationMethod(InterpolationMethod.LAGRANGE);
oemMeta.setTimeSystem(TimeSystem.UTC);
oemMeta.setObjectID(svObjectID);
oemMeta.setObjectName(svObjectName);
oemMeta.setCenter(BodyFacade(“EARTH”,CelestialBodyFactory.getCelestialBodies().getEarth()));

oemMeta.setReferenceFrame(FrameFacade.map(gcrf));

% Create the header
import org.orekit.files.ccsds.ndm.odm.OdmHeader
oemHdr = OdmHeader();
oemHdr.setOriginator(“ME”);

% Compose the OEM writer and write the file
import org.orekit.files.ccsds.utils.FileFormat
import org.orekit.files.ccsds.ndm.WriterBuilder
import org.orekit.files.ccsds.ndm.odm.oem.EphemerisOemWriter
import org.orekit.utils.Constants

oemWriter = EphemerisOemWriter(WriterBuilder().buildOemWriter(),oemHdr,oemMeta,FileFormat.KVN,“dummy”,Constants.JULIAN_DAY,60);

oemWriter.write(fullfile(pwd,“test_output.oem”),ephemFile);


I verified that oemMeta.getInterpolationOrder() returns 7. Here is the output:

CCSDS_OEM_VERS = 3.0
CREATION_DATE = 2024-05-21T23:45:48.0
ORIGINATOR = ME

META_START
OBJECT_NAME = MY_SAT
OBJECT_ID = 50000
CENTER_NAME = EARTH
REF_FRAME = GCRF
TIME_SYSTEM = UTC
START_TIME = 2024-11-03T00:00:00.0
STOP_TIME = 2024-11-04T00:00:00.0
INTERPOLATION = LAGRANGE
INTERPOLATION_DEGREE = 1
META_STOP

2024-11-03T00:00:00.0 -5281.589477548891 -3045.325055093267 4147.135180861081 -2.836183830536738 -3.1897665863260487 5.98858946858763
…

Am I doing something wrong here, or is there a problem in the writer?

Thanks,
Mike

Hi @gmar and welcome to the Orekit forum !

I apologize for the delay, some threads sometimes pass by and are not treated as fast as the others…

This message to let you know that i’m starting to investigate your issue.

Cheers,
Vincent

Good afternoon @gmar,

After looking at the code it seems to come from the following lines :

metadata.setInterpolationDegree(segment.getInterpolationSamples() - 1);

The problem is that we don’t know how you build your ephemeris file. So, supposing that you built it as an OemSegment, it calls this implementation of “getInterpolationSamples” :

    /** {@inheritDoc} */
    @Override
    public int getInterpolationSamples() {
        // From the standard it is not entirely clear how to interpret the degree.
        return getMetadata().getInterpolationDegree() + 1;
    }

So if you did not set the interpolation degree of your segment’s metadata to 7, then it will be different. The metadata that you are building in your script is only a template.

Hope this helps you.

If you can send us the script of how you are building your ephemeris file, we could provide you further assistance.

Cheers,
Vincent

2 Likes

Hello Vincent,

Thank you for your response and investigation. I was using OrekitSatelliteEphemeris.addNewSegment, but did not realize the I should specify the interpolation order at that time. With the modification:

import org.orekit.files.general.OrekitEphemerisFile
ephemFile = OrekitEphemerisFile();
satEphemeris = ephemFile.addSatellite(ObjectID);
satEphemeris.addNewSegment(svEphem,int32(interpolationDegree+1));

The OEM writer generated the desired order this time. My interpolationDegree=7 so I had to add +1 to get the output in the OEM file to also be 7.

Thank you for your help.

Mike

2 Likes