ClockCorrectionsProvider.java

  1. /* Copyright 2002-2024 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.propagation.analytical.gnss.data.GNSSClockElements;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.utils.Constants;
  25. import org.orekit.utils.PVCoordinates;

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

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

  53.     /** The GPS clock elements. */
  54.     private final GNSSClockElements gnssClk;

  55.     /** Clock reference epoch. */
  56.     private final AbsoluteDate clockRef;

  57.     /** Simple constructor.
  58.      * @param gnssClk GNSS clock elements
  59.      */
  60.     public ClockCorrectionsProvider(final GNSSClockElements gnssClk) {
  61.         this.gnssClk  = gnssClk;
  62.         this.clockRef = gnssClk.getDate();
  63.     }

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

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

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

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

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

  100.         // estimated group delay differential
  101.         final double tg = gnssClk.getTGD();

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

  106. }