TurnAroundRange.java

  1. /* Copyright 2002-2018 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.errors.OrekitException;
  26. import org.orekit.frames.FieldTransform;
  27. import org.orekit.propagation.SpacecraftState;
  28. import org.orekit.time.AbsoluteDate;
  29. import org.orekit.time.FieldAbsoluteDate;
  30. import org.orekit.utils.Constants;
  31. import org.orekit.utils.FieldPVCoordinates;
  32. import org.orekit.utils.PVCoordinates;
  33. import org.orekit.utils.ParameterDriver;
  34. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  35. import org.orekit.utils.TimeStampedPVCoordinates;

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

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

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

  62.     /** Simple constructor.
  63.      * <p>
  64.      * This constructor uses 0 as the index of the propagator related
  65.      * to this measurement, thus being well suited for mono-satellite
  66.      * orbit determination.
  67.      * </p>
  68.      * @param masterStation ground station from which measurement is performed
  69.      * @param slaveStation ground station reflecting the signal
  70.      * @param date date of the measurement
  71.      * @param turnAroundRange observed value
  72.      * @param sigma theoretical standard deviation
  73.      * @param baseWeight base weight
  74.      * @exception OrekitException if a {@link org.orekit.utils.ParameterDriver}
  75.      * name conflict occurs
  76.      */
  77.     public TurnAroundRange(final GroundStation masterStation, final GroundStation slaveStation,
  78.                            final AbsoluteDate date, final double turnAroundRange,
  79.                            final double sigma, final double baseWeight)
  80.         throws OrekitException {
  81.         this(masterStation, slaveStation, date, turnAroundRange, sigma, baseWeight, 0);
  82.     }

  83.     /** Simple constructor.
  84.      * @param masterStation ground station from which measurement is performed
  85.      * @param slaveStation ground station reflecting the signal
  86.      * @param date date of the measurement
  87.      * @param turnAroundRange observed value
  88.      * @param sigma theoretical standard deviation
  89.      * @param baseWeight base weight
  90.      * @param propagatorIndex index of the propagator related to this measurement
  91.      * @exception OrekitException if a {@link org.orekit.utils.ParameterDriver}
  92.      * name conflict occurs
  93.      * @since 9.0
  94.      */
  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.         throws OrekitException {
  100.         super(date, turnAroundRange, sigma, baseWeight, Arrays.asList(propagatorIndex),
  101.               masterStation.getEastOffsetDriver(),
  102.               masterStation.getNorthOffsetDriver(),
  103.               masterStation.getZenithOffsetDriver(),
  104.               masterStation.getPrimeMeridianOffsetDriver(),
  105.               masterStation.getPrimeMeridianDriftDriver(),
  106.               masterStation.getPolarOffsetXDriver(),
  107.               masterStation.getPolarDriftXDriver(),
  108.               masterStation.getPolarOffsetYDriver(),
  109.               masterStation.getPolarDriftYDriver(),
  110.               slaveStation.getEastOffsetDriver(),
  111.               slaveStation.getNorthOffsetDriver(),
  112.               slaveStation.getZenithOffsetDriver(),
  113.               slaveStation.getPrimeMeridianOffsetDriver(),
  114.               slaveStation.getPrimeMeridianDriftDriver(),
  115.               slaveStation.getPolarOffsetXDriver(),
  116.               slaveStation.getPolarDriftXDriver(),
  117.               slaveStation.getPolarOffsetYDriver(),
  118.               slaveStation.getPolarDriftYDriver());
  119.         this.masterStation = masterStation;
  120.         this.slaveStation = slaveStation;
  121.     }

  122.     /** Get the master ground station from which measurement is performed.
  123.      * @return master ground station from which measurement is performed
  124.      */
  125.     public GroundStation getMasterStation() {
  126.         return masterStation;
  127.     }

  128.     /** Get the slave ground station reflecting the signal.
  129.      * @return slave ground station reflecting the signal
  130.      */
  131.     public GroundStation getSlaveStation() {
  132.         return slaveStation;
  133.     }

  134.     /** {@inheritDoc} */
  135.     @Override
  136.     protected EstimatedMeasurement<TurnAroundRange> theoreticalEvaluation(final int iteration, final int evaluation,
  137.                                                                           final SpacecraftState[] states)
  138.         throws OrekitException {

  139.         final SpacecraftState state = states[getPropagatorsIndices().get(0)];

  140.         // Turn around range derivatives are computed with respect to:
  141.         // - Spacecraft state in inertial frame
  142.         // - Master station parameters
  143.         // - Slave station parameters
  144.         // --------------------------
  145.         //
  146.         //  - 0..2 - Position of the spacecraft in inertial frame
  147.         //  - 3..5 - Velocity of the spacecraft in inertial frame
  148.         //  - 6..n - stations' parameters (stations' offsets, pole, prime meridian...)
  149.         int nbParams = 6;
  150.         final Map<String, Integer> indices = new HashMap<>();
  151.         for (ParameterDriver driver : getParametersDrivers()) {
  152.             // we have to check for duplicate keys because master and slave station share
  153.             // pole and prime meridian parameters names that must be considered
  154.             // as one set only (they are combined together by the estimation engine)
  155.             if (driver.isSelected() && !indices.containsKey(driver.getName())) {
  156.                 indices.put(driver.getName(), nbParams++);
  157.             }
  158.         }
  159.         final DSFactory                          factory = new DSFactory(nbParams, 1);
  160.         final Field<DerivativeStructure>         field   = factory.getDerivativeField();
  161.         final FieldVector3D<DerivativeStructure> zero    = FieldVector3D.getZero(field);

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

  164.         // The path of the signal is divided in two legs.
  165.         // Leg1: Emission from master station to satellite in masterTauU seconds
  166.         //     + Reflection from satellite to slave station in slaveTauD seconds
  167.         // Leg2: Reflection from slave station to satellite in slaveTauU seconds
  168.         //     + Reflection from satellite to master station in masterTaudD seconds
  169.         // The measurement is considered to be time stamped at reception on ground
  170.         // by the master station. All times are therefore computed as backward offsets
  171.         // with respect to this reception time.
  172.         //
  173.         // Two intermediate spacecraft states are defined:
  174.         //  - transitStateLeg2: State of the satellite when it bounced back the signal
  175.         //                      from slave station to master station during the 2nd leg
  176.         //  - transitStateLeg1: State of the satellite when it bounced back the signal
  177.         //                      from master station to slave station during the 1st leg

  178.         // Compute propagation time for the 2nd leg of the signal path
  179.         // --

  180.         // Time difference between t (date of the measurement) and t' (date tagged in spacecraft state)
  181.         // (if state has already been set up to pre-compensate propagation delay,
  182.         // we will have delta = masterTauD + slaveTauU)
  183.         final AbsoluteDate measurementDate = getDate();
  184.         final FieldAbsoluteDate<DerivativeStructure> measurementDateDS = new FieldAbsoluteDate<>(field, measurementDate);
  185.         final double delta = measurementDate.durationFrom(state.getDate());

  186.         // transform between master station topocentric frame (east-north-zenith) and inertial frame expressed as DerivativeStructures
  187.         final FieldTransform<DerivativeStructure> masterToInert =
  188.                         masterStation.getOffsetToInertial(state.getFrame(), measurementDateDS, factory, indices);

  189.         // Master station PV in inertial frame at measurement date
  190.         final TimeStampedFieldPVCoordinates<DerivativeStructure> masterArrival =
  191.                         masterToInert.transformPVCoordinates(new TimeStampedPVCoordinates(measurementDate,
  192.                                                                                           PVCoordinates.ZERO));

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

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

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

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

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

  206.         // Slave station PV in inertial frame at approximate rebound date on slave station
  207.         final TimeStampedFieldPVCoordinates<DerivativeStructure> QSlaveApprox =
  208.                         slaveToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxReboundDate,
  209.                                                                                                       zero, zero, zero));

  210.         // Uplink time of flight from slave station to transit state of leg2
  211.         final DerivativeStructure slaveTauU = signalTimeOfFlight(QSlaveApprox,
  212.                                                                  transitStateLeg2PV.getPosition(),
  213.                                                                  transitStateLeg2PV.getDate());

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

  216.         // Compute propagation time for the 1st leg of the signal path
  217.         // --

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

  222.         // Slave station PV in inertial frame at rebound date on slave station
  223.         final TimeStampedFieldPVCoordinates<DerivativeStructure> slaveRebound =
  224.                         slaveToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(reboundDateDS,
  225.                                                                                                 FieldPVCoordinates.getZero(field)));

  226.         // Downlink time of flight from transitStateLeg1 to slave station at rebound date
  227.         final DerivativeStructure slaveTauD = signalTimeOfFlight(transitStateLeg2PV,
  228.                                                                  slaveRebound.getPosition(),
  229.                                                                  reboundDateDS);


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

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

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

  240.         // Master station PV in inertial frame at approximate emission date
  241.         final TimeStampedFieldPVCoordinates<DerivativeStructure> QMasterApprox =
  242.                         masterToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxEmissionDate,
  243.                                                                                                        zero, zero, zero));

  244.         // Uplink time of flight from master station to transit state of leg1
  245.         final DerivativeStructure masterTauU = signalTimeOfFlight(QMasterApprox,
  246.                                                                   transitStateLeg1PV.getPosition(),
  247.                                                                   transitStateLeg1PV.getDate());

  248.         // Master station PV in inertial frame at exact emission date
  249.         final AbsoluteDate emissionDate = transitStateLeg1PV.getDate().toAbsoluteDate().shiftedBy(-masterTauU.getValue());
  250.         final TimeStampedPVCoordinates masterDeparture =
  251.                         masterToInertApprox.shiftedBy(emissionDate.durationFrom(masterToInertApprox.getDate())).
  252.                         transformPVCoordinates(new TimeStampedPVCoordinates(emissionDate, PVCoordinates.ZERO)).
  253.                         toTimeStampedPVCoordinates();

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


  256.         // --
  257.         // Evaluate the turn-around range value and its derivatives
  258.         // --------------------------------------------------------

  259.         // The state we use to define the estimated measurement is a middle ground between the two transit states
  260.         // This is done to avoid calling "SpacecraftState.shiftedBy" function on long duration
  261.         // Thus we define the state at the date t" = date of rebound of the signal at the slave station
  262.         // Or t" = t -masterTauD -slaveTauU
  263.         // The iterative process in the estimation ensures that, after several iterations, the date stamped in the
  264.         // state S in input of this function will be close to t"
  265.         // Therefore we will shift state S by:
  266.         //  - +slaveTauU to get transitStateLeg2
  267.         //  - -slaveTauD to get transitStateLeg1
  268.         final EstimatedMeasurement<TurnAroundRange> estimated =
  269.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  270.                                                    new SpacecraftState[] {
  271.                                                        transitStateLeg2.shiftedBy(-slaveTauU.getValue())
  272.                                                    },
  273.                                                    new TimeStampedPVCoordinates[] {
  274.                                                        masterDeparture,
  275.                                                        transitStateLeg1PV.toTimeStampedPVCoordinates(),
  276.                                                        slaveRebound.toTimeStampedPVCoordinates(),
  277.                                                        transitStateLeg2.getPVCoordinates(),
  278.                                                        masterArrival.toTimeStampedPVCoordinates()
  279.                                                    });

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

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

  287.         // set partial derivatives with respect to parameters
  288.         // (beware element at index 0 is the value, not a derivative)
  289.         for (final ParameterDriver driver : getParametersDrivers()) {
  290.             final Integer index = indices.get(driver.getName());
  291.             if (index != null) {
  292.                 estimated.setParameterDerivatives(driver, derivatives[index + 1]);
  293.             }
  294.         }

  295.         return estimated;

  296.     }

  297. }