ClockCorrectionsProvider.java

  1. /* Copyright 2002-2020 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.gnss;

  18. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.orekit.estimation.measurements.EstimationModifier;
  20. import org.orekit.propagation.AdditionalStateProvider;
  21. import org.orekit.propagation.SpacecraftState;
  22. import org.orekit.time.AbsoluteDate;
  23. import org.orekit.utils.Constants;
  24. import org.orekit.utils.PVCoordinates;

  25. /** Provider for clock corrections as additional states.
  26.  * <p>
  27.  * The value of this additional state is a three elements array containing
  28.  * </p>
  29.  * <ul>
  30.  *   <li>at index 0, the polynomial satellite clock model
  31.  *       Δtₛₐₜ = {@link GPSOrbitalElements#getAf0() a₀} +
  32.  *               {@link GPSOrbitalElements#getAf1() a₁} (t - {@link GPSOrbitalElements#getToc() toc}) +
  33.  *               {@link GPSOrbitalElements#getAf1() a₂} (t - {@link GPSOrbitalElements#getToc() toc})²
  34.  *   </li>
  35.  *   <li>at index 1 the relativistic clock correction due to eccentricity</li>
  36.  *   <li>at index 2 the estimated group delay differential {@link GPSOrbitalElements#getTGD() TGD} for L1-L2 correction</li>
  37.  * </ul>
  38.  * <p>
  39.  * Since Orekit 10.3 the relativistic clock correction can be used as an {@link EstimationModifier}
  40.  * in orbit determination applications to take into consideration this effect
  41.  * in measurement modeling.
  42.  * <p>
  43.  *
  44.  * @author Luc Maisonobe
  45.  * @since 9.3
  46.  */
  47. public class ClockCorrectionsProvider implements AdditionalStateProvider {

  48.     /** Name of the additional state for satellite clock corrections.
  49.      * @since 9.3
  50.      */
  51.     public static final String CLOCK_CORRECTIONS = "";

  52.     /** Duration of the GPS cycle in seconds. */
  53.     private static final double GPS_CYCLE_DURATION = GPSOrbitalElements.GPS_WEEK_IN_SECONDS *
  54.                                                      GPSOrbitalElements.GPS_WEEK_NB;
  55.     /** The GPS orbital elements. */
  56.     private final GPSOrbitalElements gpsOrbit;

  57.     /** Clock reference epoch. */
  58.     private final AbsoluteDate clockRef;

  59.     /** Simple constructor.
  60.      * @param gpsOrbit GPS orbital elements
  61.      */
  62.     public ClockCorrectionsProvider(final GPSOrbitalElements gpsOrbit) {
  63.         this.gpsOrbit = gpsOrbit;
  64.         this.clockRef = gpsOrbit.getDate();
  65.     }

  66.     /** {@inheritDoc} */
  67.     @Override
  68.     public String getName() {
  69.         return CLOCK_CORRECTIONS;
  70.     }

  71.     /**
  72.      * Get the duration from clock Reference epoch.
  73.      * <p>This takes the GPS week roll-over into account.</p>
  74.      *
  75.      * @param date the considered date
  76.      * @return the duration from clock Reference epoch (s)
  77.      */
  78.     private double getDT(final AbsoluteDate date) {
  79.         // Time from ephemeris reference epoch
  80.         double dt = date.durationFrom(clockRef);
  81.         // Adjusts the time to take roll over week into account
  82.         while (dt > 0.5 * GPS_CYCLE_DURATION) {
  83.             dt -= GPS_CYCLE_DURATION;
  84.         }
  85.         while (dt < -0.5 * GPS_CYCLE_DURATION) {
  86.             dt += GPS_CYCLE_DURATION;
  87.         }
  88.         // Returns the time from ephemeris reference epoch
  89.         return dt;
  90.     }

  91.     /** {@inheritDoc} */
  92.     @Override
  93.     public double[] getAdditionalState(final SpacecraftState state) {

  94.         // polynomial clock model
  95.         final double  dt    = getDT(state.getDate());
  96.         final double  dtSat = gpsOrbit.getAf0() + dt * (gpsOrbit.getAf1() + dt * gpsOrbit.getAf2());

  97.         // relativistic effect due to eccentricity
  98.         final PVCoordinates pv    = state.getPVCoordinates();
  99.         final double        dtRel = -2 * Vector3D.dotProduct(pv.getPosition(), pv.getVelocity()) /
  100.                         (Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT);

  101.         // estimated group delay differential
  102.         final double tg = gpsOrbit.getTGD();

  103.         return new double[] {
  104.             dtSat, dtRel, tg
  105.         };
  106.     }

  107. }