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.analytical.tle;
18  
19  import java.util.List;
20  
21  import org.hipparchus.analysis.differentiation.Gradient;
22  import org.orekit.attitudes.AttitudeProvider;
23  import org.orekit.frames.Frame;
24  import org.orekit.propagation.FieldSpacecraftState;
25  import org.orekit.propagation.analytical.AbstractAnalyticalGradientConverter;
26  import org.orekit.time.TimeScale;
27  import org.orekit.utils.ParameterDriver;
28  
29  /** Converter for TLE propagator.
30   * @author Luc Maisonobe
31   * @author Bryan Cazabonne
32   * @author Thomas Paulet
33   * @since 11.0
34   */
35  class TLEGradientConverter extends AbstractAnalyticalGradientConverter {
36  
37      /** Fixed dimension of the state. */
38      public static final int FREE_STATE_PARAMETERS = 6;
39  
40      /** Current TLE. */
41      private final TLE tle;
42  
43      /** UTC time scale. */
44      private final TimeScale utc;
45  
46      /** TEME frame. */
47      private final Frame teme;
48  
49      /** Attitude provider. */
50      private final AttitudeProvider provider;
51  
52      /** Simple constructor.
53       * @param propagator TLE propagator used to access initial orbit
54       */
55      TLEGradientConverter(final TLEPropagator propagator) {
56          super(propagator, TLEConstants.MU, FREE_STATE_PARAMETERS);
57          // TLE and related parameters
58          this.tle      = propagator.getTLE();
59          this.teme     = propagator.getFrame();
60          this.utc      = tle.getUtc();
61          this.provider = propagator.getAttitudeProvider();
62      }
63  
64      /** {@inheritDoc} */
65      @Override
66      public FieldTLEPropagator<Gradient> getPropagator(final FieldSpacecraftState<Gradient> state,
67                                                        final Gradient[] parameters) {
68  
69          // Zero
70          final Gradient zero = state.getA().getField().getZero();
71  
72          // Template TLE
73          final int satelliteNumber         = tle.getSatelliteNumber();
74          final char classification         = tle.getClassification();
75          final int launchYear              = tle.getLaunchYear();
76          final int launchNumber            = tle.getLaunchNumber();
77          final String launchPiece          = tle.getLaunchPiece();
78          final int ephemerisType           = tle.getEphemerisType();
79          final int elementNumber           = tle.getElementNumber();
80          final int revolutionNumberAtEpoch = tle.getRevolutionNumberAtEpoch();
81          final double bStar                = tle.getBStar();
82  
83          // Initialize the new TLE
84          final FieldTLE<Gradient> templateTLE = new FieldTLE<>(satelliteNumber, classification,
85                          launchYear, launchNumber, launchPiece, ephemerisType, elementNumber, state.getDate(),
86                          zero, zero, zero, zero, zero, zero, zero, zero,
87                          revolutionNumberAtEpoch, bStar, utc);
88  
89          // TLE
90          final FieldTLE<Gradient> gTLE = FieldTLE.stateToTLE(state, templateTLE, utc, teme);
91  
92          // Return the "Field" propagator
93          return FieldTLEPropagator.selectExtrapolator(gTLE, provider, state.getMass(), teme, parameters);
94  
95      }
96  
97      /** {@inheritDoc} */
98      @Override
99      public List<ParameterDriver> getParametersDrivers() {
100         return tle.getParametersDrivers();
101     }
102 
103 }