OsculatingToSGP4Converter.java

  1. /* Copyright 2020-2024 Exotrail
  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.averaging.converters;

  18. import org.orekit.annotation.DefaultDataContext;
  19. import org.orekit.data.DataContext;
  20. import org.orekit.frames.Frame;
  21. import org.orekit.orbits.Orbit;
  22. import org.orekit.propagation.SpacecraftState;
  23. import org.orekit.propagation.analytical.tle.TLE;
  24. import org.orekit.propagation.analytical.tle.generation.FixedPointTleGenerationAlgorithm;
  25. import org.orekit.time.UTCScale;
  26. import org.orekit.propagation.conversion.averaging.SGP4OrbitalState;

  27. /**
  28.  * Class for osculating-to-averaged conversion according to "SGP4" theory, meant as the set of
  29.  * models associated to Two-Line Elements.
  30.  *
  31.  * @author Romain Serra
  32.  * @see org.orekit.propagation.analytical.tle.TLEPropagator
  33.  * @see SGP4OrbitalState
  34.  * @since 12.1
  35.  */
  36. public class OsculatingToSGP4Converter
  37.         extends FixedPointOsculatingToAveragedConverter<SGP4OrbitalState> {

  38.     /** First line of arbitrary TLE. Should not impact conversion. */
  39.     private static final String TEMPLATE_LINE_1 = "1 27421U 02021A   02124.48976499 -.00021470  00000-0 -89879-2 0    20";
  40.     /** Second line of arbitrary TLE. Should not impact conversion. */
  41.     private static final String TEMPLATE_LINE_2 = "2 27421  98.7490 199.5121 0001333 133.9522 226.1918 14.26113993    62";

  42.     /** Scale for fixed-point algorithm. */
  43.     private final double scale;
  44.     /** UTC time scale. */
  45.     private final UTCScale utc;
  46.     /** TEME frame. */
  47.     private final Frame teme;

  48.     /**
  49.      * Constructor with default data context.
  50.      */
  51.     @DefaultDataContext
  52.     public OsculatingToSGP4Converter() {
  53.         this(DataContext.getDefault());
  54.     }

  55.     /**
  56.      * Constructor with default parameters for fixed-point algorithm.
  57.      * @param dataContext data context
  58.      */
  59.     public OsculatingToSGP4Converter(final DataContext dataContext) {
  60.         this(DEFAULT_EPSILON, DEFAULT_MAX_ITERATIONS, FixedPointTleGenerationAlgorithm.SCALE_DEFAULT,
  61.                 dataContext);
  62.     }

  63.     /**
  64.      * Constructor.
  65.      * @param epsilon convergence threshold
  66.      * @param maxIterations maximum number of iterations
  67.      * @param scale scale
  68.      * @param dataContext data context
  69.      */
  70.     public OsculatingToSGP4Converter(final double epsilon, final int maxIterations,
  71.                                      final double scale, final DataContext dataContext) {
  72.         super(epsilon, maxIterations);
  73.         this.scale = scale;
  74.         this.utc = dataContext.getTimeScales().getUTC();
  75.         this.teme = dataContext.getFrames().getTEME();
  76.     }

  77.     /** {@inheritDoc} */
  78.     @Override
  79.     public SGP4OrbitalState convertToAveraged(final Orbit osculatingOrbit) {
  80.         final FixedPointTleGenerationAlgorithm fixedPointAlgorithm = new FixedPointTleGenerationAlgorithm(getEpsilon(),
  81.                 getMaxIterations(), scale, utc, teme);
  82.         final SpacecraftState osculatingState = new SpacecraftState(osculatingOrbit);
  83.         final TLE templateTLe = new TLE(TEMPLATE_LINE_1, TEMPLATE_LINE_2, utc);
  84.         final TLE tle = fixedPointAlgorithm.generate(osculatingState, templateTLe);
  85.         return SGP4OrbitalState.of(tle, teme);
  86.     }
  87. }