Writing Covariances in OEM file


I am trying to add covariances in OEM file. I have been able to generate ephemeris data in OEM file using the below code.

// OEM file
OrekitEphemerisFile ephemerisFile = new OrekitEphemerisFile();
OrekitEphemerisFile.OrekitSatelliteEphemeris satelliteEphemeris = ephemerisFile.addSatellite( Integer.toString(NoradID) );
satelliteEphemeris.addNewSegment(spacecraftStates);		// spacecraftStates is of type List<SpacecraftState>. It contains all the spacecraft states computed during Kalman Filter estimation.
// OEM Meta Data
OemMetadata template = new OemMetadata(2);
template.setCenter(new BodyFacade("EARTH", CelestialBodyFactory.getCelestialBodies().getEarth()));

// Building Writer and writing        
EphemerisWriter EphemerisFileWriter = new EphemerisWriter(new WriterBuilder().buildOemWriter(), 
											null, template, FileFormat.KVN, "dummy", 60 );
EphemerisFileWriter.write(OEMFileName, ephemerisFile);

Could you please point me to a test / tutorial through which I can understand how to add covariance data in OEM file?

(If I understand correctly, the class OEMFile.CovarianceMatrix does not exist in Orekit 11.0. Also, I am unable to figure our how to use writer.writeCovariances from EphemerisWriter class.)

I would prefer to write covariance matrix statically, that is, after estimation/propagation. But am also curious to see how to write it dynamically, that is, during propagation.

(I am a novice with Orekit and Java, so apologies in advance if I am misunderstanding something or asking a silly question.)


Hi @Kapish

The CCSDS infrastructure has been completely overhauled as of Orekit 11.0. The OEMFile class does not exist anymore. The current architecture is described in the maven-generated website. You can find it here.

There is a part of a tutorial that writes OEM files, it is in the Phasing tutorial, between lines 305 and 336. However, this tutorial uses the StreamingOemWriter that generates the file on the fly (it is registered as a step handler to be called directly by the propagator for each new ephemeris line) and it does not writes covariance, so it is insufficient for your needs.

OEM have the classical structure shared by all CCSDS Navigation Data Messages, with a header and segments containing metadata and data. In the case of OEM, there can be several segments, and the data part of each segment can contain both ephemerides lines and covariance data. So the process is to create an instance of OemMetadata (this you already did), create an instance of OemData, call its addData and addCovarianceMatrix to populate it, then create an instance of OemSegment with the metadata and the data before writing everything using the writeSegment method from EphemerisWriter. You can’t use OrekitEphemerisFile directly because it does not handle covariances (it only provides addNewSegment to add the ephemeris part, not the covariances part), you will have to deal with lowest level methods.

The addCovarianceMatrix method from OemData takes as its input an instance of CartesianCovariance, which you build by setting epoch, reference frame and all the matrix entries. You may decide to not set the reference frame here (and this is what I recommend), in which case you will inherit the reference frame from the metadata, which is simpler IMHO (CCSDS allows setting a reference frame in the metadata and override it in the data, but it looks strange).


Hi @luc

Thank you for your comprehensive answer. It works for me :smiley: