Writing SpacecraftStates into an AEM file


I noticed that Orekit 10.2 includes support of AEM files, but I have some difficulties with its usage. I have a list of SpacecraftStates, gathered from a propagator by a step handler. I can write the positions and velocities into an OEM File as follows (roughly) :

        OrekitEphemerisFile ephemerisFile = new OrekitEphemerisFile();
        OrekitEphemerisFile.OrekitSatelliteEphemeris satelliteEphemeris = ephemerisFile.addSatellite(satelliteId);
        OEMWriter ephemerisFileWriter = new OEMWriter(OEMWriter.InterpolationMethod.HERMITE, originator, satelliteId, spaceObjectName);
        ephemerisFileWriter.write(outputFilePath, ephemerisFile); 

However, I can’t find an equivalent way of doing this for the attitude : the AEMWriter constructor needs an AEMFile, but I don’t know how to add the existing spacecraft states to that AEMFile like I did on the OrekitEphemerisFile.

Thanks !

Hi @cmasson

First, welcome to the Orekit forum!

Indeed, translate you code example using AEM file instead of OEM file is not possible since AEMFile class does not implements EphemerisFile interface and AemSatelliteEphemeris does not implement SatelliteEphemeris interface. We do not performed that because EphemerisFile interface has methods that are not compatible with attitude files (getPropagator() and getCoordinates() for instance). However, I think that a solution is possible if we throw exceptions if a user call these methods. Can you open an issue on the Orekit forge?

What you can do is building an AEMFile object and use the addAttitudeBlock() method to fill the data. Another option is to use the StreamingAemWriter class to generate dynamically an AEM file during an orbit propagation.
Here an example showing how to use that class. Please note that this class uses a parsed AEM file to initialize some data but you can use your proper data to initialize that fields.

Kind regards,

Hi @bcazabonne,

Thanks for your quick reply, I opened an issue.

I already wrote some code to convert the attitude quaternions to strings and add the metadata manually, it’s not ideal but it will do the job for now. I’ll keep your suggestions in mind in case I need to implement a cleaner solution at some point.

Best regards,