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.leastsquares;
18  
19  import java.util.List;
20  
21  import org.orekit.estimation.measurements.ObservedMeasurement;
22  import org.orekit.orbits.Orbit;
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  /** Bridge between {@link ObservedMeasurement measurements} and {@link
33   * org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresProblem
34   * least squares problems}.
35   * <p>
36   * This class is an adaption of the {@link BatchLSModel} class
37   * but for the {@link TLEPropagator TLE propagator}.
38   * </p>
39   * @author Luc Maisonobe
40   * @author Bryan Cazabonne
41   * @author Thomas Paulet
42   * @since 11.0
43   *
44   */
45  public class TLEBatchLSModel extends AbstractBatchLSModel {
46  
47      /** Simple constructor.
48       * @param propagatorBuilders builders to use for propagation
49       * @param measurements measurements
50       * @param estimatedMeasurementsParameters estimated measurements parameters
51       * @param observer observer to be notified at model calls
52       */
53      public TLEBatchLSModel(final OrbitDeterminationPropagatorBuilder[] propagatorBuilders,
54                             final List<ObservedMeasurement<?>> measurements,
55                             final ParameterDriversList estimatedMeasurementsParameters,
56                             final ModelObserver observer) {
57          // call super constructor
58          super(propagatorBuilders, measurements, estimatedMeasurementsParameters,
59                new TLEJacobiansMapper[propagatorBuilders.length], observer);
60      }
61  
62      /** {@inheritDoc} */
63      @Override
64      protected TLEJacobiansMapper configureDerivatives(final Propagator propagator) {
65  
66          final String equationName = TLEBatchLSModel.class.getName() + "-derivatives";
67  
68          final TLEPartialDerivativesEquations partials = new TLEPartialDerivativesEquations(equationName, (TLEPropagator) propagator);
69  
70          // add the derivatives to the initial state
71          final SpacecraftState rawState = propagator.getInitialState();
72          final SpacecraftState stateWithDerivatives = partials.setInitialJacobians(rawState);
73          propagator.resetInitialState(stateWithDerivatives);
74  
75          return partials.getMapper();
76  
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      protected Orbit configureOrbits(final AbstractJacobiansMapper mapper,
82                                      final Propagator propagator) {
83          // Directly return the propagator's initial state
84          return propagator.getInitialState().getOrbit();
85      }
86  
87  }