1   /* Copyright 2002-2021 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.sequential;
18  
19  import java.util.List;
20  
21  import org.orekit.annotation.DefaultDataContext;
22  import org.orekit.propagation.PropagationType;
23  import org.orekit.propagation.Propagator;
24  import org.orekit.propagation.SpacecraftState;
25  import org.orekit.propagation.analytical.tle.TLEJacobiansMapper;
26  import org.orekit.propagation.analytical.tle.TLEPartialDerivativesEquations;
27  import org.orekit.propagation.analytical.tle.TLEPropagator;
28  import org.orekit.propagation.conversion.OrbitDeterminationPropagatorBuilder;
29  import org.orekit.propagation.integration.AbstractJacobiansMapper;
30  import org.orekit.utils.ParameterDriversList;
31  
32  /** Class defining the process model dynamics to use with a {@link KalmanEstimator}.
33   * <p>
34   * This class is an adaption of the {@link KalmanModel} class
35   * but for the {@link TLEPropagator TLE propagator}.
36   * </p>
37   * @author Romain Gerbaud
38   * @author Maxime Journot
39   * @author Bryan Cazabonne
40   * @author Thomas Paulet
41   * @since 11.0
42   */
43  public class TLEKalmanModel extends AbstractKalmanModel {
44  
45      /** Kalman process model constructor (package private).
46       * @param propagatorBuilders propagators builders used to evaluate the orbits.
47       * @param covarianceMatricesProviders providers for covariance matrices
48       * @param estimatedMeasurementParameters measurement parameters to estimate
49       * @param measurementProcessNoiseMatrix provider for measurement process noise matrix
50       */
51      public TLEKalmanModel(final List<OrbitDeterminationPropagatorBuilder> propagatorBuilders,
52                            final List<CovarianceMatrixProvider> covarianceMatricesProviders,
53                            final ParameterDriversList estimatedMeasurementParameters,
54                            final CovarianceMatrixProvider measurementProcessNoiseMatrix) {
55          // call super constructor
56          super(propagatorBuilders, covarianceMatricesProviders, estimatedMeasurementParameters,
57                measurementProcessNoiseMatrix, new TLEJacobiansMapper[propagatorBuilders.size()]);
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      @DefaultDataContext
63      protected void updateReferenceTrajectories(final Propagator[] propagators,
64                                                 final PropagationType pType,
65                                                 final PropagationType sType) {
66  
67          // Update the reference trajectory propagator
68          setReferenceTrajectories(propagators);
69  
70          // Jacobian mappers
71          final AbstractJacobiansMapper[] mappers = getMappers();
72  
73          for (int k = 0; k < propagators.length; ++k) {
74              // Link the partial derivatives to this new propagator
75              final String equationName = KalmanEstimator.class.getName() + "-derivatives-" + k;
76              final TLEPartialDerivativesEquations pde = new TLEPartialDerivativesEquations(equationName, (TLEPropagator) getReferenceTrajectories()[k]);
77  
78              // Reset the Jacobians
79              final SpacecraftState rawState = getReferenceTrajectories()[k].getInitialState();
80              final SpacecraftState stateWithDerivatives = pde.setInitialJacobians(rawState);
81              ((TLEPropagator) getReferenceTrajectories()[k]).resetInitialState(stateWithDerivatives);
82              mappers[k] = pde.getMapper();
83          }
84  
85          // Update Jacobian mappers
86          setMappers(mappers);
87  
88      }
89  
90      /** {@inheritDoc} */
91      @Override
92      @DefaultDataContext
93      protected void analyticalDerivativeComputations(final AbstractJacobiansMapper mapper, final SpacecraftState state) {
94          ((TLEJacobiansMapper) mapper).analyticalDerivatives(state);
95      }
96  
97  }