TurnAroundRange.java

  1. /* Copyright 2002-2019 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.HashMap;
  20. import java.util.Map;

  21. import org.hipparchus.Field;
  22. import org.hipparchus.analysis.differentiation.DSFactory;
  23. import org.hipparchus.analysis.differentiation.DerivativeStructure;
  24. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  25. import org.orekit.frames.FieldTransform;
  26. import org.orekit.propagation.SpacecraftState;
  27. import org.orekit.time.AbsoluteDate;
  28. import org.orekit.time.FieldAbsoluteDate;
  29. import org.orekit.utils.Constants;
  30. import org.orekit.utils.FieldPVCoordinates;
  31. import org.orekit.utils.PVCoordinates;
  32. import org.orekit.utils.ParameterDriver;
  33. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  34. import org.orekit.utils.TimeStampedPVCoordinates;

  35. /** Class modeling a turn-around range measurement using a master ground station and a slave ground station.
  36.  * <p>
  37.  * The measurement is considered to be a signal:
  38.  * - Emitted from the master ground station
  39.  * - Reflected on the spacecraft
  40.  * - Reflected on the slave ground station
  41.  * - Reflected on the spacecraft again
  42.  * - Received on the master ground station
  43.  * Its value is the elapsed time between emission and reception
  44.  * divided by 2c were c is the speed of light.
  45.  * The motion of the stations and the spacecraft
  46.  * during the signal flight time are taken into account.
  47.  * The date of the measurement corresponds to the
  48.  * reception on ground of the reflected signal.
  49.  * </p>
  50.  * @author Thierry Ceolin
  51.  * @author Luc Maisonobe
  52.  * @author Maxime Journot
  53.  *
  54.  * @since 9.0
  55.  */
  56. public class TurnAroundRange extends AbstractMeasurement<TurnAroundRange> {

  57.     /** Master ground station from which measurement is performed. */
  58.     private final GroundStation masterStation;

  59.     /** Slave ground station reflecting the signal. */
  60.     private final GroundStation slaveStation;

  61.     /** Simple constructor.
  62.      * <p>
  63.      * This constructor uses 0 as the index of the propagator related
  64.      * to this measurement, thus being well suited for mono-satellite
  65.      * orbit determination.
  66.      * </p>
  67.      * @param masterStation ground station from which measurement is performed
  68.      * @param slaveStation ground station reflecting the signal
  69.      * @param date date of the measurement
  70.      * @param turnAroundRange observed value
  71.      * @param sigma theoretical standard deviation
  72.      * @param baseWeight base weight
  73.      * @deprecated as of 9.3, replaced by {@link #TurnAroundRange(GroundStation, GroundStation, AbsoluteDate,
  74.      * double, double, double, ObservableSatellite)}
  75.      */
  76.     @Deprecated
  77.     public TurnAroundRange(final GroundStation masterStation, final GroundStation slaveStation,
  78.                            final AbsoluteDate date, final double turnAroundRange,
  79.                            final double sigma, final double baseWeight) {
  80.         this(masterStation, slaveStation, date, turnAroundRange, sigma, baseWeight, new ObservableSatellite(0));
  81.     }

  82.     /** Simple constructor.
  83.      * @param masterStation ground station from which measurement is performed
  84.      * @param slaveStation ground station reflecting the signal
  85.      * @param date date of the measurement
  86.      * @param turnAroundRange observed value
  87.      * @param sigma theoretical standard deviation
  88.      * @param baseWeight base weight
  89.      * @param propagatorIndex index of the propagator related to this measurement
  90.      * @since 9.0
  91.      * @deprecated as of 9.3, replaced by {@link #TurnAroundRange(GroundStation, GroundStation, AbsoluteDate,
  92.      * double, double, double, ObservableSatellite)}
  93.      */
  94.     @Deprecated
  95.     public TurnAroundRange(final GroundStation masterStation, final GroundStation slaveStation,
  96.                            final AbsoluteDate date, final double turnAroundRange,
  97.                            final double sigma, final double baseWeight,
  98.                            final int propagatorIndex) {
  99.         this(masterStation, slaveStation, date, turnAroundRange, sigma, baseWeight, new ObservableSatellite(propagatorIndex));
  100.     }

  101.     /** Simple constructor.
  102.      * @param masterStation ground station from which measurement is performed
  103.      * @param slaveStation ground station reflecting the signal
  104.      * @param date date of the measurement
  105.      * @param turnAroundRange observed value
  106.      * @param sigma theoretical standard deviation
  107.      * @param baseWeight base weight
  108.      * @param satellite satellite related to this measurement
  109.      * @since 9.3
  110.      */
  111.     public TurnAroundRange(final GroundStation masterStation, final GroundStation slaveStation,
  112.                            final AbsoluteDate date, final double turnAroundRange,
  113.                            final double sigma, final double baseWeight,
  114.                            final ObservableSatellite satellite) {
  115.         super(date, turnAroundRange, sigma, baseWeight, Arrays.asList(satellite));
  116.         addParameterDriver(masterStation.getClockOffsetDriver());
  117.         addParameterDriver(masterStation.getEastOffsetDriver());
  118.         addParameterDriver(masterStation.getNorthOffsetDriver());
  119.         addParameterDriver(masterStation.getZenithOffsetDriver());
  120.         addParameterDriver(masterStation.getPrimeMeridianOffsetDriver());
  121.         addParameterDriver(masterStation.getPrimeMeridianDriftDriver());
  122.         addParameterDriver(masterStation.getPolarOffsetXDriver());
  123.         addParameterDriver(masterStation.getPolarDriftXDriver());
  124.         addParameterDriver(masterStation.getPolarOffsetYDriver());
  125.         addParameterDriver(masterStation.getPolarDriftYDriver());
  126.         // the slave station clock is not used at all, we ignore the corresponding parameter driver
  127.         addParameterDriver(slaveStation.getEastOffsetDriver());
  128.         addParameterDriver(slaveStation.getNorthOffsetDriver());
  129.         addParameterDriver(slaveStation.getZenithOffsetDriver());
  130.         addParameterDriver(slaveStation.getPrimeMeridianOffsetDriver());
  131.         addParameterDriver(slaveStation.getPrimeMeridianDriftDriver());
  132.         addParameterDriver(slaveStation.getPolarOffsetXDriver());
  133.         addParameterDriver(slaveStation.getPolarDriftXDriver());
  134.         addParameterDriver(slaveStation.getPolarOffsetYDriver());
  135.         addParameterDriver(slaveStation.getPolarDriftYDriver());
  136.         this.masterStation = masterStation;
  137.         this.slaveStation = slaveStation;
  138.     }

  139.     /** Get the master ground station from which measurement is performed.
  140.      * @return master ground station from which measurement is performed
  141.      */
  142.     public GroundStation getMasterStation() {
  143.         return masterStation;
  144.     }

  145.     /** Get the slave ground station reflecting the signal.
  146.      * @return slave ground station reflecting the signal
  147.      */
  148.     public GroundStation getSlaveStation() {
  149.         return slaveStation;
  150.     }

  151.     /** {@inheritDoc} */
  152.     @Override
  153.     protected EstimatedMeasurement<TurnAroundRange> theoreticalEvaluation(final int iteration, final int evaluation,
  154.                                                                           final SpacecraftState[] states) {

  155.         final ObservableSatellite satellite = getSatellites().get(0);
  156.         final SpacecraftState     state     = states[satellite.getPropagatorIndex()];

  157.         // Turn around range derivatives are computed with respect to:
  158.         // - Spacecraft state in inertial frame
  159.         // - Master station parameters
  160.         // - Slave station parameters
  161.         // --------------------------
  162.         //
  163.         //  - 0..2 - Position of the spacecraft in inertial frame
  164.         //  - 3..5 - Velocity of the spacecraft in inertial frame
  165.         //  - 6..n - stations' parameters (clock offset, station offsets, pole, prime meridian...)
  166.         int nbParams = 6;
  167.         final Map<String, Integer> indices = new HashMap<>();
  168.         for (ParameterDriver driver : getParametersDrivers()) {
  169.             // we have to check for duplicate keys because master and slave station share
  170.             // pole and prime meridian parameters names that must be considered
  171.             // as one set only (they are combined together by the estimation engine)
  172.             if (driver.isSelected() && !indices.containsKey(driver.getName())) {
  173.                 indices.put(driver.getName(), nbParams++);
  174.             }
  175.         }
  176.         final DSFactory                          factory = new DSFactory(nbParams, 1);
  177.         final Field<DerivativeStructure>         field   = factory.getDerivativeField();
  178.         final FieldVector3D<DerivativeStructure> zero    = FieldVector3D.getZero(field);

  179.         // Place the derivative structures in a time-stamped PV
  180.         final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaDS = getCoordinates(state, 0, factory);

  181.         // The path of the signal is divided in two legs.
  182.         // Leg1: Emission from master station to satellite in masterTauU seconds
  183.         //     + Reflection from satellite to slave station in slaveTauD seconds
  184.         // Leg2: Reflection from slave station to satellite in slaveTauU seconds
  185.         //     + Reflection from satellite to master station in masterTaudD seconds
  186.         // The measurement is considered to be time stamped at reception on ground
  187.         // by the master station. All times are therefore computed as backward offsets
  188.         // with respect to this reception time.
  189.         //
  190.         // Two intermediate spacecraft states are defined:
  191.         //  - transitStateLeg2: State of the satellite when it bounced back the signal
  192.         //                      from slave station to master station during the 2nd leg
  193.         //  - transitStateLeg1: State of the satellite when it bounced back the signal
  194.         //                      from master station to slave station during the 1st leg

  195.         // Compute propagation time for the 2nd leg of the signal path
  196.         // --

  197.         // Time difference between t (date of the measurement) and t' (date tagged in spacecraft state)
  198.         // (if state has already been set up to pre-compensate propagation delay,
  199.         // we will have delta = masterTauD + slaveTauU)
  200.         final double delta = getDate().durationFrom(state.getDate());

  201.         // transform between master station topocentric frame (east-north-zenith) and inertial frame expressed as DerivativeStructures
  202.         final FieldTransform<DerivativeStructure> masterToInert =
  203.                         masterStation.getOffsetToInertial(state.getFrame(), getDate(), factory, indices);
  204.         final FieldAbsoluteDate<DerivativeStructure> measurementDateDS =
  205.                         masterToInert.getFieldDate();

  206.         // Master station PV in inertial frame at measurement date
  207.         final TimeStampedFieldPVCoordinates<DerivativeStructure> masterArrival =
  208.                         masterToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(measurementDateDS,
  209.                                                                                                  zero, zero, zero));

  210.         // Compute propagation times
  211.         final DerivativeStructure masterTauD = signalTimeOfFlight(pvaDS, masterArrival.getPosition(), measurementDateDS);

  212.         // Elapsed time between state date t' and signal arrival to the transit state of the 2nd leg
  213.         final DerivativeStructure dtLeg2 = masterTauD.negate().add(delta);

  214.         // Transit state where the satellite reflected the signal from slave to master station
  215.         final SpacecraftState transitStateLeg2 = state.shiftedBy(dtLeg2.getValue());

  216.         // Transit state pv of leg2 (re)computed with derivative structures
  217.         final TimeStampedFieldPVCoordinates<DerivativeStructure> transitStateLeg2PV = pvaDS.shiftedBy(dtLeg2);

  218.         // transform between slave station topocentric frame (east-north-zenith) and inertial frame expressed as DerivativeStructures
  219.         // The components of slave station's position in offset frame are the 3 last derivative parameters
  220.         final FieldAbsoluteDate<DerivativeStructure> approxReboundDate = measurementDateDS.shiftedBy(-delta);
  221.         final FieldTransform<DerivativeStructure> slaveToInertApprox =
  222.                         slaveStation.getOffsetToInertial(state.getFrame(), approxReboundDate, factory, indices);

  223.         // Slave station PV in inertial frame at approximate rebound date on slave station
  224.         final TimeStampedFieldPVCoordinates<DerivativeStructure> QSlaveApprox =
  225.                         slaveToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxReboundDate,
  226.                                                                                                       zero, zero, zero));

  227.         // Uplink time of flight from slave station to transit state of leg2
  228.         final DerivativeStructure slaveTauU = signalTimeOfFlight(QSlaveApprox,
  229.                                                                  transitStateLeg2PV.getPosition(),
  230.                                                                  transitStateLeg2PV.getDate());

  231.         // Total time of flight for leg 2
  232.         final DerivativeStructure tauLeg2 = masterTauD.add(slaveTauU);

  233.         // Compute propagation time for the 1st leg of the signal path
  234.         // --

  235.         // Absolute date of rebound of the signal to slave station
  236.         final FieldAbsoluteDate<DerivativeStructure> reboundDateDS = measurementDateDS.shiftedBy(tauLeg2.negate());
  237.         final FieldTransform<DerivativeStructure> slaveToInert =
  238.                         slaveStation.getOffsetToInertial(state.getFrame(), reboundDateDS, factory, indices);

  239.         // Slave station PV in inertial frame at rebound date on slave station
  240.         final TimeStampedFieldPVCoordinates<DerivativeStructure> slaveRebound =
  241.                         slaveToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(reboundDateDS,
  242.                                                                                                 FieldPVCoordinates.getZero(field)));

  243.         // Downlink time of flight from transitStateLeg1 to slave station at rebound date
  244.         final DerivativeStructure slaveTauD = signalTimeOfFlight(transitStateLeg2PV,
  245.                                                                  slaveRebound.getPosition(),
  246.                                                                  reboundDateDS);


  247.         // Elapsed time between state date t' and signal arrival to the transit state of the 1st leg
  248.         final DerivativeStructure dtLeg1 = dtLeg2.subtract(slaveTauU).subtract(slaveTauD);

  249.         // Transit state pv of leg2 (re)computed with derivative structures
  250.         final TimeStampedFieldPVCoordinates<DerivativeStructure> transitStateLeg1PV = pvaDS.shiftedBy(dtLeg1);

  251.         // transform between master station topocentric frame (east-north-zenith) and inertial frame expressed as DerivativeStructures
  252.         // The components of master station's position in offset frame are the 3 third derivative parameters
  253.         final FieldAbsoluteDate<DerivativeStructure> approxEmissionDate =
  254.                         measurementDateDS.shiftedBy(-2 * (slaveTauU.getValue() + masterTauD.getValue()));
  255.         final FieldTransform<DerivativeStructure> masterToInertApprox =
  256.                         masterStation.getOffsetToInertial(state.getFrame(), approxEmissionDate, factory, indices);

  257.         // Master station PV in inertial frame at approximate emission date
  258.         final TimeStampedFieldPVCoordinates<DerivativeStructure> QMasterApprox =
  259.                         masterToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxEmissionDate,
  260.                                                                                                        zero, zero, zero));

  261.         // Uplink time of flight from master station to transit state of leg1
  262.         final DerivativeStructure masterTauU = signalTimeOfFlight(QMasterApprox,
  263.                                                                   transitStateLeg1PV.getPosition(),
  264.                                                                   transitStateLeg1PV.getDate());

  265.         // Master station PV in inertial frame at exact emission date
  266.         final AbsoluteDate emissionDate = transitStateLeg1PV.getDate().toAbsoluteDate().shiftedBy(-masterTauU.getValue());
  267.         final TimeStampedPVCoordinates masterDeparture =
  268.                         masterToInertApprox.shiftedBy(emissionDate.durationFrom(masterToInertApprox.getDate())).
  269.                         transformPVCoordinates(new TimeStampedPVCoordinates(emissionDate, PVCoordinates.ZERO)).
  270.                         toTimeStampedPVCoordinates();

  271.         // Total time of flight for leg 1
  272.         final DerivativeStructure tauLeg1 = slaveTauD.add(masterTauU);


  273.         // --
  274.         // Evaluate the turn-around range value and its derivatives
  275.         // --------------------------------------------------------

  276.         // The state we use to define the estimated measurement is a middle ground between the two transit states
  277.         // This is done to avoid calling "SpacecraftState.shiftedBy" function on long duration
  278.         // Thus we define the state at the date t" = date of rebound of the signal at the slave station
  279.         // Or t" = t -masterTauD -slaveTauU
  280.         // The iterative process in the estimation ensures that, after several iterations, the date stamped in the
  281.         // state S in input of this function will be close to t"
  282.         // Therefore we will shift state S by:
  283.         //  - +slaveTauU to get transitStateLeg2
  284.         //  - -slaveTauD to get transitStateLeg1
  285.         final EstimatedMeasurement<TurnAroundRange> estimated =
  286.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  287.                                                    new SpacecraftState[] {
  288.                                                        transitStateLeg2.shiftedBy(-slaveTauU.getValue())
  289.                                                    },
  290.                                                    new TimeStampedPVCoordinates[] {
  291.                                                        masterDeparture,
  292.                                                        transitStateLeg1PV.toTimeStampedPVCoordinates(),
  293.                                                        slaveRebound.toTimeStampedPVCoordinates(),
  294.                                                        transitStateLeg2.getPVCoordinates(),
  295.                                                        masterArrival.toTimeStampedPVCoordinates()
  296.                                                    });

  297.         // Turn-around range value = Total time of flight for the 2 legs divided by 2 and multiplied by c
  298.         final double cOver2 = 0.5 * Constants.SPEED_OF_LIGHT;
  299.         final DerivativeStructure turnAroundRange = (tauLeg2.add(tauLeg1)).multiply(cOver2);
  300.         estimated.setEstimatedValue(turnAroundRange.getValue());

  301.         // Turn-around range partial derivatives with respect to state
  302.         final double[] derivatives = turnAroundRange.getAllDerivatives();
  303.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 1, 7));

  304.         // set partial derivatives with respect to parameters
  305.         // (beware element at index 0 is the value, not a derivative)
  306.         for (final ParameterDriver driver : getParametersDrivers()) {
  307.             final Integer index = indices.get(driver.getName());
  308.             if (index != null) {
  309.                 estimated.setParameterDerivatives(driver, derivatives[index + 1]);
  310.             }
  311.         }

  312.         return estimated;

  313.     }

  314. }