use of org.orekit.estimation.Context in project Orekit by CS-SI.
the class TropoModifierTest method testRangeTropoModifier.
@Test
public void testRangeTropoModifier() throws OrekitException {
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 0.001);
// create perfect range measurements
for (final GroundStation station : context.stations) {
station.getEastOffsetDriver().setSelected(true);
station.getNorthOffsetDriver().setSelected(true);
station.getZenithOffsetDriver().setSelected(true);
}
final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new RangeMeasurementCreator(context), 1.0, 3.0, 300.0);
propagator.setSlaveMode();
final RangeTroposphericDelayModifier modifier = new RangeTroposphericDelayModifier(SaastamoinenModel.getStandardModel());
for (final ObservedMeasurement<?> measurement : measurements) {
final AbsoluteDate date = measurement.getDate();
final SpacecraftState refState = propagator.propagate(date);
Range range = (Range) measurement;
EstimatedMeasurement<Range> evalNoMod = range.estimate(0, 0, new SpacecraftState[] { refState });
// add modifier
range.addModifier(modifier);
EstimatedMeasurement<Range> eval = range.estimate(0, 0, new SpacecraftState[] { refState });
final double diffMeters = eval.getEstimatedValue()[0] - evalNoMod.getEstimatedValue()[0];
final double epsilon = 1e-6;
Assert.assertTrue(Precision.compareTo(diffMeters, 12., epsilon) < 0);
Assert.assertTrue(Precision.compareTo(diffMeters, 0., epsilon) > 0);
}
}
use of org.orekit.estimation.Context in project Orekit by CS-SI.
the class KalmanEstimatorTest method testEquinoctialRightAscensionDeclination.
/**
* Perfect right-ascension/declination measurements with a perfect start
* Equinoctial formalism
* @throws OrekitException
*/
@Test
public void testEquinoctialRightAscensionDeclination() throws OrekitException {
// Create context
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
// Create initial orbit and propagator builder
final OrbitType orbitType = OrbitType.EQUINOCTIAL;
final PositionAngle positionAngle = PositionAngle.TRUE;
final boolean perfectStart = true;
final double minStep = 1.e-6;
final double maxStep = 60.;
final double dP = 1.;
final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(orbitType, positionAngle, perfectStart, minStep, maxStep, dP);
// Create perfect range measurements
final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new AngularRaDecMeasurementCreator(context), 1.0, 4.0, 60.0);
// Reference propagator for estimation performances
final NumericalPropagator referencePropagator = propagatorBuilder.buildPropagator(propagatorBuilder.getSelectedNormalizedParameters());
// Reference position/velocity at last measurement date
final Orbit refOrbit = referencePropagator.propagate(measurements.get(measurements.size() - 1).getDate()).getOrbit();
// Cartesian covariance matrix initialization
final RealMatrix cartesianP = MatrixUtils.createRealDiagonalMatrix(new double[] { 1e-4, 1e-4, 1e-4, 1e-10, 1e-10, 1e-10 });
// Jacobian of the orbital parameters w/r to Cartesian
final Orbit initialOrbit = orbitType.convertType(context.initialOrbit);
final double[][] dYdC = new double[6][6];
initialOrbit.getJacobianWrtCartesian(positionAngle, dYdC);
final RealMatrix Jac = MatrixUtils.createRealMatrix(dYdC);
// Keplerian initial covariance matrix
final RealMatrix initialP = Jac.multiply(cartesianP.multiply(Jac.transpose()));
// Process noise matrix
final RealMatrix cartesianQ = MatrixUtils.createRealDiagonalMatrix(new double[] { 1.e-6, 1.e-6, 1.e-6, 1.e-12, 1.e-12, 1.e-12 });
final RealMatrix Q = Jac.multiply(cartesianQ.multiply(Jac.transpose()));
// Build the Kalman filter
final KalmanEstimatorBuilder kalmanBuilder = new KalmanEstimatorBuilder();
kalmanBuilder.builder(propagatorBuilder);
kalmanBuilder.estimatedMeasurementsParameters(new ParameterDriversList());
kalmanBuilder.initialCovarianceMatrix(initialP);
kalmanBuilder.processNoiseMatrixProvider(new ConstantProcessNoise(Q));
final KalmanEstimator kalman = kalmanBuilder.build();
// Filter the measurements and check the results
final double expectedDeltaPos = 0.;
final double posEps = 1.53e-5;
final double expectedDeltaVel = 0.;
final double velEps = 5.04e-9;
final double[] expectedSigmasPos = { 0.356902, 1.297507, 1.798551 };
final double sigmaPosEps = 1e-6;
final double[] expectedSigmasVel = { 2.468745e-4, 5.810027e-4, 3.887394e-4 };
final double sigmaVelEps = 1e-10;
EstimationTestUtils.checkKalmanFit(context, kalman, measurements, refOrbit, positionAngle, expectedDeltaPos, posEps, expectedDeltaVel, velEps, expectedSigmasPos, sigmaPosEps, expectedSigmasVel, sigmaVelEps);
}
use of org.orekit.estimation.Context in project Orekit by CS-SI.
the class PVTest method testPVWithSingleStandardDeviations.
/**
* Test the PV constructor with standard deviations for position and velocity given as 2 double.
* @throws OrekitException
*/
@Test
public void testPVWithSingleStandardDeviations() throws OrekitException {
// Context
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
// Dummy P, V, T
final Vector3D position = context.initialOrbit.getPVCoordinates().getPosition();
final Vector3D velocity = context.initialOrbit.getPVCoordinates().getVelocity();
final AbsoluteDate date = context.initialOrbit.getDate();
// Initialize standard deviations and weight
final double sigmaP = 10.;
final double sigmaV = 0.1;
final double baseWeight = 0.5;
// Reference covariance matrix and correlation coefficients
final double[][] Pref = new double[6][6];
for (int i = 0; i < 3; i++) {
Pref[i][i] = FastMath.pow(sigmaP, 2);
Pref[i + 3][i + 3] = FastMath.pow(sigmaV, 2);
}
final double[][] corrCoefRef = MatrixUtils.createRealIdentityMatrix(6).getData();
// Reference propagator numbers
final int[] propNumRef = { 0, 2 };
// Create PV measurements
final PV[] pvs = new PV[2];
pvs[0] = new PV(date, position, velocity, sigmaP, sigmaV, baseWeight);
pvs[1] = new PV(date, position, velocity, sigmaP, sigmaV, baseWeight, propNumRef[1]);
// Tolerance
// tolerance
final double eps = 1e-20;
// Check data
for (int k = 0; k < pvs.length; k++) {
final PV pv = pvs[k];
// Propagator numbers
assertEquals(propNumRef[k], pv.getPropagatorsIndices().get(0), eps);
// Weights
for (int i = 0; i < 6; i++) {
assertEquals(baseWeight, pv.getBaseWeight()[i], eps);
}
// Sigmas
for (int i = 0; i < 3; i++) {
assertEquals(sigmaP, pv.getTheoreticalStandardDeviation()[i], eps);
assertEquals(sigmaV, pv.getTheoreticalStandardDeviation()[i + 3], eps);
}
// Covariances
final double[][] P = pv.getCovarianceMatrix();
// Substract with ref and get the norm
final double normP = MatrixUtils.createRealMatrix(P).subtract(MatrixUtils.createRealMatrix(Pref)).getNorm();
assertEquals(0., normP, eps);
// Correlation coef
final double[][] corrCoef = pv.getCorrelationCoefficientsMatrix();
// Substract with ref and get the norm
final double normCorrCoef = MatrixUtils.createRealMatrix(corrCoef).subtract(MatrixUtils.createRealMatrix(corrCoefRef)).getNorm();
assertEquals(0., normCorrCoef, eps);
}
}
use of org.orekit.estimation.Context in project Orekit by CS-SI.
the class PVTest method testPVWithVectorStandardDeviations.
/**
* Test the PV constructor with standard deviations for position and velocity given as a 6-sized vector.
* @throws OrekitException
*/
@Test
public void testPVWithVectorStandardDeviations() throws OrekitException {
// Context
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
// Dummy P, V, T
final Vector3D position = context.initialOrbit.getPVCoordinates().getPosition();
final Vector3D velocity = context.initialOrbit.getPVCoordinates().getVelocity();
final AbsoluteDate date = context.initialOrbit.getDate();
// Initialize standard deviations and weight
final double[] sigmaP = { 10., 20., 30. };
final double[] sigmaV = { 0.1, 0.2, 0.3 };
final double[] sigmaPV = { 10., 20., 30., 0.1, 0.2, 0.3 };
final double baseWeight = 0.5;
// Reference covariance matrix and correlation coefficients
final double[][] Pref = new double[6][6];
for (int i = 0; i < 3; i++) {
Pref[i][i] = FastMath.pow(sigmaP[i], 2);
Pref[i + 3][i + 3] = FastMath.pow(sigmaV[i], 2);
}
final double[][] corrCoefRef = MatrixUtils.createRealIdentityMatrix(6).getData();
// Reference propagator numbers
final int[] propNumRef = { 0, 2, 0, 10 };
// Create PV measurements
final PV[] pvs = new PV[4];
pvs[0] = new PV(date, position, velocity, sigmaP, sigmaV, baseWeight);
pvs[1] = new PV(date, position, velocity, sigmaP, sigmaV, baseWeight, propNumRef[1]);
pvs[2] = new PV(date, position, velocity, sigmaPV, baseWeight);
pvs[3] = new PV(date, position, velocity, sigmaPV, baseWeight, propNumRef[3]);
// Tolerance
// tolerance
final double eps = 1e-20;
// Check data
for (int k = 0; k < pvs.length; k++) {
final PV pv = pvs[k];
// Propagator numbers
assertEquals(propNumRef[k], pv.getPropagatorsIndices().get(0), eps);
// Weights
for (int i = 0; i < 6; i++) {
assertEquals(baseWeight, pv.getBaseWeight()[i], eps);
}
// Sigmas
for (int i = 0; i < 3; i++) {
assertEquals(sigmaP[i], pv.getTheoreticalStandardDeviation()[i], eps);
assertEquals(sigmaV[i], pv.getTheoreticalStandardDeviation()[i + 3], eps);
}
// Covariances
final double[][] P = pv.getCovarianceMatrix();
// Substract with ref and get the norm
final double normP = MatrixUtils.createRealMatrix(P).subtract(MatrixUtils.createRealMatrix(Pref)).getNorm();
assertEquals(0., normP, eps);
// Correlation coef
final double[][] corrCoef = pv.getCorrelationCoefficientsMatrix();
// Substract with ref and get the norm
final double normCorrCoef = MatrixUtils.createRealMatrix(corrCoef).subtract(MatrixUtils.createRealMatrix(corrCoefRef)).getNorm();
assertEquals(0., normCorrCoef, eps);
}
}
use of org.orekit.estimation.Context in project Orekit by CS-SI.
the class PVTest method testPVWithTwoCovarianceMatrices.
/**
* Test the PV constructor with two 3x3 covariance matrix (one for position, the other for velocity) as input.
* @throws OrekitException
*/
@Test
public void testPVWithTwoCovarianceMatrices() throws OrekitException {
// Context
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
// Dummy P, V, T
final Vector3D position = context.initialOrbit.getPVCoordinates().getPosition();
final Vector3D velocity = context.initialOrbit.getPVCoordinates().getVelocity();
final AbsoluteDate date = context.initialOrbit.getDate();
// Initialize standard deviations and weight
final double[][] positionP = { { 100., 400., 1200. }, { 400., 400., 1800. }, { 1200., 1800., 900. } };
final double[][] velocityP = { { 0.01, 0.04, 0.12 }, { 0.04, 0.04, 0.18 }, { 0.12, 0.18, 0.09 } };
final double baseWeight = 0.5;
// Reference covariance matrix and correlation coefficients
final double[][] Pref = new double[6][6];
for (int i = 0; i < 3; i++) {
for (int j = i; j < 3; j++) {
Pref[i][j] = positionP[i][j];
Pref[j][i] = positionP[i][j];
Pref[i + 3][j + 3] = velocityP[i][j];
Pref[j + 3][i + 3] = velocityP[i][j];
}
}
final double[][] corrCoefRef3 = { { 1., 2., 4. }, { 2., 1., 3. }, { 4., 3., 1. } };
final double[][] corrCoefRef = new double[6][6];
for (int i = 0; i < 3; i++) {
for (int j = i; j < 3; j++) {
corrCoefRef[i][j] = corrCoefRef3[i][j];
corrCoefRef[j][i] = corrCoefRef3[i][j];
corrCoefRef[i + 3][j + 3] = corrCoefRef3[i][j];
corrCoefRef[j + 3][i + 3] = corrCoefRef3[i][j];
}
}
// Reference propagator numbers
final int[] propNumRef = { 0, 2 };
// Reference standard deviations
final double[] sigmaP = { 10., 20., 30. };
final double[] sigmaV = { 0.1, 0.2, 0.3 };
// Create PV measurements
final PV[] pvs = new PV[2];
pvs[0] = new PV(date, position, velocity, positionP, velocityP, baseWeight);
pvs[1] = new PV(date, position, velocity, positionP, velocityP, baseWeight, propNumRef[1]);
// Tolerance
// tolerance
final double eps = 6.7e-16;
// Check data
for (int k = 0; k < pvs.length; k++) {
final PV pv = pvs[k];
// Propagator numbers
assertEquals(propNumRef[k], pv.getPropagatorsIndices().get(0), eps);
// Weights
for (int i = 0; i < 6; i++) {
assertEquals(baseWeight, pv.getBaseWeight()[i], eps);
}
// Sigmas
for (int i = 0; i < 3; i++) {
assertEquals(sigmaP[i], pv.getTheoreticalStandardDeviation()[i], eps);
assertEquals(sigmaV[i], pv.getTheoreticalStandardDeviation()[i + 3], eps);
}
// Covariances
final double[][] P = pv.getCovarianceMatrix();
// Substract with ref and get the norm
final double normP = MatrixUtils.createRealMatrix(P).subtract(MatrixUtils.createRealMatrix(Pref)).getNorm();
assertEquals(0., normP, eps);
// Correlation coef
final double[][] corrCoef = pv.getCorrelationCoefficientsMatrix();
// Substract with ref and get the norm
final double normCorrCoef = MatrixUtils.createRealMatrix(corrCoef).subtract(MatrixUtils.createRealMatrix(corrCoefRef)).getNorm();
assertEquals(0., normCorrCoef, eps);
}
}
Aggregations