OsculatingToMeanElementsConverter.java

  1. /* Copyright 2002-2022 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. import org.orekit.orbits.PositionAngle;
  19. import org.orekit.propagation.Propagator;
  20. import org.orekit.propagation.SpacecraftState;

  21. /** This class converts osculating orbital elements into mean elements.
  22.  *  <p>
  23.  *  As this process depends on the force models used to average the orbit,
  24.  *  a {@link Propagator} is given as input. The force models used will be
  25.  *  those contained into the propagator. This propagator <em>must</em>
  26.  *  support its initial state to be reset, and this initial state <em>must</em>
  27.  *  represent some mean value. This implies that this method will not work
  28.  *  with {@link org.orekit.propagation.analytical.tle.TLEPropagator TLE propagators}
  29.  *  because their initial state cannot be reset, and it won't work either with
  30.  *  {@link org.orekit.propagation.analytical.EcksteinHechlerPropagator Eckstein-Hechler
  31.  *  propagator} as their initial state is osculating and not mean. As of 6.0, this
  32.  *  works mainly for {@link org.orekit.propagation.semianalytical.dsst.DSSTPropagator
  33.  *  DSST propagator}.
  34.  *  </p>
  35.  *  @author rdicosta
  36.  *  @author Pascal Parraud
  37.  */
  38. public class OsculatingToMeanElementsConverter {

  39.     /** Integrator maximum evaluation. */
  40.     private static final int      MAX_EVALUATION = 1000;

  41.     /** Initial orbit to convert. */
  42.     private final SpacecraftState state;

  43.     /** Number of satellite revolutions in the averaging interval. */
  44.     private final int             satelliteRevolution;

  45.     /** Propagator used to compute mean orbit. */
  46.     private final Propagator      propagator;

  47.     /** Scaling factor used for orbital parameters normalization. */
  48.     private double positionScale;

  49.     /** Constructor.
  50.      *  @param state initial orbit to convert
  51.      *  @param satelliteRevolution number of satellite revolutions in the averaging interval
  52.      *  @param propagator propagator used to compute mean orbit
  53.      *  @param positionScale scaling factor used for orbital parameters normalization
  54.      *  (typically set to the expected standard deviation of the position)
  55.      */
  56.     public OsculatingToMeanElementsConverter(final SpacecraftState state,
  57.                                              final int satelliteRevolution,
  58.                                              final Propagator propagator,
  59.                                              final double positionScale) {
  60.         this.state = state;
  61.         this.satelliteRevolution = satelliteRevolution;
  62.         this.propagator = propagator;
  63.         this.positionScale = positionScale;
  64.     }

  65.     /** Convert an osculating orbit into a mean orbit, in DSST sense.
  66.      *  @return mean orbit state, in DSST sense
  67.      */
  68.     public final SpacecraftState convert() {

  69.         final double timeSpan = state.getKeplerianPeriod() * satelliteRevolution;
  70.         propagator.resetInitialState(state);
  71.         final FiniteDifferencePropagatorConverter converter =
  72.                 new FiniteDifferencePropagatorConverter(new KeplerianPropagatorBuilder(state.getOrbit(),
  73.                                                                                        PositionAngle.MEAN,
  74.                                                                                        positionScale,
  75.                                                                                        propagator.getAttitudeProvider()),
  76.                                                         1.e-6, MAX_EVALUATION);
  77.         final Propagator prop = converter.convert(propagator, timeSpan, satelliteRevolution * 36);
  78.         return prop.getInitialState();
  79.     }
  80. }