GroundStation.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.Map;

  19. import org.hipparchus.Field;
  20. import org.hipparchus.analysis.differentiation.DSFactory;
  21. import org.hipparchus.analysis.differentiation.DerivativeStructure;
  22. import org.hipparchus.analysis.differentiation.Gradient;
  23. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  24. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  25. import org.hipparchus.geometry.euclidean.threed.Rotation;
  26. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  27. import org.hipparchus.util.FastMath;
  28. import org.orekit.bodies.BodyShape;
  29. import org.orekit.bodies.FieldGeodeticPoint;
  30. import org.orekit.bodies.GeodeticPoint;
  31. import org.orekit.data.BodiesElements;
  32. import org.orekit.data.FundamentalNutationArguments;
  33. import org.orekit.errors.OrekitException;
  34. import org.orekit.errors.OrekitMessages;
  35. import org.orekit.frames.EOPHistory;
  36. import org.orekit.frames.FieldTransform;
  37. import org.orekit.frames.Frame;
  38. import org.orekit.frames.FramesFactory;
  39. import org.orekit.frames.TopocentricFrame;
  40. import org.orekit.frames.Transform;
  41. import org.orekit.models.earth.displacement.StationDisplacement;
  42. import org.orekit.time.AbsoluteDate;
  43. import org.orekit.time.FieldAbsoluteDate;
  44. import org.orekit.time.UT1Scale;
  45. import org.orekit.utils.ParameterDriver;

  46. /** Class modeling a ground station that can perform some measurements.
  47.  * <p>
  48.  * This class adds a position offset parameter to a base {@link TopocentricFrame
  49.  * topocentric frame}.
  50.  * </p>
  51.  * <p>
  52.  * Since 9.0, this class also adds parameters for an additional polar motion
  53.  * and an additional prime meridian orientation. Since these parameters will
  54.  * have the same name for all ground stations, they will be managed consistently
  55.  * and allow to estimate Earth orientation precisely (this is needed for precise
  56.  * orbit determination). The polar motion and prime meridian orientation will
  57.  * be applied <em>after</em> regular Earth orientation parameters, so the value
  58.  * of the estimated parameters will be correction to EOP, they will not be the
  59.  * complete EOP values by themselves. Basically, this means that for Earth, the
  60.  * following transforms are applied in order, between inertial frame and ground
  61.  * station frame (for non-Earth based ground stations, different precession nutation
  62.  * models and associated planet oritentation parameters would be applied, if available):
  63.  * </p>
  64.  * <p>
  65.  * Since 9.3, this class also adds a station clock offset parameter, which manages
  66.  * the value that must be subtracted from the observed measurement date to get the real
  67.  * physical date at which the measurement was performed (i.e. the offset is negative
  68.  * if the ground station clock is slow and positive if it is fast).
  69.  * </p>
  70.  * <ol>
  71.  *   <li>precession/nutation, as theoretical model plus celestial pole EOP parameters</li>
  72.  *   <li>body rotation, as theoretical model plus prime meridian EOP parameters</li>
  73.  *   <li>polar motion, which is only from EOP parameters (no theoretical models)</li>
  74.  *   <li>additional body rotation, controlled by {@link #getPrimeMeridianOffsetDriver()} and {@link #getPrimeMeridianDriftDriver()}</li>
  75.  *   <li>additional polar motion, controlled by {@link #getPolarOffsetXDriver()}, {@link #getPolarDriftXDriver()},
  76.  *   {@link #getPolarOffsetYDriver()} and {@link #getPolarDriftYDriver()}</li>
  77.  *   <li>station clock offset, controlled by {@link #getClockOffsetDriver()}</li>
  78.  *   <li>station position offset, controlled by {@link #getEastOffsetDriver()},
  79.  *   {@link #getNorthOffsetDriver()} and {@link #getZenithOffsetDriver()}</li>
  80.  * </ol>
  81.  * @author Luc Maisonobe
  82.  * @since 8.0
  83.  */
  84. public class GroundStation {

  85.     /** Suffix for ground station position and clock offset parameters names. */
  86.     public static final String OFFSET_SUFFIX = "-offset";

  87.     /** Suffix for ground clock drift parameters name. */
  88.     public static final String DRIFT_SUFFIX = "-drift-clock";

  89.     /** Suffix for ground station intermediate frame name. */
  90.     public static final String INTERMEDIATE_SUFFIX = "-intermediate";

  91.     /** Clock offset scaling factor.
  92.      * <p>
  93.      * We use a power of 2 to avoid numeric noise introduction
  94.      * in the multiplications/divisions sequences.
  95.      * </p>
  96.      */
  97.     private static final double CLOCK_OFFSET_SCALE = FastMath.scalb(1.0, -10);

  98.     /** Position offsets scaling factor.
  99.      * <p>
  100.      * We use a power of 2 (in fact really 1.0 here) to avoid numeric noise introduction
  101.      * in the multiplications/divisions sequences.
  102.      * </p>
  103.      */
  104.     private static final double POSITION_OFFSET_SCALE = FastMath.scalb(1.0, 0);

  105.     /** Provider for Earth frame whose EOP parameters can be estimated. */
  106.     private final EstimatedEarthFrameProvider estimatedEarthFrameProvider;

  107.     /** Earth frame whose EOP parameters can be estimated. */
  108.     private final Frame estimatedEarthFrame;

  109.     /** Base frame associated with the station. */
  110.     private final TopocentricFrame baseFrame;

  111.     /** Fundamental nutation arguments. */
  112.     private final FundamentalNutationArguments arguments;

  113.     /** Displacement models. */
  114.     private final StationDisplacement[] displacements;

  115.     /** Driver for clock offset. */
  116.     private final ParameterDriver clockOffsetDriver;

  117.     /** Driver for clock drift. */
  118.     private final ParameterDriver clockDriftDriver;

  119.     /** Driver for position offset along the East axis. */
  120.     private final ParameterDriver eastOffsetDriver;

  121.     /** Driver for position offset along the North axis. */
  122.     private final ParameterDriver northOffsetDriver;

  123.     /** Driver for position offset along the zenith axis. */
  124.     private final ParameterDriver zenithOffsetDriver;

  125.     /** Build a ground station ignoring {@link StationDisplacement station displacements}.
  126.      * <p>
  127.      * The initial values for the pole and prime meridian parametric linear models
  128.      * ({@link #getPrimeMeridianOffsetDriver()}, {@link #getPrimeMeridianDriftDriver()},
  129.      * {@link #getPolarOffsetXDriver()}, {@link #getPolarDriftXDriver()},
  130.      * {@link #getPolarOffsetXDriver()}, {@link #getPolarDriftXDriver()}) are set to 0.
  131.      * The initial values for the station offset model ({@link #getClockOffsetDriver()},
  132.      * {@link #getEastOffsetDriver()}, {@link #getNorthOffsetDriver()},
  133.      * {@link #getZenithOffsetDriver()}) are set to 0.
  134.      * This implies that as long as these values are not changed, the offset frame is
  135.      * the same as the {@link #getBaseFrame() base frame}. As soon as some of these models
  136.      * are changed, the offset frame moves away from the {@link #getBaseFrame() base frame}.
  137.      * </p>
  138.      * @param baseFrame base frame associated with the station, without *any* parametric
  139.      * model (no station offset, no polar motion, no meridian shift)
  140.      * @see #GroundStation(TopocentricFrame, EOPHistory, StationDisplacement...)
  141.      */
  142.     public GroundStation(final TopocentricFrame baseFrame) {
  143.         this(baseFrame, FramesFactory.findEOP(baseFrame), new StationDisplacement[0]);
  144.     }

  145.     /** Simple constructor.
  146.      * <p>
  147.      * The initial values for the pole and prime meridian parametric linear models
  148.      * ({@link #getPrimeMeridianOffsetDriver()}, {@link #getPrimeMeridianDriftDriver()},
  149.      * {@link #getPolarOffsetXDriver()}, {@link #getPolarDriftXDriver()},
  150.      * {@link #getPolarOffsetXDriver()}, {@link #getPolarDriftXDriver()}) are set to 0.
  151.      * The initial values for the station offset model ({@link #getClockOffsetDriver()},
  152.      * {@link #getEastOffsetDriver()}, {@link #getNorthOffsetDriver()},
  153.      * {@link #getZenithOffsetDriver()}, {@link #getClockOffsetDriver()}) are set to 0.
  154.      * This implies that as long as these values are not changed, the offset frame is
  155.      * the same as the {@link #getBaseFrame() base frame}. As soon as some of these models
  156.      * are changed, the offset frame moves away from the {@link #getBaseFrame() base frame}.
  157.      * </p>
  158.      * @param baseFrame base frame associated with the station, without *any* parametric
  159.      * model (no station offset, no polar motion, no meridian shift)
  160.      * @param eopHistory EOP history associated with Earth frames
  161.      * @param displacements ground station displacement model (tides, ocean loading,
  162.      * atmospheric loading, thermal effects...)
  163.      * @since 9.1
  164.      */
  165.     public GroundStation(final TopocentricFrame baseFrame, final EOPHistory eopHistory,
  166.                          final StationDisplacement... displacements) {

  167.         this.baseFrame = baseFrame;

  168.         if (eopHistory == null) {
  169.             throw new OrekitException(OrekitMessages.NO_EARTH_ORIENTATION_PARAMETERS);
  170.         }

  171.         final UT1Scale baseUT1 = eopHistory.getTimeScales()
  172.                 .getUT1(eopHistory.getConventions(), eopHistory.isSimpleEop());
  173.         this.estimatedEarthFrameProvider = new EstimatedEarthFrameProvider(baseUT1);
  174.         this.estimatedEarthFrame = new Frame(baseFrame.getParent(), estimatedEarthFrameProvider,
  175.                                              baseFrame.getParent() + "-estimated");

  176.         if (displacements.length == 0) {
  177.             arguments = null;
  178.         } else {
  179.             arguments = eopHistory.getConventions().getNutationArguments(
  180.                     estimatedEarthFrameProvider.getEstimatedUT1(),
  181.                     eopHistory.getTimeScales());
  182.         }

  183.         this.displacements = displacements.clone();

  184.         this.clockOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-clock",
  185.                                                      0.0, CLOCK_OFFSET_SCALE,
  186.                                                      Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  187.         this.clockDriftDriver = new ParameterDriver(baseFrame.getName() + DRIFT_SUFFIX,
  188.                                                     0.0, CLOCK_OFFSET_SCALE,
  189.                                                     Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  190.         this.eastOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-East",
  191.                                                     0.0, POSITION_OFFSET_SCALE,
  192.                                                     Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  193.         this.northOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-North",
  194.                                                      0.0, POSITION_OFFSET_SCALE,
  195.                                                      Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  196.         this.zenithOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-Zenith",
  197.                                                       0.0, POSITION_OFFSET_SCALE,
  198.                                                       Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  199.     }

  200.     /** Get the displacement models.
  201.      * @return displacement models (empty if no model has been set up)
  202.      * @since 9.1
  203.      */
  204.     public StationDisplacement[] getDisplacements() {
  205.         return displacements.clone();
  206.     }

  207.     /** Get a driver allowing to change station clock (which is related to measurement date).
  208.      * @return driver for station clock offset
  209.      * @since 9.3
  210.      */
  211.     public ParameterDriver getClockOffsetDriver() {
  212.         return clockOffsetDriver;
  213.     }

  214.     /** Get a driver allowing to change station clock drift (which is related to measurement date).
  215.      * @return driver for station clock drift
  216.      * @since 10.3
  217.      */
  218.     public ParameterDriver getClockDriftDriver() {
  219.         return clockDriftDriver;
  220.     }

  221.     /** Get a driver allowing to change station position along East axis.
  222.      * @return driver for station position offset along East axis
  223.      */
  224.     public ParameterDriver getEastOffsetDriver() {
  225.         return eastOffsetDriver;
  226.     }

  227.     /** Get a driver allowing to change station position along North axis.
  228.      * @return driver for station position offset along North axis
  229.      */
  230.     public ParameterDriver getNorthOffsetDriver() {
  231.         return northOffsetDriver;
  232.     }

  233.     /** Get a driver allowing to change station position along Zenith axis.
  234.      * @return driver for station position offset along Zenith axis
  235.      */
  236.     public ParameterDriver getZenithOffsetDriver() {
  237.         return zenithOffsetDriver;
  238.     }

  239.     /** Get a driver allowing to add a prime meridian rotation.
  240.      * <p>
  241.      * The parameter is an angle in radians. In order to convert this
  242.      * value to a DUT1 in seconds, the value must be divided by
  243.      * {@code ave = 7.292115146706979e-5} (which is the nominal Angular Velocity
  244.      * of Earth from the TIRF model).
  245.      * </p>
  246.      * @return driver for prime meridian rotation
  247.      */
  248.     public ParameterDriver getPrimeMeridianOffsetDriver() {
  249.         return estimatedEarthFrameProvider.getPrimeMeridianOffsetDriver();
  250.     }

  251.     /** Get a driver allowing to add a prime meridian rotation rate.
  252.      * <p>
  253.      * The parameter is an angle rate in radians per second. In order to convert this
  254.      * value to a LOD in seconds, the value must be multiplied by -86400 and divided by
  255.      * {@code ave = 7.292115146706979e-5} (which is the nominal Angular Velocity
  256.      * of Earth from the TIRF model).
  257.      * </p>
  258.      * @return driver for prime meridian rotation rate
  259.      */
  260.     public ParameterDriver getPrimeMeridianDriftDriver() {
  261.         return estimatedEarthFrameProvider.getPrimeMeridianDriftDriver();
  262.     }

  263.     /** Get a driver allowing to add a polar offset along X.
  264.      * <p>
  265.      * The parameter is an angle in radians
  266.      * </p>
  267.      * @return driver for polar offset along X
  268.      */
  269.     public ParameterDriver getPolarOffsetXDriver() {
  270.         return estimatedEarthFrameProvider.getPolarOffsetXDriver();
  271.     }

  272.     /** Get a driver allowing to add a polar drift along X.
  273.      * <p>
  274.      * The parameter is an angle rate in radians per second
  275.      * </p>
  276.      * @return driver for polar drift along X
  277.      */
  278.     public ParameterDriver getPolarDriftXDriver() {
  279.         return estimatedEarthFrameProvider.getPolarDriftXDriver();
  280.     }

  281.     /** Get a driver allowing to add a polar offset along Y.
  282.      * <p>
  283.      * The parameter is an angle in radians
  284.      * </p>
  285.      * @return driver for polar offset along Y
  286.      */
  287.     public ParameterDriver getPolarOffsetYDriver() {
  288.         return estimatedEarthFrameProvider.getPolarOffsetYDriver();
  289.     }

  290.     /** Get a driver allowing to add a polar drift along Y.
  291.      * <p>
  292.      * The parameter is an angle rate in radians per second
  293.      * </p>
  294.      * @return driver for polar drift along Y
  295.      */
  296.     public ParameterDriver getPolarDriftYDriver() {
  297.         return estimatedEarthFrameProvider.getPolarDriftYDriver();
  298.     }

  299.     /** Get the base frame associated with the station.
  300.      * <p>
  301.      * The base frame corresponds to a null position offset, null
  302.      * polar motion, null meridian shift
  303.      * </p>
  304.      * @return base frame associated with the station
  305.      */
  306.     public TopocentricFrame getBaseFrame() {
  307.         return baseFrame;
  308.     }

  309.     /** Get the estimated Earth frame, including the estimated linear models for pole and prime meridian.
  310.      * <p>
  311.      * This frame is bound to the {@link #getPrimeMeridianOffsetDriver() driver for prime meridian offset},
  312.      * {@link #getPrimeMeridianDriftDriver() driver prime meridian drift},
  313.      * {@link #getPolarOffsetXDriver() driver for polar offset along X},
  314.      * {@link #getPolarDriftXDriver() driver for polar drift along X},
  315.      * {@link #getPolarOffsetYDriver() driver for polar offset along Y},
  316.      * {@link #getPolarDriftYDriver() driver for polar drift along Y}, so its orientation changes when
  317.      * the {@link ParameterDriver#setValue(double) setValue} methods of the drivers are called.
  318.      * </p>
  319.      * @return estimated Earth frame
  320.      * @since 9.1
  321.      */
  322.     public Frame getEstimatedEarthFrame() {
  323.         return estimatedEarthFrame;
  324.     }

  325.     /** Get the estimated UT1 scale, including the estimated linear models for prime meridian.
  326.      * <p>
  327.      * This time scale is bound to the {@link #getPrimeMeridianOffsetDriver() driver for prime meridian offset},
  328.      * and {@link #getPrimeMeridianDriftDriver() driver prime meridian drift}, so its offset from UTC changes when
  329.      * the {@link ParameterDriver#setValue(double) setValue} methods of the drivers are called.
  330.      * </p>
  331.      * @return estimated Earth frame
  332.      * @since 9.1
  333.      */
  334.     public UT1Scale getEstimatedUT1() {
  335.         return estimatedEarthFrameProvider.getEstimatedUT1();
  336.     }

  337.     /** Get the station displacement.
  338.      * @param date current date
  339.      * @param position raw position of the station in Earth frame
  340.      * before displacement is applied
  341.      * @return station displacement
  342.      * @since 9.1
  343.      */
  344.     private Vector3D computeDisplacement(final AbsoluteDate date, final Vector3D position) {
  345.         Vector3D displacement = Vector3D.ZERO;
  346.         if (arguments != null) {
  347.             final BodiesElements elements = arguments.evaluateAll(date);
  348.             for (final StationDisplacement sd : displacements) {
  349.                 // we consider all displacements apply to the same initial position,
  350.                 // i.e. they apply simultaneously, not according to some order
  351.                 displacement = displacement.add(sd.displacement(elements, estimatedEarthFrame, position));
  352.             }
  353.         }
  354.         return displacement;
  355.     }

  356.     /** Get the geodetic point at the center of the offset frame.
  357.      * @param date current date (may be null if displacements are ignored)
  358.      * @return geodetic point at the center of the offset frame
  359.      * @since 9.1
  360.      */
  361.     public GeodeticPoint getOffsetGeodeticPoint(final AbsoluteDate date) {

  362.         // take station offset into account
  363.         final double    x          = eastOffsetDriver.getValue();
  364.         final double    y          = northOffsetDriver.getValue();
  365.         final double    z          = zenithOffsetDriver.getValue();
  366.         final BodyShape baseShape  = baseFrame.getParentShape();
  367.         final Transform baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), date);
  368.         Vector3D        origin     = baseToBody.transformPosition(new Vector3D(x, y, z));

  369.         if (date != null) {
  370.             origin = origin.add(computeDisplacement(date, origin));
  371.         }

  372.         return baseShape.transform(origin, baseShape.getBodyFrame(), null);

  373.     }

  374.     /** Get the transform between offset frame and inertial frame.
  375.      * <p>
  376.      * The offset frame takes the <em>current</em> position offset,
  377.      * polar motion and the meridian shift into account. The frame
  378.      * returned is disconnected from later changes in the parameters.
  379.      * When the {@link ParameterDriver parameters} managing these
  380.      * offsets are changed, the method must be called again to retrieve
  381.      * a new offset frame.
  382.      * </p>
  383.      * @param inertial inertial frame to transform to
  384.      * @param clockDate date of the transform as read by the ground station clock (i.e. clock offset <em>not</em> compensated)
  385.      * @return transform between offset frame and inertial frame, at <em>real</em> measurement
  386.      * date (i.e. with clock, Earth and station offsets applied)
  387.      */
  388.     public Transform getOffsetToInertial(final Frame inertial, final AbsoluteDate clockDate) {

  389.         // take clock offset into account
  390.         final double offset = clockOffsetDriver.getValue();
  391.         final AbsoluteDate offsetCompensatedDate = new AbsoluteDate(clockDate, -offset);

  392.         // take Earth offsets into account
  393.         final Transform intermediateToBody = estimatedEarthFrameProvider.getTransform(offsetCompensatedDate).getInverse();

  394.         // take station offsets into account
  395.         final double    x          = eastOffsetDriver.getValue();
  396.         final double    y          = northOffsetDriver.getValue();
  397.         final double    z          = zenithOffsetDriver.getValue();
  398.         final BodyShape baseShape  = baseFrame.getParentShape();
  399.         final Transform baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), offsetCompensatedDate);
  400.         Vector3D        origin     = baseToBody.transformPosition(new Vector3D(x, y, z));
  401.         origin = origin.add(computeDisplacement(offsetCompensatedDate, origin));

  402.         final GeodeticPoint originGP = baseShape.transform(origin, baseShape.getBodyFrame(), offsetCompensatedDate);
  403.         final Transform offsetToIntermediate =
  404.                         new Transform(offsetCompensatedDate,
  405.                                       new Transform(offsetCompensatedDate,
  406.                                                     new Rotation(Vector3D.PLUS_I, Vector3D.PLUS_K,
  407.                                                                  originGP.getEast(), originGP.getZenith()),
  408.                                                     Vector3D.ZERO),
  409.                                       new Transform(offsetCompensatedDate, origin));

  410.         // combine all transforms together
  411.         final Transform bodyToInert        = baseFrame.getParent().getTransformTo(inertial, offsetCompensatedDate);

  412.         return new Transform(offsetCompensatedDate, offsetToIntermediate, new Transform(offsetCompensatedDate, intermediateToBody, bodyToInert));

  413.     }

  414.     /** Get the transform between offset frame and inertial frame with derivatives.
  415.      * <p>
  416.      * As the East and North vectors are not well defined at pole, the derivatives
  417.      * of these two vectors diverge to infinity as we get closer to the pole.
  418.      * So this method should not be used for stations less than 0.0001 degree from
  419.      * either poles.
  420.      * </p>
  421.      * @param inertial inertial frame to transform to
  422.      * @param clockDate date of the transform as read by the ground station clock (i.e. clock offset <em>not</em> compensated)
  423.      * @param factory factory for the derivatives
  424.      * @param indices indices of the estimated parameters in derivatives computations
  425.      * @return transform between offset frame and inertial frame, at <em>real</em> measurement
  426.      * date (i.e. with clock, Earth and station offsets applied)
  427.      * @see #getOffsetToInertial(Frame, FieldAbsoluteDate, DSFactory, Map)
  428.      * @since 9.3
  429.      * @deprecated as of 10.2, replaced by {@link #getOffsetToInertial(Frame, AbsoluteDate, int, Map)}
  430.      */
  431.     @Deprecated
  432.     public FieldTransform<DerivativeStructure> getOffsetToInertial(final Frame inertial,
  433.                                                                    final AbsoluteDate clockDate,
  434.                                                                    final DSFactory factory,
  435.                                                                    final Map<String, Integer> indices) {
  436.         // take clock offset into account
  437.         final DerivativeStructure offset = clockOffsetDriver.getValue(factory, indices);
  438.         final FieldAbsoluteDate<DerivativeStructure> offsetCompensatedDate =
  439.                         new FieldAbsoluteDate<DerivativeStructure>(clockDate, offset.negate());

  440.         return getOffsetToInertial(inertial, offsetCompensatedDate, factory, indices);
  441.     }

  442.     /** Get the transform between offset frame and inertial frame with derivatives.
  443.      * <p>
  444.      * As the East and North vectors are not well defined at pole, the derivatives
  445.      * of these two vectors diverge to infinity as we get closer to the pole.
  446.      * So this method should not be used for stations less than 0.0001 degree from
  447.      * either poles.
  448.      * </p>
  449.      * @param inertial inertial frame to transform to
  450.      * @param offsetCompensatedDate date of the transform, clock offset and its derivatives already compensated
  451.      * @param factory factory for the derivatives
  452.      * @param indices indices of the estimated parameters in derivatives computations
  453.      * @return transform between offset frame and inertial frame, at specified date
  454.      * @see #getOffsetToInertial(Frame, AbsoluteDate, DSFactory, Map)
  455.      * @since 9.0
  456.      * @deprecated as of 10.2, replaced by {@link #getOffsetToInertial(Frame, FieldAbsoluteDate, int, Map)}
  457.      */
  458.     @Deprecated
  459.     public FieldTransform<DerivativeStructure> getOffsetToInertial(final Frame inertial,
  460.                                                                    final FieldAbsoluteDate<DerivativeStructure> offsetCompensatedDate,
  461.                                                                    final DSFactory factory,
  462.                                                                    final Map<String, Integer> indices) {

  463.         final Field<DerivativeStructure>         field = factory.getDerivativeField();
  464.         final FieldVector3D<DerivativeStructure> zero  = FieldVector3D.getZero(field);
  465.         final FieldVector3D<DerivativeStructure> plusI = FieldVector3D.getPlusI(field);
  466.         final FieldVector3D<DerivativeStructure> plusK = FieldVector3D.getPlusK(field);

  467.         // take Earth offsets into account
  468.         final FieldTransform<DerivativeStructure> intermediateToBody =
  469.                         estimatedEarthFrameProvider.getTransform(offsetCompensatedDate, factory, indices).getInverse();

  470.         // take station offsets into account
  471.         final DerivativeStructure  x          = eastOffsetDriver.getValue(factory, indices);
  472.         final DerivativeStructure  y          = northOffsetDriver.getValue(factory, indices);
  473.         final DerivativeStructure  z          = zenithOffsetDriver.getValue(factory, indices);
  474.         final BodyShape            baseShape  = baseFrame.getParentShape();
  475.         final Transform            baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), (AbsoluteDate) null);

  476.         FieldVector3D<DerivativeStructure>            origin   = baseToBody.transformPosition(new FieldVector3D<>(x, y, z));
  477.         origin = origin.add(computeDisplacement(offsetCompensatedDate.toAbsoluteDate(), origin.toVector3D()));
  478.         final FieldGeodeticPoint<DerivativeStructure> originGP = baseShape.transform(origin, baseShape.getBodyFrame(), offsetCompensatedDate);
  479.         final FieldTransform<DerivativeStructure> offsetToIntermediate =
  480.                         new FieldTransform<>(offsetCompensatedDate,
  481.                                              new FieldTransform<>(offsetCompensatedDate,
  482.                                                                   new FieldRotation<>(plusI, plusK,
  483.                                                                                       originGP.getEast(), originGP.getZenith()),
  484.                                                                   zero),
  485.                                              new FieldTransform<>(offsetCompensatedDate, origin));

  486.         // combine all transforms together
  487.         final FieldTransform<DerivativeStructure> bodyToInert        = baseFrame.getParent().getTransformTo(inertial, offsetCompensatedDate);

  488.         return new FieldTransform<>(offsetCompensatedDate,
  489.                                     offsetToIntermediate,
  490.                                     new FieldTransform<>(offsetCompensatedDate, intermediateToBody, bodyToInert));

  491.     }

  492.     /** Get the transform between offset frame and inertial frame with derivatives.
  493.      * <p>
  494.      * As the East and North vectors are not well defined at pole, the derivatives
  495.      * of these two vectors diverge to infinity as we get closer to the pole.
  496.      * So this method should not be used for stations less than 0.0001 degree from
  497.      * either poles.
  498.      * </p>
  499.      * @param inertial inertial frame to transform to
  500.      * @param clockDate date of the transform as read by the ground station clock (i.e. clock offset <em>not</em> compensated)
  501.      * @param freeParameters total number of free parameters in the gradient
  502.      * @param indices indices of the estimated parameters in derivatives computations
  503.      * @return transform between offset frame and inertial frame, at <em>real</em> measurement
  504.      * date (i.e. with clock, Earth and station offsets applied)
  505.      * @see #getOffsetToInertial(Frame, FieldAbsoluteDate, DSFactory, Map)
  506.      * @since 10.2
  507.      */
  508.     public FieldTransform<Gradient> getOffsetToInertial(final Frame inertial,
  509.                                                         final AbsoluteDate clockDate,
  510.                                                         final int freeParameters,
  511.                                                         final Map<String, Integer> indices) {
  512.         // take clock offset into account
  513.         final Gradient offset = clockOffsetDriver.getValue(freeParameters, indices);
  514.         final FieldAbsoluteDate<Gradient> offsetCompensatedDate =
  515.                         new FieldAbsoluteDate<>(clockDate, offset.negate());

  516.         return getOffsetToInertial(inertial, offsetCompensatedDate, freeParameters, indices);
  517.     }

  518.     /** Get the transform between offset frame and inertial frame with derivatives.
  519.      * <p>
  520.      * As the East and North vectors are not well defined at pole, the derivatives
  521.      * of these two vectors diverge to infinity as we get closer to the pole.
  522.      * So this method should not be used for stations less than 0.0001 degree from
  523.      * either poles.
  524.      * </p>
  525.      * @param inertial inertial frame to transform to
  526.      * @param offsetCompensatedDate date of the transform, clock offset and its derivatives already compensated
  527.      * @param freeParameters total number of free parameters in the gradient
  528.      * @param indices indices of the estimated parameters in derivatives computations
  529.      * @return transform between offset frame and inertial frame, at specified date
  530.      * @see #getOffsetToInertial(Frame, AbsoluteDate, DSFactory, Map)
  531.      * @since 10.2
  532.      */
  533.     public FieldTransform<Gradient> getOffsetToInertial(final Frame inertial,
  534.                                                         final FieldAbsoluteDate<Gradient> offsetCompensatedDate,
  535.                                                         final int freeParameters,
  536.                                                         final Map<String, Integer> indices) {

  537.         final Field<Gradient>         field = offsetCompensatedDate.getField();
  538.         final FieldVector3D<Gradient> zero  = FieldVector3D.getZero(field);
  539.         final FieldVector3D<Gradient> plusI = FieldVector3D.getPlusI(field);
  540.         final FieldVector3D<Gradient> plusK = FieldVector3D.getPlusK(field);

  541.         // take Earth offsets into account
  542.         final FieldTransform<Gradient> intermediateToBody =
  543.                         estimatedEarthFrameProvider.getTransform(offsetCompensatedDate, freeParameters, indices).getInverse();

  544.         // take station offsets into account
  545.         final Gradient  x          = eastOffsetDriver.getValue(freeParameters, indices);
  546.         final Gradient  y          = northOffsetDriver.getValue(freeParameters, indices);
  547.         final Gradient  z          = zenithOffsetDriver.getValue(freeParameters, indices);
  548.         final BodyShape            baseShape  = baseFrame.getParentShape();
  549.         final Transform            baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), (AbsoluteDate) null);

  550.         FieldVector3D<Gradient> origin = baseToBody.transformPosition(new FieldVector3D<>(x, y, z));
  551.         origin = origin.add(computeDisplacement(offsetCompensatedDate.toAbsoluteDate(), origin.toVector3D()));
  552.         final FieldGeodeticPoint<Gradient> originGP = baseShape.transform(origin, baseShape.getBodyFrame(), offsetCompensatedDate);
  553.         final FieldTransform<Gradient> offsetToIntermediate =
  554.                         new FieldTransform<>(offsetCompensatedDate,
  555.                                              new FieldTransform<>(offsetCompensatedDate,
  556.                                                                   new FieldRotation<>(plusI, plusK,
  557.                                                                                       originGP.getEast(), originGP.getZenith()),
  558.                                                                   zero),
  559.                                              new FieldTransform<>(offsetCompensatedDate, origin));

  560.         // combine all transforms together
  561.         final FieldTransform<Gradient> bodyToInert = baseFrame.getParent().getTransformTo(inertial, offsetCompensatedDate);

  562.         return new FieldTransform<>(offsetCompensatedDate,
  563.                                     offsetToIntermediate,
  564.                                     new FieldTransform<>(offsetCompensatedDate, intermediateToBody, bodyToInert));

  565.     }

  566. }