1 /* Copyright 2002-2025 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.propagation.conversion;
18
19 import org.orekit.orbits.PositionAngleType;
20 import org.orekit.propagation.Propagator;
21 import org.orekit.propagation.SpacecraftState;
22
23 /** This class converts osculating orbital elements into mean elements.
24 * <p>
25 * As this process depends on the force models used to average the orbit,
26 * a {@link Propagator} is given as input. The force models used will be
27 * those contained into the propagator. This propagator <em>must</em>
28 * support its initial state to be reset, and this initial state <em>must</em>
29 * represent some mean value. This implies that this method will not work
30 * with {@link org.orekit.propagation.analytical.tle.TLEPropagator TLE propagators}
31 * because their initial state cannot be reset, and it won't work either with
32 * {@link org.orekit.propagation.analytical.EcksteinHechlerPropagator Eckstein-Hechler
33 * propagator} as their initial state is osculating and not mean. As of 6.0, this
34 * works mainly for {@link org.orekit.propagation.semianalytical.dsst.DSSTPropagator
35 * DSST propagator}.
36 * </p>
37 * @author rdicosta
38 * @author Pascal Parraud
39 */
40 public class OsculatingToMeanElementsConverter {
41
42 /** Integrator maximum evaluation. */
43 private static final int MAX_EVALUATION = 1000;
44
45 /** Initial orbit to convert. */
46 private final SpacecraftState state;
47
48 /** Number of satellite revolutions in the averaging interval. */
49 private final int satelliteRevolution;
50
51 /** Propagator used to compute mean orbit. */
52 private final Propagator propagator;
53
54 /** Scaling factor used for orbital parameters normalization. */
55 private double positionScale;
56
57 /** Constructor.
58 * @param state initial orbit to convert
59 * @param satelliteRevolution number of satellite revolutions in the averaging interval
60 * @param propagator propagator used to compute mean orbit
61 * @param positionScale scaling factor used for orbital parameters normalization
62 * (typically set to the expected standard deviation of the position)
63 */
64 public OsculatingToMeanElementsConverter(final SpacecraftState state,
65 final int satelliteRevolution,
66 final Propagator propagator,
67 final double positionScale) {
68 this.state = state;
69 this.satelliteRevolution = satelliteRevolution;
70 this.propagator = propagator;
71 this.positionScale = positionScale;
72 }
73
74 /** Convert an osculating orbit into a mean orbit, in DSST sense.
75 * @return mean orbit state, in DSST sense
76 */
77 public final SpacecraftState convert() {
78
79 final double timeSpan = state.getOrbit().getKeplerianPeriod() * satelliteRevolution;
80 propagator.resetInitialState(state);
81 final FiniteDifferencePropagatorConverter converter =
82 new FiniteDifferencePropagatorConverter(new KeplerianPropagatorBuilder(state.getOrbit(),
83 PositionAngleType.MEAN,
84 positionScale,
85 propagator.getAttitudeProvider()),
86 1.e-6, MAX_EVALUATION);
87 final Propagator prop = converter.convert(propagator, timeSpan, satelliteRevolution * 36);
88 return prop.getInitialState();
89 }
90 }