OsculatingToMeanElementsConverter.java

  1. /* Copyright 2002-2016 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.errors.OrekitException;
  19. import org.orekit.orbits.PositionAngle;
  20. import org.orekit.propagation.Propagator;
  21. import org.orekit.propagation.SpacecraftState;

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

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

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

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

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

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

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

  66.     /** Convert an osculating orbit into a mean orbit, in DSST sense.
  67.      *  @return mean orbit state, in DSST sense
  68.      *  @throws OrekitException if state cannot be propagated throughout range
  69.      */
  70.     public final SpacecraftState convert() throws OrekitException {

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