InterSatellitesPhase.java

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

  18. import java.util.Arrays;

  19. import org.hipparchus.analysis.differentiation.Gradient;
  20. import org.orekit.estimation.measurements.EstimatedMeasurement;
  21. import org.orekit.estimation.measurements.EstimatedMeasurementBase;
  22. import org.orekit.estimation.measurements.ObservableSatellite;
  23. import org.orekit.propagation.SpacecraftState;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.utils.Constants;
  26. import org.orekit.utils.ParameterDriver;
  27. import org.orekit.utils.TimeSpanMap.Span;
  28. import org.orekit.utils.TimeStampedPVCoordinates;

  29. /** Phase measurement between two satellites.
  30.  * <p>
  31.  * The measurement is considered to be a signal emitted from
  32.  * a remote satellite and received by a local satellite.
  33.  * Its value is the number of cycles between emission and reception.
  34.  * The motion of both spacecraft during the signal flight time
  35.  * are taken into account. The date of the measurement corresponds to the
  36.  * reception on ground of the emitted signal.
  37.  * </p>
  38.  * @author Bryan Cazabonne
  39.  * @since 10.3
  40.  */
  41. public class InterSatellitesPhase extends AbstractInterSatellitesMeasurement<InterSatellitesPhase> {

  42.     /** Type of the measurement. */
  43.     public static final String MEASUREMENT_TYPE = "InterSatellitesPhase";

  44.     /** Driver for ambiguity. */
  45.     private final AmbiguityDriver ambiguityDriver;

  46.     /** Wavelength of the phase observed value [m]. */
  47.     private final double wavelength;

  48.     /** Constructor.
  49.      * @param local satellite which receives the signal and performs the measurement
  50.      * @param remote remote satellite which simply emits the signal
  51.      * @param date date of the measurement
  52.      * @param phase observed value (cycles)
  53.      * @param wavelength phase observed value wavelength (m)
  54.      * @param sigma theoretical standard deviation
  55.      * @param baseWeight base weight
  56.      * @param cache from which ambiguity drive should come
  57.      * @since 12.1
  58.      */
  59.     public InterSatellitesPhase(final ObservableSatellite local,
  60.                                 final ObservableSatellite remote,
  61.                                 final AbsoluteDate date, final double phase,
  62.                                 final double wavelength, final double sigma,
  63.                                 final double baseWeight,
  64.                                 final AmbiguityCache cache) {
  65.         // Call to super constructor
  66.         super(date, phase, sigma, baseWeight, local, remote);

  67.         // Initialize phase ambiguity driver
  68.         ambiguityDriver = cache.getAmbiguity(remote.getName(), local.getName(), wavelength);

  69.         // Add parameter drivers
  70.         addParameterDriver(ambiguityDriver);

  71.         // Initialize fields
  72.         this.wavelength = wavelength;
  73.     }

  74.     /** Get the wavelength.
  75.      * @return wavelength (m)
  76.      */
  77.     public double getWavelength() {
  78.         return wavelength;
  79.     }

  80.     /** Get the driver for phase ambiguity.
  81.      * @return the driver for phase ambiguity
  82.      */
  83.     public ParameterDriver getAmbiguityDriver() {
  84.         return ambiguityDriver;
  85.     }

  86.     /** {@inheritDoc} */
  87.     @Override
  88.     protected EstimatedMeasurementBase<InterSatellitesPhase> theoreticalEvaluationWithoutDerivatives(final int iteration,
  89.                                                                                                      final int evaluation,
  90.                                                                                                      final SpacecraftState[] states) {

  91.         final OnBoardCommonParametersWithoutDerivatives common = computeCommonParametersWithout(states, false);

  92.         // prepare the evaluation
  93.         final EstimatedMeasurementBase<InterSatellitesPhase> estimatedPhase =
  94.                         new EstimatedMeasurementBase<>(this, iteration, evaluation,
  95.                                                        new SpacecraftState[] {
  96.                                                            common.getState(),
  97.                                                            states[1]
  98.                                                        }, new TimeStampedPVCoordinates[] {
  99.                                                            common.getRemotePV(),
  100.                                                            common.getTransitPV()
  101.                                                        });

  102.         // Phase value
  103.         final double cOverLambda = Constants.SPEED_OF_LIGHT / wavelength;
  104.         final double ambiguity   = ambiguityDriver.getValue(common.getState().getDate());
  105.         final double phase       = (common.getTauD() + common.getLocalOffset() - common.getRemoteOffset()) * cOverLambda +
  106.                                    ambiguity;

  107.         estimatedPhase.setEstimatedValue(phase);

  108.         // Return the estimated measurement
  109.         return estimatedPhase;

  110.     }

  111.     /** {@inheritDoc} */
  112.     @Override
  113.     protected EstimatedMeasurement<InterSatellitesPhase> theoreticalEvaluation(final int iteration,
  114.                                                                                final int evaluation,
  115.                                                                                final SpacecraftState[] states) {

  116.         final OnBoardCommonParametersWithDerivatives common = computeCommonParametersWith(states, false);

  117.        // prepare the evaluation
  118.         final EstimatedMeasurement<InterSatellitesPhase> estimatedPhase =
  119.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  120.                                                    new SpacecraftState[] {
  121.                                                        common.getState(),
  122.                                                        states[1]
  123.                                                    }, new TimeStampedPVCoordinates[] {
  124.                                                        common.getRemotePV().toTimeStampedPVCoordinates(),
  125.                                                        common.getTransitPV().toTimeStampedPVCoordinates()
  126.                                                    });

  127.         // Phase value
  128.         final double   cOverLambda = Constants.SPEED_OF_LIGHT / wavelength;
  129.         final Gradient ambiguity   = ambiguityDriver.getValue(common.getTauD().getFreeParameters(), common.getIndices(),
  130.                                                               common.getState().getDate());
  131.         final Gradient phase       = common.getTauD().add(common.getLocalOffset()).subtract(common.getRemoteOffset()).
  132.                                      multiply(cOverLambda).
  133.                                      add(ambiguity);

  134.         estimatedPhase.setEstimatedValue(phase.getValue());

  135.         // Range first order derivatives with respect to states
  136.         final double[] derivatives = phase.getGradient();
  137.         estimatedPhase.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0,  6));
  138.         estimatedPhase.setStateDerivatives(1, Arrays.copyOfRange(derivatives, 6, 12));

  139.         // Set first order derivatives with respect to parameters
  140.         for (final ParameterDriver driver : getParametersDrivers()) {
  141.             for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {

  142.                 final Integer index = common.getIndices().get(span.getData());
  143.                 if (index != null) {
  144.                     estimatedPhase.setParameterDerivatives(driver, span.getStart(), derivatives[index]);
  145.                 }
  146.             }
  147.         }

  148.         // Return the estimated measurement
  149.         return estimatedPhase;

  150.     }

  151. }