TurnAroundRange.java

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

  21. import org.hipparchus.Field;
  22. import org.hipparchus.analysis.differentiation.Gradient;
  23. import org.hipparchus.analysis.differentiation.GradientField;
  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.      * @param masterStation ground station from which measurement is performed
  63.      * @param slaveStation ground station reflecting the signal
  64.      * @param date date of the measurement
  65.      * @param turnAroundRange observed value
  66.      * @param sigma theoretical standard deviation
  67.      * @param baseWeight base weight
  68.      * @param satellite satellite related to this measurement
  69.      * @since 9.3
  70.      */
  71.     public TurnAroundRange(final GroundStation masterStation, final GroundStation slaveStation,
  72.                            final AbsoluteDate date, final double turnAroundRange,
  73.                            final double sigma, final double baseWeight,
  74.                            final ObservableSatellite satellite) {
  75.         super(date, turnAroundRange, sigma, baseWeight, Arrays.asList(satellite));
  76.         addParameterDriver(masterStation.getClockOffsetDriver());
  77.         addParameterDriver(masterStation.getEastOffsetDriver());
  78.         addParameterDriver(masterStation.getNorthOffsetDriver());
  79.         addParameterDriver(masterStation.getZenithOffsetDriver());
  80.         addParameterDriver(masterStation.getPrimeMeridianOffsetDriver());
  81.         addParameterDriver(masterStation.getPrimeMeridianDriftDriver());
  82.         addParameterDriver(masterStation.getPolarOffsetXDriver());
  83.         addParameterDriver(masterStation.getPolarDriftXDriver());
  84.         addParameterDriver(masterStation.getPolarOffsetYDriver());
  85.         addParameterDriver(masterStation.getPolarDriftYDriver());
  86.         // the slave station clock is not used at all, we ignore the corresponding parameter driver
  87.         addParameterDriver(slaveStation.getEastOffsetDriver());
  88.         addParameterDriver(slaveStation.getNorthOffsetDriver());
  89.         addParameterDriver(slaveStation.getZenithOffsetDriver());
  90.         addParameterDriver(slaveStation.getPrimeMeridianOffsetDriver());
  91.         addParameterDriver(slaveStation.getPrimeMeridianDriftDriver());
  92.         addParameterDriver(slaveStation.getPolarOffsetXDriver());
  93.         addParameterDriver(slaveStation.getPolarDriftXDriver());
  94.         addParameterDriver(slaveStation.getPolarOffsetYDriver());
  95.         addParameterDriver(slaveStation.getPolarDriftYDriver());
  96.         this.masterStation = masterStation;
  97.         this.slaveStation = slaveStation;
  98.     }

  99.     /** Get the master ground station from which measurement is performed.
  100.      * @return master ground station from which measurement is performed
  101.      */
  102.     public GroundStation getMasterStation() {
  103.         return masterStation;
  104.     }

  105.     /** Get the slave ground station reflecting the signal.
  106.      * @return slave ground station reflecting the signal
  107.      */
  108.     public GroundStation getSlaveStation() {
  109.         return slaveStation;
  110.     }

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

  115.         final SpacecraftState state = states[0];

  116.         // Turn around range derivatives are computed with respect to:
  117.         // - Spacecraft state in inertial frame
  118.         // - Master station parameters
  119.         // - Slave station parameters
  120.         // --------------------------
  121.         //
  122.         //  - 0..2 - Position of the spacecraft in inertial frame
  123.         //  - 3..5 - Velocity of the spacecraft in inertial frame
  124.         //  - 6..n - stations' parameters (clock offset, station offsets, pole, prime meridian...)
  125.         int nbParams = 6;
  126.         final Map<String, Integer> indices = new HashMap<>();
  127.         for (ParameterDriver driver : getParametersDrivers()) {
  128.             // we have to check for duplicate keys because master and slave station share
  129.             // pole and prime meridian parameters names that must be considered
  130.             // as one set only (they are combined together by the estimation engine)
  131.             if (driver.isSelected() && !indices.containsKey(driver.getName())) {
  132.                 indices.put(driver.getName(), nbParams++);
  133.             }
  134.         }
  135.         final Field<Gradient>         field   = GradientField.getField(nbParams);
  136.         final FieldVector3D<Gradient> zero    = FieldVector3D.getZero(field);

  137.         // Place the gradient in a time-stamped PV
  138.         final TimeStampedFieldPVCoordinates<Gradient> pvaDS = getCoordinates(state, 0, nbParams);

  139.         // The path of the signal is divided in two legs.
  140.         // Leg1: Emission from master station to satellite in masterTauU seconds
  141.         //     + Reflection from satellite to slave station in slaveTauD seconds
  142.         // Leg2: Reflection from slave station to satellite in slaveTauU seconds
  143.         //     + Reflection from satellite to master station in masterTaudD seconds
  144.         // The measurement is considered to be time stamped at reception on ground
  145.         // by the master station. All times are therefore computed as backward offsets
  146.         // with respect to this reception time.
  147.         //
  148.         // Two intermediate spacecraft states are defined:
  149.         //  - transitStateLeg2: State of the satellite when it bounced back the signal
  150.         //                      from slave station to master station during the 2nd leg
  151.         //  - transitStateLeg1: State of the satellite when it bounced back the signal
  152.         //                      from master station to slave station during the 1st leg

  153.         // Compute propagation time for the 2nd leg of the signal path
  154.         // --

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

  159.         // transform between master station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  160.         final FieldTransform<Gradient> masterToInert =
  161.                         masterStation.getOffsetToInertial(state.getFrame(), getDate(), nbParams, indices);
  162.         final FieldAbsoluteDate<Gradient> measurementDateDS =
  163.                         masterToInert.getFieldDate();

  164.         // Master station PV in inertial frame at measurement date
  165.         final TimeStampedFieldPVCoordinates<Gradient> masterArrival =
  166.                         masterToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(measurementDateDS,
  167.                                                                                                  zero, zero, zero));

  168.         // Compute propagation times
  169.         final Gradient masterTauD = signalTimeOfFlight(pvaDS, masterArrival.getPosition(), measurementDateDS);

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

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

  174.         // Transit state pv of leg2 (re)computed with gradient
  175.         final TimeStampedFieldPVCoordinates<Gradient> transitStateLeg2PV = pvaDS.shiftedBy(dtLeg2);

  176.         // transform between slave station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  177.         // The components of slave station's position in offset frame are the 3 last derivative parameters
  178.         final FieldAbsoluteDate<Gradient> approxReboundDate = measurementDateDS.shiftedBy(-delta);
  179.         final FieldTransform<Gradient> slaveToInertApprox =
  180.                         slaveStation.getOffsetToInertial(state.getFrame(), approxReboundDate, nbParams, indices);

  181.         // Slave station PV in inertial frame at approximate rebound date on slave station
  182.         final TimeStampedFieldPVCoordinates<Gradient> QSlaveApprox =
  183.                         slaveToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxReboundDate,
  184.                                                                                                       zero, zero, zero));

  185.         // Uplink time of flight from slave station to transit state of leg2
  186.         final Gradient slaveTauU = signalTimeOfFlight(QSlaveApprox,
  187.                                                       transitStateLeg2PV.getPosition(),
  188.                                                       transitStateLeg2PV.getDate());

  189.         // Total time of flight for leg 2
  190.         final Gradient tauLeg2 = masterTauD.add(slaveTauU);

  191.         // Compute propagation time for the 1st leg of the signal path
  192.         // --

  193.         // Absolute date of rebound of the signal to slave station
  194.         final FieldAbsoluteDate<Gradient> reboundDateDS = measurementDateDS.shiftedBy(tauLeg2.negate());
  195.         final FieldTransform<Gradient> slaveToInert =
  196.                         slaveStation.getOffsetToInertial(state.getFrame(), reboundDateDS, nbParams, indices);

  197.         // Slave station PV in inertial frame at rebound date on slave station
  198.         final TimeStampedFieldPVCoordinates<Gradient> slaveRebound =
  199.                         slaveToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(reboundDateDS,
  200.                                                                                                 FieldPVCoordinates.getZero(field)));

  201.         // Downlink time of flight from transitStateLeg1 to slave station at rebound date
  202.         final Gradient slaveTauD = signalTimeOfFlight(transitStateLeg2PV,
  203.                                                       slaveRebound.getPosition(),
  204.                                                       reboundDateDS);


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

  207.         // Transit state pv of leg2 (re)computed with gradients
  208.         final TimeStampedFieldPVCoordinates<Gradient> transitStateLeg1PV = pvaDS.shiftedBy(dtLeg1);

  209.         // transform between master station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  210.         // The components of master station's position in offset frame are the 3 third derivative parameters
  211.         final FieldAbsoluteDate<Gradient> approxEmissionDate =
  212.                         measurementDateDS.shiftedBy(-2 * (slaveTauU.getValue() + masterTauD.getValue()));
  213.         final FieldTransform<Gradient> masterToInertApprox =
  214.                         masterStation.getOffsetToInertial(state.getFrame(), approxEmissionDate, nbParams, indices);

  215.         // Master station PV in inertial frame at approximate emission date
  216.         final TimeStampedFieldPVCoordinates<Gradient> QMasterApprox =
  217.                         masterToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxEmissionDate,
  218.                                                                                                        zero, zero, zero));

  219.         // Uplink time of flight from master station to transit state of leg1
  220.         final Gradient masterTauU = signalTimeOfFlight(QMasterApprox,
  221.                                                        transitStateLeg1PV.getPosition(),
  222.                                                        transitStateLeg1PV.getDate());

  223.         // Master station PV in inertial frame at exact emission date
  224.         final AbsoluteDate emissionDate = transitStateLeg1PV.getDate().toAbsoluteDate().shiftedBy(-masterTauU.getValue());
  225.         final TimeStampedPVCoordinates masterDeparture =
  226.                         masterToInertApprox.shiftedBy(emissionDate.durationFrom(masterToInertApprox.getDate())).
  227.                         transformPVCoordinates(new TimeStampedPVCoordinates(emissionDate, PVCoordinates.ZERO)).
  228.                         toTimeStampedPVCoordinates();

  229.         // Total time of flight for leg 1
  230.         final Gradient tauLeg1 = slaveTauD.add(masterTauU);


  231.         // --
  232.         // Evaluate the turn-around range value and its derivatives
  233.         // --------------------------------------------------------

  234.         // The state we use to define the estimated measurement is a middle ground between the two transit states
  235.         // This is done to avoid calling "SpacecraftState.shiftedBy" function on long duration
  236.         // Thus we define the state at the date t" = date of rebound of the signal at the slave station
  237.         // Or t" = t -masterTauD -slaveTauU
  238.         // The iterative process in the estimation ensures that, after several iterations, the date stamped in the
  239.         // state S in input of this function will be close to t"
  240.         // Therefore we will shift state S by:
  241.         //  - +slaveTauU to get transitStateLeg2
  242.         //  - -slaveTauD to get transitStateLeg1
  243.         final EstimatedMeasurement<TurnAroundRange> estimated =
  244.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  245.                                                    new SpacecraftState[] {
  246.                                                        transitStateLeg2.shiftedBy(-slaveTauU.getValue())
  247.                                                    },
  248.                                                    new TimeStampedPVCoordinates[] {
  249.                                                        masterDeparture,
  250.                                                        transitStateLeg1PV.toTimeStampedPVCoordinates(),
  251.                                                        slaveRebound.toTimeStampedPVCoordinates(),
  252.                                                        transitStateLeg2.getPVCoordinates(),
  253.                                                        masterArrival.toTimeStampedPVCoordinates()
  254.                                                    });

  255.         // Turn-around range value = Total time of flight for the 2 legs divided by 2 and multiplied by c
  256.         final double cOver2 = 0.5 * Constants.SPEED_OF_LIGHT;
  257.         final Gradient turnAroundRange = (tauLeg2.add(tauLeg1)).multiply(cOver2);
  258.         estimated.setEstimatedValue(turnAroundRange.getValue());

  259.         // Turn-around range partial derivatives with respect to state
  260.         final double[] derivatives = turnAroundRange.getGradient();
  261.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0, 6));

  262.         // set partial derivatives with respect to parameters
  263.         // (beware element at index 0 is the value, not a derivative)
  264.         for (final ParameterDriver driver : getParametersDrivers()) {
  265.             final Integer index = indices.get(driver.getName());
  266.             if (index != null) {
  267.                 estimated.setParameterDerivatives(driver, derivatives[index]);
  268.             }
  269.         }

  270.         return estimated;

  271.     }

  272. }