Hi @Sacha
Welcome to the Orekit forum!
Yes it is. For the Kalman Filter, you can easily access the covariance matrix, at each measurement epoch by setting a KalmanObserver
to your KalmanEstimator
using
kalmanEstimator.setObserver(new MyKalmanObserver());
Here an example for the implementation of MyKalmanObserver()
class
public class MyKalmanObserver implements KalmanObserver {
@Override
public void evaluationPerformed(final KalmanEstimation estimation) {
// Access the physical covariance matrix
final RealMatrix covariance = estimation.getPhysicalEstimatedCovarianceMatrix();
// Do what you want with the covariance
}
}
Please note that the evaluationPerformed(final KalmanEstimation estimation)
method is called each time a measurement is processed by the Kalman filter.
For the batch least squares covariance matrix, the method is a bit different. Indeed, the algorithm optimize the least squares problem using the whole package of measurements. Therefore, you can only access the covariance at the orbit determination epoch. However, it is possible to propagate this estimated covariance, at the end of the orbit determination process, using Orekit. Indeed the covariance at a given epoch can be expressed as a function of the covariance at the orbit determination epoch: P(t) = STM(t,t0) * P(t0) * transpose(STM(t,t0)). Where STM is the state transition matrix.
I will give you an example considering that only orbital parameters are estimated.
Let estimator
by your BatchLSEstimator
object, first you need to access the estimated orbit propagator and the estimated covariance using
final NumericalPropagator estimatedPropagator = estimator.estimate()[0];
final RealMatrix estimatedCovariance = estimator.getPhysicalCovariances(1.0e-15)
Then configure your estimated orbit propagator to propagate the covariance
// Additional equations name
final String equationName = "partial-derivatives";
// Initialize spacecraft state partial derivatives object
final PartialDerivativesEquations partials = new PartialDerivativesEquations(equationName, estimatedPropagator);
// Get initial state
final SpacecraftState state = estimatedPropagator.getInitialState();
// Add derivatives to initial state
final SpacecraftState stateWithDerivatives = partials.setInitialJacobians(state);
estimatedPropagator.resetInitialState(stateWithDerivatives);
// Initialise the Jacobians mapper
final JacobianMapper jacobiansMapper = partials.getMapper();
Finally, you need to create and add a step handler to your orbit propagator to perform the covariance matrix propagation.
// Set master mode and step handler
estimatedPropagator.setMasterMode(stepSize, new MyStepHandler(jacobiansMapper, estimatedCovariance));
Where stepSize
is the step at which you want the computation of the propagated covariance matrix. Here an example of MyStepHandler
class:
public class MyStepHandler implements OrekitFixedStepHandler {
private JacobianMapper mapper;
private RealMatrix estimatedCovariance;
MyStepHandler(final JacobianMapper mapper, final RealMatrix estimatedCovariance) {
this.mapper = mapper;
this.estimatedCovariance = estimatedCovariance;
}
@Override
public void handleStep(SpacecraftState currentState, boolean isLast) {
// Current state transition matrix
final double[][] aYY0 = new double[6][6];
mapper.getStateJacobian(currentState, aYY0);
final RealMatrix dYdY0 = new Array2DRowRealMatrix(aYY0, false);
// Current covariance
final RealMatrix currentCovariance = dYdY0.multiply(estimatedCovariance.multiplyTransposed(dYdY0))
// Do what you want with the covariance
}
}
Please note that I have just written this code snippet in the forum editor. Therefore, it may contain errors. Furthermore, I think that the given method can be applied to the Kalman estimator by replacing the estimator.getPhysicalCovariances(1.0e-15)
instruction by kalmanestimator.getPhysicalEstimatedCovarianceMatrix()
I think that is because you have more measurements. Therefore, the estimation algorithms are able to provide better estimation of the parameters and therefore standard deviations are better for the 10 days fit span.
Good question. Algorithms are very differents. I’m not able to answer this question.
Best regards,
Bryan