DSSTBatchLSModel.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.estimation.leastsquares;

  18. import java.util.List;

  19. import org.orekit.estimation.measurements.ObservedMeasurement;
  20. import org.orekit.orbits.Orbit;
  21. import org.orekit.propagation.MatricesHarvester;
  22. import org.orekit.propagation.PropagationType;
  23. import org.orekit.propagation.Propagator;
  24. import org.orekit.propagation.SpacecraftState;
  25. import org.orekit.propagation.conversion.OrbitDeterminationPropagatorBuilder;
  26. import org.orekit.propagation.semianalytical.dsst.DSSTHarvester;
  27. import org.orekit.propagation.semianalytical.dsst.DSSTJacobiansMapper;
  28. import org.orekit.propagation.semianalytical.dsst.DSSTPropagator;
  29. import org.orekit.utils.ParameterDriversList;

  30. /** Bridge between {@link ObservedMeasurement measurements} and {@link
  31.  * org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresProblem
  32.  * least squares problems}.
  33.  * <p>
  34.  * This class is an adaption of the {@link BatchLSModel} class
  35.  * but for the {@link DSSTPropagator DSST propagator}.
  36.  * </p>
  37.  * @author Luc Maisonobe
  38.  * @author Bryan Cazabonne
  39.  * @since 10.0
  40.  *
  41.  */
  42. public class DSSTBatchLSModel extends AbstractBatchLSModel {

  43.     /** Name of the State Transition Matrix state. */
  44.     private static final String STM_NAME = DSSTBatchLSModel.class.getName() + "-derivatives";

  45.     /** Type of the orbit used for the propagation.*/
  46.     private PropagationType propagationType;

  47.     /** Type of the elements used to define the orbital state.*/
  48.     private PropagationType stateType;

  49.     /** Simple constructor.
  50.      * @param propagatorBuilders builders to use for propagation
  51.      * @param measurements measurements
  52.      * @param estimatedMeasurementsParameters estimated measurements parameters
  53.      * @param observer observer to be notified at model calls
  54.      * @param propagationType type of the orbit used for the propagation (mean or osculating)
  55.      * @param stateType type of the elements used to define the orbital state (mean or osculating)
  56.      */
  57.     public DSSTBatchLSModel(final OrbitDeterminationPropagatorBuilder[] propagatorBuilders,
  58.                             final List<ObservedMeasurement<?>> measurements,
  59.                             final ParameterDriversList estimatedMeasurementsParameters,
  60.                             final ModelObserver observer,
  61.                             final PropagationType propagationType,
  62.                             final PropagationType stateType) {
  63.         // call super constructor
  64.         super(propagatorBuilders, measurements, estimatedMeasurementsParameters, observer);
  65.         this.propagationType = propagationType;
  66.         this.stateType       = stateType;
  67.     }

  68.     /** {@inheritDoc} */
  69.     @Override
  70.     protected MatricesHarvester configureHarvester(final Propagator propagator) {
  71.         return propagator.setupMatricesComputation(STM_NAME, null, null);
  72.     }

  73.     /** {@inheritDoc} */
  74.     @Override
  75.     @Deprecated
  76.     protected DSSTJacobiansMapper configureDerivatives(final Propagator propagator) {

  77.         final org.orekit.propagation.semianalytical.dsst.DSSTPartialDerivativesEquations partials =
  78.                         new org.orekit.propagation.semianalytical.dsst.DSSTPartialDerivativesEquations(STM_NAME, (DSSTPropagator) propagator, propagationType);

  79.         // add the derivatives to the initial state
  80.         final SpacecraftState rawState = propagator.getInitialState();
  81.         final SpacecraftState stateWithDerivatives = partials.setInitialJacobians(rawState);
  82.         ((DSSTPropagator) propagator).setInitialState(stateWithDerivatives, stateType);

  83.         return partials.getMapper();

  84.     }

  85.     /** {@inheritDoc} */
  86.     @Override
  87.     protected Orbit configureOrbits(final MatricesHarvester harvester, final Propagator propagator) {
  88.         // Cast
  89.         final DSSTPropagator dsstPropagator = (DSSTPropagator) propagator;
  90.         final DSSTHarvester  dsstHarvester  = (DSSTHarvester) harvester;
  91.         // Mean orbit
  92.         final SpacecraftState initial = dsstPropagator.initialIsOsculating() ?
  93.                        DSSTPropagator.computeMeanState(dsstPropagator.getInitialState(), dsstPropagator.getAttitudeProvider(), dsstPropagator.getAllForceModels()) :
  94.                        dsstPropagator.getInitialState();
  95.         dsstHarvester.initializeFieldShortPeriodTerms(initial);
  96.         // Compute short period derivatives at the beginning of the iteration
  97.         if (propagationType == PropagationType.OSCULATING) {
  98.             dsstHarvester.updateFieldShortPeriodTerms(initial);
  99.             dsstHarvester.setReferenceState(initial);
  100.         }
  101.         // Compute short period derivatives at the beginning of the iteration
  102.         harvester.setReferenceState(initial);
  103.         return initial.getOrbit();
  104.     }

  105. }