1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.propagation;
18
19 import org.hipparchus.linear.MatrixUtils;
20 import org.hipparchus.linear.RealMatrix;
21 import org.junit.jupiter.params.ParameterizedTest;
22 import org.junit.jupiter.params.provider.EnumSource;
23 import org.junit.jupiter.params.provider.ValueSource;
24 import org.orekit.frames.FramesFactory;
25 import org.orekit.frames.LOFType;
26 import org.orekit.orbits.EquinoctialOrbit;
27 import org.orekit.orbits.Orbit;
28 import org.orekit.orbits.OrbitType;
29 import org.orekit.orbits.PositionAngleType;
30 import org.orekit.time.AbsoluteDate;
31 import org.orekit.utils.Constants;
32
33 import static org.junit.jupiter.api.Assertions.*;
34
35 class LinearKeplerianCovarianceMapperTest {
36
37 @ParameterizedTest
38 @EnumSource(OrbitType.class)
39 void testMapIdentity(final OrbitType orbitType) {
40
41 final Orbit equinoctialOrbit = new EquinoctialOrbit(7e6, 0.01, 0.001, 1, 2, 3, PositionAngleType.TRUE, FramesFactory.getGCRF(),
42 AbsoluteDate.ARBITRARY_EPOCH, Constants.EGM96_EARTH_MU);
43 final Orbit orbit = orbitType.convertType(equinoctialOrbit);
44 final RealMatrix covarianceMatrix = MatrixUtils.createRealIdentityMatrix(6);
45 final LOFType lofType = LOFType.QSW;
46 final StateCovariance covariance = new StateCovariance(covarianceMatrix, orbit.getDate(), lofType);
47 final LinearKeplerianCovarianceMapper mapper = new LinearKeplerianCovarianceMapper(orbit, covariance);
48
49 final StateCovariance mappedCovariance = mapper.map(orbit);
50
51 assertEquals(lofType, mappedCovariance.getLOF());
52 for (int i = 0; i < covarianceMatrix.getRowDimension(); i++) {
53 assertArrayEquals(covarianceMatrix.getRow(i), mappedCovariance.getMatrix().getRow(i), 1e-5);
54 }
55 }
56
57 @ParameterizedTest
58 @ValueSource(doubles = {1e2, 1e3, 1e4, 1e5})
59 void testMapEquinoctial() {
60
61 final double dt = 1e2;
62 final PositionAngleType positionAngleType = PositionAngleType.MEAN;
63 final EquinoctialOrbit orbit = new EquinoctialOrbit(7e6, 0.01, 0.001, 1, 2, 3, positionAngleType, FramesFactory.getGCRF(),
64 AbsoluteDate.ARBITRARY_EPOCH, Constants.EGM96_EARTH_MU);
65 final RealMatrix covarianceMatrix = MatrixUtils.createRealIdentityMatrix(6).scalarMultiply(1e-2);
66 covarianceMatrix.setEntry(0, 0, 10);
67 final StateCovariance covariance = new StateCovariance(covarianceMatrix, orbit.getDate(), orbit.getFrame(),
68 orbit.getType(), orbit.getCachedPositionAngleType());
69 final LinearKeplerianCovarianceMapper mapper = new LinearKeplerianCovarianceMapper(orbit, covariance);
70 final Orbit shitedOrbit = orbit.shiftedBy(dt);
71
72 final StateCovariance mappedCovariance = mapper.map(shitedOrbit);
73
74 final RealMatrix stm = MatrixUtils.createRealIdentityMatrix(6);
75 final double contribution = orbit.getMeanAnomalyDotWrtA() * dt;
76 stm.setEntry(5, 0, contribution);
77 final RealMatrix expectedCovarianceMatrix = stm.multiply(covarianceMatrix.multiplyTransposed(stm));
78 assertEquals(shitedOrbit.getDate(), mappedCovariance.getDate());
79 assertEquals(shitedOrbit.getFrame(), mappedCovariance.getFrame());
80 assertEquals(OrbitType.EQUINOCTIAL, mappedCovariance.getOrbitType());
81
82 assertArrayEquals(expectedCovarianceMatrix.getRow(0), mappedCovariance.getMatrix().getRow(0), 1e-2);
83 for (int i = 1; i < covarianceMatrix.getRowDimension(); i++) {
84 assertArrayEquals(expectedCovarianceMatrix.getRow(i), mappedCovariance.getMatrix().getRow(i), 1e-7);
85 }
86 }
87 }