InterSatellitesPhase.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.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.     /** Name for ambiguity driver.
  45.      * @deprecated as of 12.1 not used anymore
  46.      */
  47.     @Deprecated
  48.     public static final String AMBIGUITY_NAME = "ambiguity";

  49.     /** Driver for ambiguity. */
  50.     private final AmbiguityDriver ambiguityDriver;

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

  53.     /** Constructor.
  54.      * @param local satellite which receives the signal and performs the measurement
  55.      * @param remote remote satellite which simply emits the signal
  56.      * @param date date of the measurement
  57.      * @param phase observed value (cycles)
  58.      * @param wavelength phase observed value wavelength (m)
  59.      * @param sigma theoretical standard deviation
  60.      * @param baseWeight base weight
  61.      * @deprecated as of 12.1, replaced by {@link #InterSatellitesPhase(ObservableSatellite,
  62.      * ObservableSatellite, AbsoluteDate, double, double, double, double,
  63.      * AmbiguityCache)}
  64.      */
  65.     @Deprecated
  66.     public InterSatellitesPhase(final ObservableSatellite local,
  67.                                 final ObservableSatellite remote,
  68.                                 final AbsoluteDate date, final double phase,
  69.                                 final double wavelength, final double sigma,
  70.                                 final double baseWeight) {
  71.         this(local, remote, date, phase, wavelength, sigma, baseWeight,
  72.              AmbiguityCache.DEFAULT_CACHE);
  73.     }

  74.     /** Constructor.
  75.      * @param local satellite which receives the signal and performs the measurement
  76.      * @param remote remote satellite which simply emits the signal
  77.      * @param date date of the measurement
  78.      * @param phase observed value (cycles)
  79.      * @param wavelength phase observed value wavelength (m)
  80.      * @param sigma theoretical standard deviation
  81.      * @param baseWeight base weight
  82.      * @param cache from which ambiguity drive should come
  83.      * @since 12.1
  84.      */
  85.     public InterSatellitesPhase(final ObservableSatellite local,
  86.                                 final ObservableSatellite remote,
  87.                                 final AbsoluteDate date, final double phase,
  88.                                 final double wavelength, final double sigma,
  89.                                 final double baseWeight,
  90.                                 final AmbiguityCache cache) {
  91.         // Call to super constructor
  92.         super(date, phase, sigma, baseWeight, local, remote);

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

  95.         // Add parameter drivers
  96.         addParameterDriver(ambiguityDriver);

  97.         // Initialize fields
  98.         this.wavelength = wavelength;
  99.     }

  100.     /** Get the wavelength.
  101.      * @return wavelength (m)
  102.      */
  103.     public double getWavelength() {
  104.         return wavelength;
  105.     }

  106.     /** Get the driver for phase ambiguity.
  107.      * @return the driver for phase ambiguity
  108.      */
  109.     public ParameterDriver getAmbiguityDriver() {
  110.         return ambiguityDriver;
  111.     }

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

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

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

  128.         // Phase value
  129.         final double cOverLambda = Constants.SPEED_OF_LIGHT / wavelength;
  130.         final double ambiguity   = ambiguityDriver.getValue(common.getState().getDate());
  131.         final double phase       = (common.getTauD() + common.getLocalOffset() - common.getRemoteOffset()) * cOverLambda +
  132.                                    ambiguity;

  133.         estimatedPhase.setEstimatedValue(phase);

  134.         // Return the estimated measurement
  135.         return estimatedPhase;

  136.     }

  137.     /** {@inheritDoc} */
  138.     @Override
  139.     protected EstimatedMeasurement<InterSatellitesPhase> theoreticalEvaluation(final int iteration,
  140.                                                                                final int evaluation,
  141.                                                                                final SpacecraftState[] states) {

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

  143.        // prepare the evaluation
  144.         final EstimatedMeasurement<InterSatellitesPhase> estimatedPhase =
  145.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  146.                                                    new SpacecraftState[] {
  147.                                                        common.getState(),
  148.                                                        states[1]
  149.                                                    }, new TimeStampedPVCoordinates[] {
  150.                                                        common.getRemotePV().toTimeStampedPVCoordinates(),
  151.                                                        common.getTransitPV().toTimeStampedPVCoordinates()
  152.                                                    });

  153.         // Phase value
  154.         final double   cOverLambda = Constants.SPEED_OF_LIGHT / wavelength;
  155.         final Gradient ambiguity   = ambiguityDriver.getValue(common.getTauD().getFreeParameters(), common.getIndices(),
  156.                                                               common.getState().getDate());
  157.         final Gradient phase       = common.getTauD().add(common.getLocalOffset()).subtract(common.getRemoteOffset()).
  158.                                      multiply(cOverLambda).
  159.                                      add(ambiguity);

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

  161.         // Range first order derivatives with respect to states
  162.         final double[] derivatives = phase.getGradient();
  163.         estimatedPhase.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0,  6));
  164.         estimatedPhase.setStateDerivatives(1, Arrays.copyOfRange(derivatives, 6, 12));

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

  168.                 final Integer index = common.getIndices().get(span.getData());
  169.                 if (index != null) {
  170.                     estimatedPhase.setParameterDerivatives(driver, span.getStart(), derivatives[index]);
  171.                 }
  172.             }
  173.         }

  174.         // Return the estimated measurement
  175.         return estimatedPhase;

  176.     }

  177. }