InterSatellitesPhase.java

  1. /* Copyright 2002-2022 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 java.util.HashMap;
  20. import java.util.Map;

  21. import org.hipparchus.analysis.differentiation.Gradient;
  22. import org.orekit.estimation.measurements.AbstractMeasurement;
  23. import org.orekit.estimation.measurements.EstimatedMeasurement;
  24. import org.orekit.estimation.measurements.ObservableSatellite;
  25. import org.orekit.propagation.SpacecraftState;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.time.FieldAbsoluteDate;
  28. import org.orekit.utils.Constants;
  29. import org.orekit.utils.ParameterDriver;
  30. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  31. import org.orekit.utils.TimeStampedPVCoordinates;

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

  45.     /** Name for ambiguity driver. */
  46.     public static final String AMBIGUITY_NAME = "ambiguity";

  47.     /** Driver for ambiguity. */
  48.     private final ParameterDriver ambiguityDriver;

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

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

  67.         // Initialize phase ambiguity driver
  68.         ambiguityDriver = new ParameterDriver(AMBIGUITY_NAME, 0.0, 1.0,
  69.                                               Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  70.         // Add parameter drivers
  71.         addParameterDriver(ambiguityDriver);
  72.         addParameterDriver(local.getClockOffsetDriver());
  73.         addParameterDriver(remote.getClockOffsetDriver());

  74.         // Initialize fields
  75.         this.wavelength = wavelength;
  76.     }

  77.     /** Get the wavelength.
  78.      * @return wavelength (m)
  79.      */
  80.     public double getWavelength() {
  81.         return wavelength;
  82.     }

  83.     /** Get the driver for phase ambiguity.
  84.      * @return the driver for phase ambiguity
  85.      */
  86.     public ParameterDriver getAmbiguityDriver() {
  87.         return ambiguityDriver;
  88.     }

  89.     /** {@inheritDoc} */
  90.     @Override
  91.     protected EstimatedMeasurement<InterSatellitesPhase> theoreticalEvaluation(final int iteration,
  92.                                                                                final int evaluation,
  93.                                                                                final SpacecraftState[] states) {

  94.         // Phase derivatives are computed with respect to spacecrafts states in inertial frame
  95.         // ----------------------
  96.         //
  97.         // Parameters:
  98.         //  - 0..2  - Position of the receiver satellite in inertial frame
  99.         //  - 3..5  - Velocity of the receiver satellite in inertial frame
  100.         //  - 6..8  - Position of the remote satellite in inertial frame
  101.         //  - 9..11 - Velocity of the remote satellite in inertial frame
  102.         //  - 12..  - Measurement parameters: ambiguity, local clock offset, remote clock offset...
  103.         int nbParams = 12;
  104.         final Map<String, Integer> indices = new HashMap<>();
  105.         for (ParameterDriver phaseMeasurementDriver : getParametersDrivers()) {
  106.             if (phaseMeasurementDriver.isSelected()) {
  107.                 indices.put(phaseMeasurementDriver.getName(), nbParams++);
  108.             }
  109.         }

  110.         // Coordinates of both satellites
  111.         final SpacecraftState local = states[0];
  112.         final TimeStampedFieldPVCoordinates<Gradient> pvaL = getCoordinates(local, 0, nbParams);
  113.         final SpacecraftState remote = states[1];
  114.         final TimeStampedFieldPVCoordinates<Gradient> pvaR = getCoordinates(remote, 6, nbParams);

  115.         // Compute propagation times
  116.         // Downlink delay
  117.         final Gradient dtl = getSatellites().get(0).getClockOffsetDriver().getValue(nbParams, indices);
  118.         final FieldAbsoluteDate<Gradient> arrivalDate = new FieldAbsoluteDate<>(getDate(), dtl.negate());

  119.         final TimeStampedFieldPVCoordinates<Gradient> s1Downlink =
  120.                         pvaL.shiftedBy(arrivalDate.durationFrom(pvaL.getDate()));
  121.         final Gradient tauD = signalTimeOfFlight(pvaR, s1Downlink.getPosition(), arrivalDate);

  122.         // Transit state
  123.         final double   delta      = getDate().durationFrom(remote.getDate());
  124.         final Gradient deltaMTauD = tauD.negate().add(delta);

  125.         // prepare the evaluation
  126.         final EstimatedMeasurement<InterSatellitesPhase> estimatedPhase =
  127.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  128.                                                    new SpacecraftState[] {
  129.                                                        local.shiftedBy(deltaMTauD.getValue()),
  130.                                                        remote.shiftedBy(deltaMTauD.getValue())
  131.                                                    }, new TimeStampedPVCoordinates[] {
  132.                                                        remote.shiftedBy(delta - tauD.getValue()).getPVCoordinates(),
  133.                                                        local.shiftedBy(delta).getPVCoordinates()
  134.                                                    });

  135.         // Clock offsets
  136.         final Gradient dtr = getSatellites().get(1).getClockOffsetDriver().getValue(nbParams, indices);

  137.         // Phase value
  138.         final double   cOverLambda = Constants.SPEED_OF_LIGHT / wavelength;
  139.         final Gradient ambiguity   = ambiguityDriver.getValue(nbParams, indices);
  140.         final Gradient phase       = tauD.add(dtl).subtract(dtr).multiply(cOverLambda).add(ambiguity);

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

  142.         // Range partial derivatives with respect to states
  143.         final double[] derivatives = phase.getGradient();
  144.         estimatedPhase.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0,  6));
  145.         estimatedPhase.setStateDerivatives(1, Arrays.copyOfRange(derivatives, 6, 12));

  146.         // Set partial derivatives with respect to parameters
  147.         for (final ParameterDriver driver : getParametersDrivers()) {
  148.             final Integer index = indices.get(driver.getName());
  149.             if (index != null) {
  150.                 estimatedPhase.setParameterDerivatives(driver, derivatives[index]);
  151.             }
  152.         }

  153.         // Return the estimated measurement
  154.         return estimatedPhase;

  155.     }

  156. }