TLEPropagatorBuilder.java

  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.propagation.conversion;

  18. import java.util.List;

  19. import org.orekit.annotation.DefaultDataContext;
  20. import org.orekit.attitudes.InertialProvider;
  21. import org.orekit.data.DataContext;
  22. import org.orekit.estimation.leastsquares.AbstractBatchLSModel;
  23. import org.orekit.estimation.leastsquares.ModelObserver;
  24. import org.orekit.estimation.leastsquares.TLEBatchLSModel;
  25. import org.orekit.estimation.measurements.ObservedMeasurement;
  26. import org.orekit.estimation.sequential.AbstractKalmanModel;
  27. import org.orekit.estimation.sequential.CovarianceMatrixProvider;
  28. import org.orekit.estimation.sequential.TLEKalmanModel;
  29. import org.orekit.frames.Frame;
  30. import org.orekit.orbits.Orbit;
  31. import org.orekit.orbits.PositionAngle;
  32. import org.orekit.propagation.Propagator;
  33. import org.orekit.propagation.SpacecraftState;
  34. import org.orekit.propagation.analytical.tle.TLE;
  35. import org.orekit.propagation.analytical.tle.TLEPropagator;
  36. import org.orekit.time.TimeScale;
  37. import org.orekit.utils.ParameterDriver;
  38. import org.orekit.utils.ParameterDriversList;

  39. /** Builder for TLEPropagator.
  40.  * @author Pascal Parraud
  41.  * @author Thomas Paulet
  42.  * @since 6.0
  43.  */
  44. public class TLEPropagatorBuilder extends AbstractPropagatorBuilder implements OrbitDeterminationPropagatorBuilder {

  45.     /** Data context used to access frames and time scales. */
  46.     private final DataContext dataContext;

  47.     /** Template TLE. */
  48.     private final TLE templateTLE;

  49.     /** Build a new instance. This constructor uses the {@link DataContext#getDefault()
  50.      * default data context}.
  51.      * <p>
  52.      * The template TLE is used as a model to {@link
  53.      * #createInitialOrbit() create initial orbit}. It defines the
  54.      * inertial frame, the central attraction coefficient, orbit type, satellite number,
  55.      * classification, .... and is also used together with the {@code positionScale} to
  56.      * convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
  57.      * parameters used by the callers of this builder to the real orbital parameters.
  58.      * </p>
  59.      * @param templateTLE reference TLE from which real orbits will be built
  60.      * @param positionAngle position angle type to use
  61.      * @param positionScale scaling factor used for orbital parameters normalization
  62.      * (typically set to the expected standard deviation of the position)
  63.      * @since 7.1
  64.      * @see #TLEPropagatorBuilder(TLE, PositionAngle, double, DataContext)
  65.      */
  66.     @DefaultDataContext
  67.     public TLEPropagatorBuilder(final TLE templateTLE, final PositionAngle positionAngle,
  68.                                 final double positionScale) {
  69.         this(templateTLE, positionAngle, positionScale, DataContext.getDefault());
  70.     }

  71.     /** Build a new instance.
  72.      * <p>
  73.      * The template TLE is used as a model to {@link
  74.      * #createInitialOrbit() create initial orbit}. It defines the
  75.      * inertial frame, the central attraction coefficient, orbit type, satellite number,
  76.      * classification, .... and is also used together with the {@code positionScale} to
  77.      * convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
  78.      * parameters used by the callers of this builder to the real orbital parameters.
  79.      * </p>
  80.      * @param templateTLE reference TLE from which real orbits will be built
  81.      * @param positionAngle position angle type to use
  82.      * @param positionScale scaling factor used for orbital parameters normalization
  83.      * (typically set to the expected standard deviation of the position)
  84.      * @param dataContext used to access frames and time scales.
  85.      * @since 10.1
  86.      */
  87.     public TLEPropagatorBuilder(final TLE templateTLE,
  88.                                 final PositionAngle positionAngle,
  89.                                 final double positionScale,
  90.                                 final DataContext dataContext) {
  91.         super(TLEPropagator.selectExtrapolator(templateTLE, dataContext.getFrames())
  92.                         .getInitialState().getOrbit(),
  93.               positionAngle, positionScale, false,
  94.               InertialProvider.of(dataContext.getFrames().getTEME()));
  95.         for (final ParameterDriver driver : templateTLE.getParametersDrivers()) {
  96.             addSupportedParameter(driver);
  97.         }
  98.         this.templateTLE = templateTLE;
  99.         this.dataContext = dataContext;

  100.     }

  101.     /** {@inheritDoc} */
  102.     @Override
  103.     public TLEPropagator buildPropagator(final double[] normalizedParameters) {

  104.         // create the orbit
  105.         setParameters(normalizedParameters);
  106.         final Orbit           orbit = createInitialOrbit();
  107.         final SpacecraftState state = new SpacecraftState(orbit);
  108.         final Frame           teme  = dataContext.getFrames().getTEME();
  109.         final TimeScale       utc   = dataContext.getTimeScales().getUTC();

  110.         // TLE related to the orbit
  111.         final TLE tle = TLE.stateToTLE(state, templateTLE, utc, teme);
  112.         final List<ParameterDriver> drivers = templateTLE.getParametersDrivers();
  113.         for (int index = 0; index < drivers.size(); index++) {
  114.             if (drivers.get(index).isSelected()) {
  115.                 tle.getParametersDrivers().get(index).setSelected(true);
  116.             }
  117.         }

  118.         // propagator
  119.         return TLEPropagator.selectExtrapolator(tle,
  120.                                                 getAttitudeProvider(),
  121.                                                 Propagator.DEFAULT_MASS,
  122.                                                 teme);

  123.     }

  124.     /** Getter for the template TLE.
  125.      * @return the template TLE
  126.      */
  127.     public TLE getTemplateTLE() {
  128.         return templateTLE;
  129.     }

  130.     /** {@inheritDoc} */
  131.     public AbstractBatchLSModel buildLSModel(final OrbitDeterminationPropagatorBuilder[] builders,
  132.                                 final List<ObservedMeasurement<?>> measurements,
  133.                                 final ParameterDriversList estimatedMeasurementsParameters,
  134.                                 final ModelObserver observer) {
  135.         return new TLEBatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
  136.     }

  137.     @Override
  138.     public AbstractKalmanModel
  139.         buildKalmanModel(final List<OrbitDeterminationPropagatorBuilder> propagatorBuilders,
  140.                          final List<CovarianceMatrixProvider> covarianceMatricesProviders,
  141.                          final ParameterDriversList estimatedMeasurementsParameters,
  142.                          final CovarianceMatrixProvider measurementProcessNoiseMatrix) {
  143.         return new TLEKalmanModel(propagatorBuilders, covarianceMatricesProviders, estimatedMeasurementsParameters, measurementProcessNoiseMatrix);
  144.     }

  145. }