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

  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.hipparchus.geometry.euclidean.threed.Vector3D;
  26. import org.orekit.frames.FieldTransform;
  27. import org.orekit.frames.Transform;
  28. import org.orekit.propagation.SpacecraftState;
  29. import org.orekit.time.AbsoluteDate;
  30. import org.orekit.time.FieldAbsoluteDate;
  31. import org.orekit.utils.Constants;
  32. import org.orekit.utils.FieldPVCoordinates;
  33. import org.orekit.utils.PVCoordinates;
  34. import org.orekit.utils.ParameterDriver;
  35. import org.orekit.utils.TimeSpanMap.Span;
  36. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  37. import org.orekit.utils.TimeStampedPVCoordinates;

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

  60.     /** Type of the measurement. */
  61.     public static final String MEASUREMENT_TYPE = "TurnAroundRange";

  62.     /** Secondary ground station reflecting the signal. */
  63.     private final GroundStation secondaryStation;

  64.     /** Simple constructor.
  65.      * @param primaryStation ground station from which measurement is performed
  66.      * @param secondaryStation ground station reflecting the signal
  67.      * @param date date of the measurement
  68.      * @param turnAroundRange observed value
  69.      * @param sigma theoretical standard deviation
  70.      * @param baseWeight base weight
  71.      * @param satellite satellite related to this measurement
  72.      * @since 9.3
  73.      */
  74.     public TurnAroundRange(final GroundStation primaryStation, final GroundStation secondaryStation,
  75.                            final AbsoluteDate date, final double turnAroundRange,
  76.                            final double sigma, final double baseWeight,
  77.                            final ObservableSatellite satellite) {
  78.         super(primaryStation, true, date, turnAroundRange, sigma, baseWeight, satellite);

  79.         // the secondary station clock is not used at all, we ignore the corresponding parameter driver
  80.         addParameterDriver(secondaryStation.getEastOffsetDriver());
  81.         addParameterDriver(secondaryStation.getNorthOffsetDriver());
  82.         addParameterDriver(secondaryStation.getZenithOffsetDriver());
  83.         addParameterDriver(secondaryStation.getPrimeMeridianOffsetDriver());
  84.         addParameterDriver(secondaryStation.getPrimeMeridianDriftDriver());
  85.         addParameterDriver(secondaryStation.getPolarOffsetXDriver());
  86.         addParameterDriver(secondaryStation.getPolarDriftXDriver());
  87.         addParameterDriver(secondaryStation.getPolarOffsetYDriver());
  88.         addParameterDriver(secondaryStation.getPolarDriftYDriver());
  89.         this.secondaryStation = secondaryStation;

  90.     }

  91.     /** Get the primary ground station from which measurement is performed.
  92.      * @return primary ground station from which measurement is performed
  93.      */
  94.     public GroundStation getPrimaryStation() {
  95.         return getStation();
  96.     }

  97.     /** Get the secondary ground station reflecting the signal.
  98.      * @return secondary ground station reflecting the signal
  99.      */
  100.     public GroundStation getSecondaryStation() {
  101.         return secondaryStation;
  102.     }

  103.     /** {@inheritDoc} */
  104.     @Override
  105.     protected EstimatedMeasurementBase<TurnAroundRange> theoreticalEvaluationWithoutDerivatives(final int iteration,
  106.                                                                                                 final int evaluation,
  107.                                                                                                 final SpacecraftState[] states) {

  108.         final SpacecraftState state = states[0];

  109.         // Time-stamped PV
  110.         final TimeStampedPVCoordinates pva = state.getPVCoordinates();

  111.         // The path of the signal is divided in two legs.
  112.         // Leg1: Emission from primary station to satellite in primaryTauU seconds
  113.         //     + Reflection from satellite to secondary station in secondaryTauD seconds
  114.         // Leg2: Reflection from secondary station to satellite in secondaryTauU seconds
  115.         //     + Reflection from satellite to primary station in primaryTaudD seconds
  116.         // The measurement is considered to be time stamped at reception on ground
  117.         // by the primary station. All times are therefore computed as backward offsets
  118.         // with respect to this reception time.
  119.         //
  120.         // Two intermediate spacecraft states are defined:
  121.         //  - transitStateLeg2: State of the satellite when it bounced back the signal
  122.         //                      from secondary station to primary station during the 2nd leg
  123.         //  - transitStateLeg1: State of the satellite when it bounced back the signal
  124.         //                      from primary station to secondary station during the 1st leg

  125.         // Compute propagation time for the 2nd leg of the signal path
  126.         // --

  127.         // Time difference between t (date of the measurement) and t' (date tagged in spacecraft state)
  128.         // (if state has already been set up to pre-compensate propagation delay,
  129.         // we will have delta = primaryTauD + secondaryTauU)
  130.         final double delta = getDate().durationFrom(state.getDate());

  131.         // transform between primary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  132.         final Transform primaryToInert =
  133.                         getStation().getOffsetToInertial(state.getFrame(), getDate(), false);
  134.         final AbsoluteDate measurementDate = primaryToInert.getDate();

  135.         // Primary station PV in inertial frame at measurement date
  136.         final TimeStampedPVCoordinates primaryArrival =
  137.                         primaryToInert.transformPVCoordinates(new TimeStampedPVCoordinates(measurementDate,
  138.                                                                                            Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  139.         // Compute propagation times
  140.         final double primaryTauD = signalTimeOfFlight(pva, primaryArrival.getPosition(), measurementDate);

  141.         // Elapsed time between state date t' and signal arrival to the transit state of the 2nd leg
  142.         final double dtLeg2 = delta - primaryTauD;

  143.         // Transit state where the satellite reflected the signal from secondary to primary station
  144.         final SpacecraftState transitStateLeg2 = state.shiftedBy(dtLeg2);

  145.         // Transit state pv of leg2 (re)computed with gradient
  146.         final TimeStampedPVCoordinates transitStateLeg2PV = pva.shiftedBy(dtLeg2);

  147.         // transform between secondary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  148.         // The components of secondary station's position in offset frame are the 3 last derivative parameters
  149.         final AbsoluteDate approxReboundDate = measurementDate.shiftedBy(-delta);
  150.         final Transform secondaryToInertApprox =
  151.                         secondaryStation.getOffsetToInertial(state.getFrame(), approxReboundDate, true);

  152.         // Secondary station PV in inertial frame at approximate rebound date on secondary station
  153.         final TimeStampedPVCoordinates QSecondaryApprox =
  154.                         secondaryToInertApprox.transformPVCoordinates(new TimeStampedPVCoordinates(approxReboundDate,
  155.                                                                                                    Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  156.         // Uplink time of flight from secondary station to transit state of leg2
  157.         final double secondaryTauU = signalTimeOfFlight(QSecondaryApprox,
  158.                                                           transitStateLeg2PV.getPosition(),
  159.                                                           transitStateLeg2PV.getDate());

  160.         // Total time of flight for leg 2
  161.         final double tauLeg2 = primaryTauD + secondaryTauU;

  162.         // Compute propagation time for the 1st leg of the signal path
  163.         // --

  164.         // Absolute date of rebound of the signal to secondary station
  165.         final AbsoluteDate reboundDate   = measurementDate.shiftedBy(-tauLeg2);
  166.         final Transform secondaryToInert = secondaryStation.getOffsetToInertial(state.getFrame(), reboundDate, true);

  167.         // Secondary station PV in inertial frame at rebound date on secondary station
  168.         final TimeStampedPVCoordinates secondaryRebound =
  169.                         secondaryToInert.transformPVCoordinates(new TimeStampedPVCoordinates(reboundDate,
  170.                                                                                              Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  171.         // Downlink time of flight from transitStateLeg1 to secondary station at rebound date
  172.         final double secondaryTauD = signalTimeOfFlight(transitStateLeg2PV,
  173.                                                         secondaryRebound.getPosition(),
  174.                                                         reboundDate);


  175.         // Elapsed time between state date t' and signal arrival to the transit state of the 1st leg
  176.         final double dtLeg1 = dtLeg2 - secondaryTauU - secondaryTauD;

  177.         // Transit state pv of leg2 (re)computed
  178.         final TimeStampedPVCoordinates transitStateLeg1PV = pva.shiftedBy(dtLeg1);

  179.         // transform between primary station topocentric frame (east-north-zenith) and inertial frame
  180.         final AbsoluteDate approxEmissionDate = measurementDate.shiftedBy(-2 * (secondaryTauU + primaryTauD));
  181.         final Transform primaryToInertApprox  = getStation().getOffsetToInertial(state.getFrame(), approxEmissionDate, true);

  182.         // Primary station PV in inertial frame at approximate emission date
  183.         final TimeStampedPVCoordinates QPrimaryApprox =
  184.                         primaryToInertApprox.transformPVCoordinates(new TimeStampedPVCoordinates(approxEmissionDate,
  185.                                                                                                  Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO));

  186.         // Uplink time of flight from primary station to transit state of leg1
  187.         final double primaryTauU = signalTimeOfFlight(QPrimaryApprox,
  188.                                                       transitStateLeg1PV.getPosition(),
  189.                                                       transitStateLeg1PV.getDate());

  190.         // Primary station PV in inertial frame at exact emission date
  191.         final AbsoluteDate emissionDate = transitStateLeg1PV.getDate().shiftedBy(-primaryTauU);
  192.         final TimeStampedPVCoordinates primaryDeparture =
  193.                         primaryToInertApprox.shiftedBy(emissionDate.durationFrom(primaryToInertApprox.getDate())).
  194.                         transformPVCoordinates(new TimeStampedPVCoordinates(emissionDate, PVCoordinates.ZERO));

  195.         // Total time of flight for leg 1
  196.         final double tauLeg1 = secondaryTauD + primaryTauU;


  197.         // --
  198.         // Evaluate the turn-around range value and its derivatives
  199.         // --------------------------------------------------------

  200.         // The state we use to define the estimated measurement is a middle ground between the two transit states
  201.         // This is done to avoid calling "SpacecraftState.shiftedBy" function on long duration
  202.         // Thus we define the state at the date t" = date of rebound of the signal at the secondary station
  203.         // Or t" = t -primaryTauD -secondaryTauU
  204.         // The iterative process in the estimation ensures that, after several iterations, the date stamped in the
  205.         // state S in input of this function will be close to t"
  206.         // Therefore we will shift state S by:
  207.         //  - +secondaryTauU to get transitStateLeg2
  208.         //  - -secondaryTauD to get transitStateLeg1
  209.         final EstimatedMeasurementBase<TurnAroundRange> estimated =
  210.                         new EstimatedMeasurementBase<>(this, iteration, evaluation,
  211.                                                    new SpacecraftState[] {
  212.                                                        transitStateLeg2.shiftedBy(-secondaryTauU)
  213.                                                    },
  214.                                                    new TimeStampedPVCoordinates[] {
  215.                                                        primaryDeparture,
  216.                                                        transitStateLeg1PV,
  217.                                                        secondaryRebound,
  218.                                                        transitStateLeg2.getPVCoordinates(),
  219.                                                        primaryArrival
  220.                                                    });

  221.         // Turn-around range value = Total time of flight for the 2 legs divided by 2 and multiplied by c
  222.         final double cOver2 = 0.5 * Constants.SPEED_OF_LIGHT;
  223.         final double turnAroundRange = (tauLeg2 + tauLeg1) * cOver2;
  224.         estimated.setEstimatedValue(turnAroundRange);

  225.         return estimated;

  226.     }

  227.     /** {@inheritDoc} */
  228.     @Override
  229.     protected EstimatedMeasurement<TurnAroundRange> theoreticalEvaluation(final int iteration, final int evaluation,
  230.                                                                           final SpacecraftState[] states) {

  231.         final SpacecraftState state = states[0];

  232.         // Turn around range derivatives are computed with respect to:
  233.         // - Spacecraft state in inertial frame
  234.         // - Primary station parameters
  235.         // - Secondary station parameters
  236.         // --------------------------
  237.         //
  238.         //  - 0..2 - Position of the spacecraft in inertial frame
  239.         //  - 3..5 - Velocity of the spacecraft in inertial frame
  240.         //  - 6..n - stations' parameters (clock offset, station offsets, pole, prime meridian...)
  241.         int nbParams = 6;
  242.         final Map<String, Integer> indices = new HashMap<>();
  243.         for (ParameterDriver driver : getParametersDrivers()) {
  244.             // we have to check for duplicate keys because primary and secondary station share
  245.             // pole and prime meridian parameters names that must be considered
  246.             // as one set only (they are combined together by the estimation engine)
  247.             if (driver.isSelected()) {
  248.                 for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {

  249.                     if (!indices.containsKey(span.getData())) {
  250.                         indices.put(span.getData(), nbParams++);
  251.                     }
  252.                 }
  253.             }
  254.         }
  255.         final Field<Gradient>         field   = GradientField.getField(nbParams);
  256.         final FieldVector3D<Gradient> zero    = FieldVector3D.getZero(field);

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

  259.         // The path of the signal is divided in two legs.
  260.         // Leg1: Emission from primary station to satellite in primaryTauU seconds
  261.         //     + Reflection from satellite to secondary station in secondaryTauD seconds
  262.         // Leg2: Reflection from secondary station to satellite in secondaryTauU seconds
  263.         //     + Reflection from satellite to primary station in primaryTaudD seconds
  264.         // The measurement is considered to be time stamped at reception on ground
  265.         // by the primary station. All times are therefore computed as backward offsets
  266.         // with respect to this reception time.
  267.         //
  268.         // Two intermediate spacecraft states are defined:
  269.         //  - transitStateLeg2: State of the satellite when it bounced back the signal
  270.         //                      from secondary station to primary station during the 2nd leg
  271.         //  - transitStateLeg1: State of the satellite when it bounced back the signal
  272.         //                      from primary station to secondary station during the 1st leg

  273.         // Compute propagation time for the 2nd leg of the signal path
  274.         // --

  275.         // Time difference between t (date of the measurement) and t' (date tagged in spacecraft state)
  276.         // (if state has already been set up to pre-compensate propagation delay,
  277.         // we will have delta = primaryTauD + secondaryTauU)
  278.         final double delta = getDate().durationFrom(state.getDate());

  279.         // transform between primary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  280.         final FieldTransform<Gradient> primaryToInert =
  281.                         getStation().getOffsetToInertial(state.getFrame(), getDate(), nbParams, indices);
  282.         final FieldAbsoluteDate<Gradient> measurementDateDS = primaryToInert.getFieldDate();

  283.         // Primary station PV in inertial frame at measurement date
  284.         final TimeStampedFieldPVCoordinates<Gradient> primaryArrival =
  285.                         primaryToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(measurementDateDS,
  286.                                                                                                   zero, zero, zero));

  287.         // Compute propagation times
  288.         final Gradient primaryTauD = signalTimeOfFlight(pvaDS, primaryArrival.getPosition(), measurementDateDS);

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

  291.         // Transit state where the satellite reflected the signal from secondary to primary station
  292.         final SpacecraftState transitStateLeg2 = state.shiftedBy(dtLeg2.getValue());

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

  295.         // transform between secondary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  296.         // The components of secondary station's position in offset frame are the 3 last derivative parameters
  297.         final FieldAbsoluteDate<Gradient> approxReboundDate = measurementDateDS.shiftedBy(-delta);
  298.         final FieldTransform<Gradient> secondaryToInertApprox =
  299.                         secondaryStation.getOffsetToInertial(state.getFrame(), approxReboundDate, nbParams, indices);

  300.         // Secondary station PV in inertial frame at approximate rebound date on secondary station
  301.         final TimeStampedFieldPVCoordinates<Gradient> QSecondaryApprox =
  302.                         secondaryToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxReboundDate,
  303.                                                                                                           zero, zero, zero));

  304.         // Uplink time of flight from secondary station to transit state of leg2
  305.         final Gradient secondaryTauU = signalTimeOfFlight(QSecondaryApprox,
  306.                                                           transitStateLeg2PV.getPosition(),
  307.                                                           transitStateLeg2PV.getDate());

  308.         // Total time of flight for leg 2
  309.         final Gradient tauLeg2 = primaryTauD.add(secondaryTauU);

  310.         // Compute propagation time for the 1st leg of the signal path
  311.         // --

  312.         // Absolute date of rebound of the signal to secondary station
  313.         final FieldAbsoluteDate<Gradient> reboundDateDS = measurementDateDS.shiftedBy(tauLeg2.negate());
  314.         final FieldTransform<Gradient> secondaryToInert =
  315.                         secondaryStation.getOffsetToInertial(state.getFrame(), reboundDateDS, nbParams, indices);

  316.         // Secondary station PV in inertial frame at rebound date on secondary station
  317.         final TimeStampedFieldPVCoordinates<Gradient> secondaryRebound =
  318.                         secondaryToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(reboundDateDS,
  319.                                                                                                     FieldPVCoordinates.getZero(field)));

  320.         // Downlink time of flight from transitStateLeg1 to secondary station at rebound date
  321.         final Gradient secondaryTauD = signalTimeOfFlight(transitStateLeg2PV,
  322.                                                           secondaryRebound.getPosition(),
  323.                                                           reboundDateDS);


  324.         // Elapsed time between state date t' and signal arrival to the transit state of the 1st leg
  325.         final Gradient dtLeg1 = dtLeg2.subtract(secondaryTauU).subtract(secondaryTauD);

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

  328.         // transform between primary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  329.         // The components of primary station's position in offset frame are the 3 third derivative parameters
  330.         final FieldAbsoluteDate<Gradient> approxEmissionDate =
  331.                         measurementDateDS.shiftedBy(-2 * (secondaryTauU.getValue() + primaryTauD.getValue()));
  332.         final FieldTransform<Gradient> primaryToInertApprox =
  333.                         getStation().getOffsetToInertial(state.getFrame(), approxEmissionDate, nbParams, indices);

  334.         // Primary station PV in inertial frame at approximate emission date
  335.         final TimeStampedFieldPVCoordinates<Gradient> QPrimaryApprox =
  336.                         primaryToInertApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxEmissionDate,
  337.                                                                                                         zero, zero, zero));

  338.         // Uplink time of flight from primary station to transit state of leg1
  339.         final Gradient primaryTauU = signalTimeOfFlight(QPrimaryApprox,
  340.                                                         transitStateLeg1PV.getPosition(),
  341.                                                         transitStateLeg1PV.getDate());

  342.         // Primary station PV in inertial frame at exact emission date
  343.         final AbsoluteDate emissionDate = transitStateLeg1PV.getDate().toAbsoluteDate().shiftedBy(-primaryTauU.getValue());
  344.         final TimeStampedPVCoordinates primaryDeparture =
  345.                         primaryToInertApprox.shiftedBy(emissionDate.durationFrom(primaryToInertApprox.getDate())).
  346.                         transformPVCoordinates(new TimeStampedPVCoordinates(emissionDate, PVCoordinates.ZERO)).
  347.                         toTimeStampedPVCoordinates();

  348.         // Total time of flight for leg 1
  349.         final Gradient tauLeg1 = secondaryTauD.add(primaryTauU);


  350.         // --
  351.         // Evaluate the turn-around range value and its derivatives
  352.         // --------------------------------------------------------

  353.         // The state we use to define the estimated measurement is a middle ground between the two transit states
  354.         // This is done to avoid calling "SpacecraftState.shiftedBy" function on long duration
  355.         // Thus we define the state at the date t" = date of rebound of the signal at the secondary station
  356.         // Or t" = t -primaryTauD -secondaryTauU
  357.         // The iterative process in the estimation ensures that, after several iterations, the date stamped in the
  358.         // state S in input of this function will be close to t"
  359.         // Therefore we will shift state S by:
  360.         //  - +secondaryTauU to get transitStateLeg2
  361.         //  - -secondaryTauD to get transitStateLeg1
  362.         final EstimatedMeasurement<TurnAroundRange> estimated =
  363.                         new EstimatedMeasurement<>(this, iteration, evaluation,
  364.                                                    new SpacecraftState[] {
  365.                                                        transitStateLeg2.shiftedBy(-secondaryTauU.getValue())
  366.                                                    },
  367.                                                    new TimeStampedPVCoordinates[] {
  368.                                                        primaryDeparture,
  369.                                                        transitStateLeg1PV.toTimeStampedPVCoordinates(),
  370.                                                        secondaryRebound.toTimeStampedPVCoordinates(),
  371.                                                        transitStateLeg2.getPVCoordinates(),
  372.                                                        primaryArrival.toTimeStampedPVCoordinates()
  373.                                                    });

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

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

  381.         // set partial derivatives with respect to parameters
  382.         // (beware element at index 0 is the value, not a derivative)
  383.         for (final ParameterDriver driver : getParametersDrivers()) {
  384.             for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
  385.                 final Integer index = indices.get(span.getData());
  386.                 if (index != null) {
  387.                     estimated.setParameterDerivatives(driver, span.getStart(), derivatives[index]);
  388.                 }
  389.             }
  390.         }

  391.         return estimated;

  392.     }

  393. }