GroundStation.java

  1. /* Copyright 2002-2022 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.Gradient;
  21. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Rotation;
  24. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  25. import org.hipparchus.util.FastMath;
  26. import org.orekit.bodies.BodyShape;
  27. import org.orekit.bodies.FieldGeodeticPoint;
  28. import org.orekit.bodies.GeodeticPoint;
  29. import org.orekit.data.BodiesElements;
  30. import org.orekit.data.FundamentalNutationArguments;
  31. import org.orekit.errors.OrekitException;
  32. import org.orekit.errors.OrekitMessages;
  33. import org.orekit.frames.EOPHistory;
  34. import org.orekit.frames.FieldTransform;
  35. import org.orekit.frames.Frame;
  36. import org.orekit.frames.FramesFactory;
  37. import org.orekit.frames.StaticTransform;
  38. import org.orekit.frames.TopocentricFrame;
  39. import org.orekit.frames.Transform;
  40. import org.orekit.models.earth.displacement.StationDisplacement;
  41. import org.orekit.time.AbsoluteDate;
  42. import org.orekit.time.FieldAbsoluteDate;
  43. import org.orekit.time.UT1Scale;
  44. import org.orekit.utils.ParameterDriver;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  166.         this.baseFrame = baseFrame;

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

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

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

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

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

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

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

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

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

  198.     }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  361.         // take station offset into account
  362.         final double    x          = eastOffsetDriver.getValue();
  363.         final double    y          = northOffsetDriver.getValue();
  364.         final double    z          = zenithOffsetDriver.getValue();
  365.         final BodyShape baseShape  = baseFrame.getParentShape();
  366.         final StaticTransform baseToBody =
  367.                 baseFrame.getStaticTransformTo(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 StaticTransform baseToBody = baseFrame
  400.                 .getStaticTransformTo(baseShape.getBodyFrame(), offsetCompensatedDate);
  401.         Vector3D        origin     = baseToBody.transformPosition(new Vector3D(x, y, z));
  402.         origin = origin.add(computeDisplacement(offsetCompensatedDate, origin));

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

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

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

  414.     }

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

  439.         return getOffsetToInertial(inertial, offsetCompensatedDate, freeParameters, indices);
  440.     }

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

  459.         final Field<Gradient>         field = offsetCompensatedDate.getField();
  460.         final FieldVector3D<Gradient> zero  = FieldVector3D.getZero(field);
  461.         final FieldVector3D<Gradient> plusI = FieldVector3D.getPlusI(field);
  462.         final FieldVector3D<Gradient> plusK = FieldVector3D.getPlusK(field);

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

  466.         // take station offsets into account
  467.         final Gradient  x          = eastOffsetDriver.getValue(freeParameters, indices);
  468.         final Gradient  y          = northOffsetDriver.getValue(freeParameters, indices);
  469.         final Gradient  z          = zenithOffsetDriver.getValue(freeParameters, indices);
  470.         final BodyShape            baseShape  = baseFrame.getParentShape();
  471.         final StaticTransform      baseToBody = baseFrame
  472.                 .getStaticTransformTo(baseShape.getBodyFrame(), null);

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

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

  485.         return new FieldTransform<>(offsetCompensatedDate,
  486.                                     offsetToIntermediate,
  487.                                     new FieldTransform<>(offsetCompensatedDate, intermediateToBody, bodyToInert));

  488.     }

  489. }