1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.propagation;
18
19 import java.util.Locale;
20 import java.util.Map;
21
22 import org.hipparchus.analysis.polynomials.SmoothStepFactory;
23 import org.hipparchus.stat.descriptive.DescriptiveStatistics;
24 import org.hipparchus.util.FastMath;
25 import org.junit.jupiter.api.Assertions;
26 import org.junit.jupiter.api.BeforeAll;
27 import org.junit.jupiter.api.DisplayName;
28 import org.junit.jupiter.api.Test;
29 import org.orekit.Utils;
30 import org.orekit.data.DataContext;
31 import org.orekit.forces.gravity.potential.AstronomicalAmplitudeReader;
32 import org.orekit.forces.gravity.potential.EGMFormatReader;
33 import org.orekit.forces.gravity.potential.FESCHatEpsilonReader;
34 import org.orekit.forces.gravity.potential.GravityFieldFactory;
35 import org.orekit.forces.gravity.potential.OceanLoadDeformationCoefficients;
36 import org.orekit.frames.Frame;
37 import org.orekit.frames.LOFType;
38 import org.orekit.orbits.Orbit;
39 import org.orekit.orbits.OrbitBlender;
40 import org.orekit.orbits.OrbitType;
41 import org.orekit.orbits.PositionAngleType;
42 import org.orekit.propagation.analytical.AbstractAnalyticalPropagator;
43 import org.orekit.propagation.analytical.BrouwerLyddanePropagator;
44 import org.orekit.propagation.analytical.EcksteinHechlerPropagator;
45 import org.orekit.propagation.analytical.KeplerianPropagator;
46 import org.orekit.time.TimeInterpolator;
47 import org.orekit.time.TimeStampedPair;
48 import org.orekit.utils.Constants;
49
50 class StateCovarianceBlenderTest {
51
52 private static SpacecraftState sergeiState;
53 private static Orbit sergeiOrbit;
54 private static Frame sergeiFrame;
55
56
57 private final double DEFAULT_SERGEI_PROPAGATION_TIME = 2400;
58 private final double DEFAUTL_SERGEI_TABULATED_TIMESTEP = 2400;
59
60 @BeforeAll
61 public static void setUp() {
62 Utils.setDataRoot("regular-data:potential/egm-format:atmosphere:tides:regular-data/de405-ephemerides");
63 GravityFieldFactory.addPotentialCoefficientsReader(new EGMFormatReader("EGM96-truncated-21x21", true));
64 AstronomicalAmplitudeReader aaReader =
65 new AstronomicalAmplitudeReader("hf-fes2004.dat", 5, 2, 3, 1.0);
66 DataContext.getDefault().getDataProvidersManager().feed(aaReader.getSupportedNames(), aaReader);
67 Map<Integer, Double> map = aaReader.getAstronomicalAmplitudesMap();
68 GravityFieldFactory.addOceanTidesReader(new FESCHatEpsilonReader("fes2004-7x7.dat",
69 0.01, FastMath.toRadians(1.0),
70 OceanLoadDeformationCoefficients.IERS_2010,
71 map));
72
73 sergeiState = StateCovarianceKeplerianHermiteInterpolatorTest.generateSergeiReferenceState();
74 sergeiOrbit = sergeiState.getOrbit();
75 sergeiFrame = sergeiOrbit.getFrame();
76 }
77
78 private void doTestBlending(final double propagationHorizon, final double tabulatedTimeStep,
79 final SmoothStepFactory.SmoothStepFunction blendingFunction,
80 final AbstractAnalyticalPropagator analyticalPropagator,
81 final double expectedMeanRMSPositionError,
82 final double expectedMeanRMSVelocityError,
83 final double expectedMedianRMSPositionError,
84 final double expectedMedianRMSVelocityError,
85 final double expectedMaxRMSPositionError,
86 final double expectedMaxRMSVelocityError,
87 final double tolerance,
88 final boolean showResults) {
89 final TimeInterpolator<Orbit> orbitInterpolator = new OrbitBlender(blendingFunction,
90 analyticalPropagator,
91 sergeiFrame);
92
93 final TimeInterpolator<TimeStampedPair<Orbit, StateCovariance>> covarianceInterpolator =
94 new StateCovarianceBlender(blendingFunction, orbitInterpolator,
95 sergeiFrame, OrbitType.CARTESIAN,
96 PositionAngleType.MEAN);
97
98
99 final TimeInterpolator<SpacecraftState> stateInterpolator =
100 new SpacecraftStateInterpolator(sergeiFrame, orbitInterpolator, null, null, null, null);
101
102
103 final DescriptiveStatistics[] relativeRMSSigmaError =
104 StateCovarianceKeplerianHermiteInterpolatorTest.computeStatisticsCovarianceInterpolationOnSergeiCase(
105 propagationHorizon, tabulatedTimeStep, stateInterpolator, covarianceInterpolator);
106
107
108 if (showResults) {
109 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[0].getMean", relativeRMSSigmaError[0].getMean());
110 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[1].getMean", relativeRMSSigmaError[1].getMean());
111 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[0].getMedian", relativeRMSSigmaError[0].getPercentile(50));
112 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[1].getMedian", relativeRMSSigmaError[1].getPercentile(50));
113 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[0].getMax", relativeRMSSigmaError[0].getMax());
114 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[1].getMax", relativeRMSSigmaError[1].getMax());
115
116 }
117
118
119 Assertions.assertEquals(expectedMeanRMSPositionError, relativeRMSSigmaError[0].getMean(), tolerance);
120 Assertions.assertEquals(expectedMeanRMSVelocityError, relativeRMSSigmaError[1].getMean(), tolerance);
121 Assertions.assertEquals(expectedMedianRMSPositionError, relativeRMSSigmaError[0].getPercentile(50), tolerance);
122 Assertions.assertEquals(expectedMedianRMSVelocityError, relativeRMSSigmaError[1].getPercentile(50), tolerance);
123 Assertions.assertEquals(expectedMaxRMSPositionError, relativeRMSSigmaError[0].getMax(), tolerance);
124 Assertions.assertEquals(expectedMaxRMSVelocityError, relativeRMSSigmaError[1].getMax(), tolerance);
125 }
126
127
128
129
130
131
132
133
134
135
136 @Test
137 @DisplayName("test Keplerian quadratic blending interpolation on full force model test case from: "
138 + "TANYGIN, Sergei. Efficient covariance interpolation using blending of approximate covariance propagations. "
139 + "The Journal of the Astronautical Sciences, 2014, vol. 61, no 1, p. 107-132.")
140 void testKeplerianQuadraticBlending() {
141
142 final boolean showResults = false;
143 final double tolerance = 1.e-16;
144
145
146 final SmoothStepFactory.SmoothStepFunction blendingFunction = SmoothStepFactory.getQuadratic();
147
148
149 doTestBlending(DEFAULT_SERGEI_PROPAGATION_TIME, DEFAUTL_SERGEI_TABULATED_TIMESTEP, blendingFunction,
150 new KeplerianPropagator(sergeiOrbit),
151 0.1133302045524815,
152 0.2351882330196802,
153 0.1111607965207670,
154 0.2621621038900783,
155 0.2687823732965123,
156 0.4022217682474207,
157 tolerance,
158 showResults);
159
160
161
162
163
164
165
166
167 }
168
169
170
171
172
173
174
175
176 @Test
177 @DisplayName("test Brouwer Lyddane quadratic blending interpolation on full force model test case from: "
178 + "TANYGIN, Sergei. Efficient covariance interpolation using blending of approximate covariance propagations. "
179 + "The Journal of the Astronautical Sciences, 2014, vol. 61, no 1, p. 107-132.")
180 void testBrouwerLyddaneQuadraticBlending() {
181
182 final boolean showResults = false;
183 final double tolerance = 1.e-16;
184
185
186 final SmoothStepFactory.SmoothStepFunction blendingFunction = SmoothStepFactory.getQuadratic();
187
188 final AbstractAnalyticalPropagator propagator = new BrouwerLyddanePropagator(sergeiOrbit,
189 sergeiState.getMass(),
190 Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS,
191 Constants.EIGEN5C_EARTH_MU,
192 Constants.EIGEN5C_EARTH_C20,
193 Constants.EIGEN5C_EARTH_C30,
194 Constants.EIGEN5C_EARTH_C40,
195 Constants.EIGEN5C_EARTH_C50,
196 0);
197
198
199 doTestBlending(DEFAULT_SERGEI_PROPAGATION_TIME, DEFAUTL_SERGEI_TABULATED_TIMESTEP, blendingFunction,
200 propagator,
201 0.0823442943514750,
202 0.1976467714037895,
203 0.0888590153696339,
204 0.2020905044160413,
205 0.1446159909426887,
206 0.3894610461790040,
207 tolerance,
208 showResults);
209
210
211
212
213
214
215
216
217 }
218
219
220
221
222
223
224
225
226 @Test
227 @DisplayName("test Ekstein Hechler quadratic blending interpolation on full force model test case from: "
228 + "TANYGIN, Sergei. Efficient covariance interpolation using blending of approximate covariance propagations. "
229 + "The Journal of the Astronautical Sciences, 2014, vol. 61, no 1, p. 107-132.")
230 void testEksteinHechlerQuadraticBlending() {
231
232 final boolean showResults = false;
233 final double tolerance = 1.e-16;
234
235
236 final SmoothStepFactory.SmoothStepFunction blendingFunction = SmoothStepFactory.getQuadratic();
237
238 final AbstractAnalyticalPropagator propagator = new EcksteinHechlerPropagator(sergeiOrbit,
239 sergeiState.getMass(),
240 Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS,
241 Constants.EIGEN5C_EARTH_MU,
242 Constants.EIGEN5C_EARTH_C20,
243 Constants.EIGEN5C_EARTH_C30,
244 Constants.EIGEN5C_EARTH_C40,
245 Constants.EIGEN5C_EARTH_C50,
246 Constants.EIGEN5C_EARTH_C60);
247
248
249 doTestBlending(DEFAULT_SERGEI_PROPAGATION_TIME, DEFAUTL_SERGEI_TABULATED_TIMESTEP, blendingFunction,
250 propagator,
251 0.0920227696921130,
252 0.1753289773020222,
253 0.0857543808467324,
254 0.1933199872752203,
255 0.1693483908858563,
256 0.3473020830532024,
257 tolerance,
258 showResults);
259
260
261
262
263
264
265
266
267 }
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283 @Test
284 @DisplayName("test Keplerian quadratic blending expressed in LOF on full force model test case from : "
285 + "TANYGIN, Sergei. Efficient covariance interpolation using blending of approximate covariance propagations. "
286 + "The Journal of the Astronautical Sciences, 2014, vol. 61, no 1, p. 107-132.")
287 void testLOFKeplerianBlending() {
288
289 final boolean showResults = false;
290 final double tolerance = 1.e-16;
291
292
293 final SmoothStepFactory.SmoothStepFunction blendingFunction = SmoothStepFactory.getQuadratic();
294
295 final TimeInterpolator<Orbit> orbitInterpolator = new OrbitBlender(blendingFunction,
296 new KeplerianPropagator(sergeiOrbit),
297 sergeiFrame);
298
299 final LOFType DEFAULT_LOFTYPE = LOFType.TNW;
300 final AbstractStateCovarianceInterpolator covarianceInterpolator =
301 new StateCovarianceBlender(blendingFunction, orbitInterpolator, DEFAULT_LOFTYPE);
302
303
304 final DescriptiveStatistics[] relativeRMSSigmaError =
305 StateCovarianceKeplerianHermiteInterpolatorTest.computeStatisticsCovarianceLOFInterpolation(
306 DEFAULT_SERGEI_PROPAGATION_TIME, DEFAUTL_SERGEI_TABULATED_TIMESTEP,
307 DEFAULT_LOFTYPE, covarianceInterpolator);
308
309
310 if (showResults) {
311 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[0].getMean", relativeRMSSigmaError[0].getMean());
312 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[1].getMean", relativeRMSSigmaError[1].getMean());
313 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[0].getMedian", relativeRMSSigmaError[0].getPercentile(50));
314 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[1].getMedian", relativeRMSSigmaError[1].getPercentile(50));
315 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[0].getMax", relativeRMSSigmaError[0].getMax());
316 System.out.format(Locale.US, "%35s = %20.16f%n", "relativeRMSSigmaError[1].getMax", relativeRMSSigmaError[1].getMax());
317
318 }
319
320
321 Assertions.assertEquals( 0.1190324153130111, relativeRMSSigmaError[0].getMean(), tolerance);
322 Assertions.assertEquals( 7.2800694213600920, relativeRMSSigmaError[1].getMean(), tolerance);
323 Assertions.assertEquals( 0.1221432756730858, relativeRMSSigmaError[0].getPercentile(50), tolerance);
324 Assertions.assertEquals( 7.4882845444744826, relativeRMSSigmaError[1].getPercentile(50), tolerance);
325 Assertions.assertEquals( 0.2282143889000270, relativeRMSSigmaError[0].getMax(), tolerance);
326 Assertions.assertEquals(16.0468464408560370, relativeRMSSigmaError[1].getMax(), tolerance);
327
328
329 Assertions.assertNull(covarianceInterpolator.getOutFrame());
330 Assertions.assertEquals(DEFAULT_LOFTYPE, covarianceInterpolator.getOutLOF());
331 Assertions.assertEquals(OrbitType.CARTESIAN, covarianceInterpolator.getOutOrbitType());
332 Assertions.assertEquals(PositionAngleType.MEAN, covarianceInterpolator.getOutPositionAngleType());
333 Assertions.assertEquals(orbitInterpolator, covarianceInterpolator.getOrbitInterpolator());
334
335 }
336
337 }