RangeRate.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;

  18. import java.util.Arrays;
  19. import java.util.Map;

  20. import org.hipparchus.analysis.differentiation.Gradient;
  21. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  22. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  23. import org.orekit.frames.FieldTransform;
  24. import org.orekit.frames.Transform;
  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.TimeSpanMap.Span;
  31. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  32. import org.orekit.utils.TimeStampedPVCoordinates;

  33. /** Class modeling one-way or two-way range rate measurement between two vehicles.
  34.  * One-way range rate (or Doppler) measurements generally apply to specific satellites
  35.  * (e.g. GNSS, DORIS), where a signal is transmitted from a satellite to a
  36.  * measuring station.
  37.  * Two-way range rate measurements are applicable to any system. The signal is
  38.  * transmitted to the (non-spinning) satellite and returned by a transponder
  39.  * (or reflected back)to the same measuring station.
  40.  * The Doppler measurement can be obtained by multiplying the velocity by (fe/c), where
  41.  * fe is the emission frequency.
  42.  *
  43.  * @author Thierry Ceolin
  44.  * @author Joris Olympio
  45.  * @since 8.0
  46.  */
  47. public class RangeRate extends GroundReceiverMeasurement<RangeRate> {

  48.     /** Type of the measurement. */
  49.     public static final String MEASUREMENT_TYPE = "RangeRate";

  50.     /** Simple constructor.
  51.      * @param station ground station from which measurement is performed
  52.      * @param date date of the measurement
  53.      * @param rangeRate observed value, m/s
  54.      * @param sigma theoretical standard deviation
  55.      * @param baseWeight base weight
  56.      * @param twoway if true, this is a two-way measurement
  57.      * @param satellite satellite related to this measurement
  58.      * @since 9.3
  59.      */
  60.     public RangeRate(final GroundStation station, final AbsoluteDate date,
  61.                      final double rangeRate, final double sigma, final double baseWeight,
  62.                      final boolean twoway, final ObservableSatellite satellite) {
  63.         super(station, twoway, date, rangeRate, sigma, baseWeight, satellite);
  64.     }

  65.     /** {@inheritDoc} */
  66.     @Override
  67.     protected EstimatedMeasurementBase<RangeRate> theoreticalEvaluationWithoutDerivatives(final int iteration,
  68.                                                                                           final int evaluation,
  69.                                                                                           final SpacecraftState[] states) {

  70.         final GroundReceiverCommonParametersWithoutDerivatives common = computeCommonParametersWithout(states[0]);
  71.         final TimeStampedPVCoordinates transitPV = common.getTransitPV();

  72.         // one-way (downlink) range-rate
  73.         final EstimatedMeasurementBase<RangeRate> evalOneWay1 =
  74.                         oneWayTheoreticalEvaluation(iteration, evaluation, true,
  75.                                                     common.getStationDownlink(),
  76.                                                     transitPV,
  77.                                                     common.getTransitState());
  78.         final EstimatedMeasurementBase<RangeRate> estimated;
  79.         if (isTwoWay()) {
  80.             // one-way (uplink) light time correction
  81.             final Transform offsetToInertialApproxUplink =
  82.                             getStation().getOffsetToInertial(common.getState().getFrame(),
  83.                                                              common.getStationDownlink().getDate().shiftedBy(-2 * common.getTauD()),
  84.                                                              false);
  85.             final AbsoluteDate approxUplinkDate = offsetToInertialApproxUplink.getDate();

  86.             final TimeStampedPVCoordinates stationApproxUplink =
  87.                             offsetToInertialApproxUplink.transformPVCoordinates(new TimeStampedPVCoordinates(approxUplinkDate,
  88.                                                                                                              Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  89.             final double tauU = signalTimeOfFlightAdjustableEmitter(stationApproxUplink, transitPV.getPosition(),
  90.                                                                     transitPV.getDate(), common.getState().getFrame());

  91.             final TimeStampedPVCoordinates stationUplink =
  92.                             stationApproxUplink.shiftedBy(transitPV.getDate().durationFrom(approxUplinkDate) - tauU);

  93.             final EstimatedMeasurementBase<RangeRate> evalOneWay2 =
  94.                             oneWayTheoreticalEvaluation(iteration, evaluation, false,
  95.                                                         stationUplink, transitPV, common.getTransitState());

  96.             // combine uplink and downlink values
  97.             estimated = new EstimatedMeasurementBase<>(this, iteration, evaluation,
  98.                                                        evalOneWay1.getStates(),
  99.                                                        new TimeStampedPVCoordinates[] {
  100.                                                            evalOneWay2.getParticipants()[0],
  101.                                                            evalOneWay1.getParticipants()[0],
  102.                                                            evalOneWay1.getParticipants()[1]
  103.                                                        });
  104.             estimated.setEstimatedValue(0.5 * (evalOneWay1.getEstimatedValue()[0] + evalOneWay2.getEstimatedValue()[0]));

  105.         } else {
  106.             estimated = evalOneWay1;
  107.         }

  108.         return estimated;

  109.     }

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

  114.         final SpacecraftState state = states[0];

  115.         // Range-rate derivatives are computed with respect to spacecraft state in inertial frame
  116.         // and station position in station's offset frame
  117.         // -------
  118.         //
  119.         // Parameters:
  120.         //  - 0..2 - Position of the spacecraft in inertial frame
  121.         //  - 3..5 - Velocity of the spacecraft in inertial frame
  122.         //  - 6..n - station parameters (clock offset, clock drift, station offsets, pole, prime meridian...)
  123.         final GroundReceiverCommonParametersWithDerivatives common = computeCommonParametersWithDerivatives(state);
  124.         final int nbParams = common.getTauD().getFreeParameters();
  125.         final TimeStampedFieldPVCoordinates<Gradient> transitPV = common.getTransitPV();

  126.         // one-way (downlink) range-rate
  127.         final EstimatedMeasurement<RangeRate> evalOneWay1 =
  128.                         oneWayTheoreticalEvaluation(iteration, evaluation, true,
  129.                                                     common.getStationDownlink(), transitPV,
  130.                                                     common.getTransitState(), common.getIndices(), nbParams);
  131.         final EstimatedMeasurement<RangeRate> estimated;
  132.         if (isTwoWay()) {
  133.             // one-way (uplink) light time correction
  134.             final FieldTransform<Gradient> offsetToInertialApproxUplink =
  135.                             getStation().getOffsetToInertial(state.getFrame(),
  136.                                                              common.getStationDownlink().getDate().shiftedBy(common.getTauD().multiply(-2)),
  137.                                                              nbParams, common.getIndices());
  138.             final FieldAbsoluteDate<Gradient> approxUplinkDateDS =
  139.                             offsetToInertialApproxUplink.getFieldDate();

  140.             final FieldVector3D<Gradient> zero = FieldVector3D.getZero(common.getTauD().getField());
  141.             final TimeStampedFieldPVCoordinates<Gradient> stationApproxUplink =
  142.                             offsetToInertialApproxUplink.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxUplinkDateDS,
  143.                                                                                                                     zero, zero, zero));

  144.             final Gradient tauU = signalTimeOfFlightAdjustableEmitter(stationApproxUplink, transitPV.getPosition(), transitPV.getDate(),
  145.                                                                       state.getFrame());

  146.             final TimeStampedFieldPVCoordinates<Gradient> stationUplink =
  147.                             stationApproxUplink.shiftedBy(transitPV.getDate().durationFrom(approxUplinkDateDS).subtract(tauU));

  148.             final EstimatedMeasurement<RangeRate> evalOneWay2 =
  149.                             oneWayTheoreticalEvaluation(iteration, evaluation, false,
  150.                                                         stationUplink, transitPV, common.getTransitState(),
  151.                                                         common.getIndices(), nbParams);

  152.             // combine uplink and downlink values
  153.             estimated = new EstimatedMeasurement<>(this, iteration, evaluation,
  154.                                                    evalOneWay1.getStates(),
  155.                                                    new TimeStampedPVCoordinates[] {
  156.                                                        evalOneWay2.getParticipants()[0],
  157.                                                        evalOneWay1.getParticipants()[0],
  158.                                                        evalOneWay1.getParticipants()[1]
  159.                                                    });
  160.             estimated.setEstimatedValue(0.5 * (evalOneWay1.getEstimatedValue()[0] + evalOneWay2.getEstimatedValue()[0]));

  161.             // combine uplink and downlink partial derivatives with respect to state
  162.             final double[][] sd1 = evalOneWay1.getStateDerivatives(0);
  163.             final double[][] sd2 = evalOneWay2.getStateDerivatives(0);
  164.             final double[][] sd = new double[sd1.length][sd1[0].length];
  165.             for (int i = 0; i < sd.length; ++i) {
  166.                 for (int j = 0; j < sd[0].length; ++j) {
  167.                     sd[i][j] = 0.5 * (sd1[i][j] + sd2[i][j]);
  168.                 }
  169.             }
  170.             estimated.setStateDerivatives(0, sd);

  171.             // combine uplink and downlink partial derivatives with respect to parameters
  172.             evalOneWay1.getDerivativesDrivers().forEach(driver -> {
  173.                 for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
  174.                     final double[] pd1 = evalOneWay1.getParameterDerivatives(driver, span.getStart());
  175.                     final double[] pd2 = evalOneWay2.getParameterDerivatives(driver, span.getStart());
  176.                     final double[] pd = new double[pd1.length];
  177.                     for (int i = 0; i < pd.length; ++i) {
  178.                         pd[i] = 0.5 * (pd1[i] + pd2[i]);
  179.                     }
  180.                     estimated.setParameterDerivatives(driver, span.getStart(), pd);
  181.                 }
  182.             });

  183.         } else {
  184.             estimated = evalOneWay1;
  185.         }

  186.         return estimated;

  187.     }

  188.     /** Evaluate measurement in one-way without derivatives.
  189.      * @param iteration iteration number
  190.      * @param evaluation evaluations counter
  191.      * @param downlink indicator for downlink leg
  192.      * @param stationPV station coordinates when signal is at station
  193.      * @param transitPV spacecraft coordinates at onboard signal transit
  194.      * @param transitState orbital state at onboard signal transit
  195.      * @return theoretical value
  196.      * @since 12.0
  197.      */
  198.     private EstimatedMeasurementBase<RangeRate> oneWayTheoreticalEvaluation(final int iteration, final int evaluation, final boolean downlink,
  199.                                                                             final TimeStampedPVCoordinates stationPV,
  200.                                                                             final TimeStampedPVCoordinates transitPV,
  201.                                                                             final SpacecraftState transitState) {

  202.         // prepare the evaluation
  203.         final EstimatedMeasurementBase<RangeRate> estimated =
  204.                         new EstimatedMeasurementBase<>(this, iteration, evaluation,
  205.                                                        new SpacecraftState[] {
  206.                                                            transitState
  207.                                                        }, new TimeStampedPVCoordinates[] {
  208.                                                            downlink ? transitPV : stationPV,
  209.                                                            downlink ? stationPV : transitPV
  210.                                                        });

  211.         // range rate value
  212.         final Vector3D stationPosition  = stationPV.getPosition();
  213.         final Vector3D relativePosition = stationPosition.subtract(transitPV.getPosition());

  214.         final Vector3D stationVelocity  = stationPV.getVelocity();
  215.         final Vector3D relativeVelocity = stationVelocity.subtract(transitPV.getVelocity());

  216.         // radial direction
  217.         final Vector3D lineOfSight      = relativePosition.normalize();

  218.         // line of sight velocity
  219.         final double lineOfSightVelocity = Vector3D.dotProduct(relativeVelocity, lineOfSight);

  220.         // range rate
  221.         double rangeRate = lineOfSightVelocity;

  222.         if (!isTwoWay()) {
  223.             // clock drifts, taken in account only in case of one way
  224.             final ObservableSatellite satellite    = getSatellites().get(0);
  225.             final double              dtsDot       = satellite.getClockDriftDriver().getValue(transitState.getDate());
  226.             final double              dtgDot       = getStation().getClockDriftDriver().getValue(stationPV.getDate());

  227.             final double clockDriftBiais = (dtgDot - dtsDot) * Constants.SPEED_OF_LIGHT;

  228.             rangeRate = rangeRate + clockDriftBiais;
  229.         }

  230.         estimated.setEstimatedValue(rangeRate);

  231.         return estimated;

  232.     }

  233.     /** Evaluate measurement in one-way.
  234.      * @param iteration iteration number
  235.      * @param evaluation evaluations counter
  236.      * @param downlink indicator for downlink leg
  237.      * @param stationPV station coordinates when signal is at station
  238.      * @param transitPV spacecraft coordinates at onboard signal transit
  239.      * @param transitState orbital state at onboard signal transit
  240.      * @param indices indices of the estimated parameters in derivatives computations
  241.      * @param nbParams the number of estimated parameters in derivative computations
  242.      * @return theoretical value
  243.      */
  244.     private EstimatedMeasurement<RangeRate> oneWayTheoreticalEvaluation(final int iteration, final int evaluation, final boolean downlink,
  245.                                                                         final TimeStampedFieldPVCoordinates<Gradient> stationPV,
  246.                                                                         final TimeStampedFieldPVCoordinates<Gradient> transitPV,
  247.                                                                         final SpacecraftState transitState,
  248.                                                                         final Map<String, Integer> indices,
  249.                                                                         final int nbParams) {

  250.         // prepare the evaluation
  251.         final EstimatedMeasurement<RangeRate> estimated =
  252.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  253.                                                    new SpacecraftState[] {
  254.                                                        transitState
  255.                                                    }, new TimeStampedPVCoordinates[] {
  256.                                                        (downlink ? transitPV : stationPV).toTimeStampedPVCoordinates(),
  257.                                                        (downlink ? stationPV : transitPV).toTimeStampedPVCoordinates()
  258.                                                    });

  259.         // range rate value
  260.         final FieldVector3D<Gradient> stationPosition  = stationPV.getPosition();
  261.         final FieldVector3D<Gradient> relativePosition = stationPosition.subtract(transitPV.getPosition());

  262.         final FieldVector3D<Gradient> stationVelocity  = stationPV.getVelocity();
  263.         final FieldVector3D<Gradient> relativeVelocity = stationVelocity.subtract(transitPV.getVelocity());

  264.         // radial direction
  265.         final FieldVector3D<Gradient> lineOfSight      = relativePosition.normalize();

  266.         // line of sight velocity
  267.         final Gradient lineOfSightVelocity = FieldVector3D.dotProduct(relativeVelocity, lineOfSight);

  268.         // range rate
  269.         Gradient rangeRate = lineOfSightVelocity;

  270.         if (!isTwoWay()) {
  271.             // clock drifts, taken in account only in case of one way
  272.             final ObservableSatellite satellite    = getSatellites().get(0);
  273.             final Gradient            dtsDot       = satellite.getClockDriftDriver().getValue(nbParams, indices, transitState.getDate());
  274.             final Gradient            dtgDot       = getStation().getClockDriftDriver().getValue(nbParams, indices, stationPV.getDate().toAbsoluteDate());

  275.             final Gradient clockDriftBiais = dtgDot.subtract(dtsDot).multiply(Constants.SPEED_OF_LIGHT);

  276.             rangeRate = rangeRate.add(clockDriftBiais);
  277.         }

  278.         estimated.setEstimatedValue(rangeRate.getValue());

  279.         // compute first order derivatives of (rr) with respect to spacecraft state Cartesian coordinates
  280.         final double[] derivatives = rangeRate.getGradient();
  281.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0, 6));

  282.         // Set first order derivatives with respect to parameters
  283.         for (final ParameterDriver driver : getParametersDrivers()) {
  284.             for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
  285.                 final Integer index = indices.get(span.getData());
  286.                 if (index != null) {
  287.                     estimated.setParameterDerivatives(driver, span.getStart(), derivatives[index]);
  288.                 }
  289.             }
  290.         }

  291.         return estimated;

  292.     }

  293. }