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.TopocentricFrame;
  38. import org.orekit.frames.Transform;
  39. import org.orekit.models.earth.displacement.StationDisplacement;
  40. import org.orekit.time.AbsoluteDate;
  41. import org.orekit.time.FieldAbsoluteDate;
  42. import org.orekit.time.UT1Scale;
  43. import org.orekit.utils.ParameterDriver;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  165.         this.baseFrame = baseFrame;

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

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

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

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

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

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

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

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

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

  197.     }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  371.     }

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

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

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

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

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

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

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

  411.     }

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

  436.         return getOffsetToInertial(inertial, offsetCompensatedDate, freeParameters, indices);
  437.     }

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

  456.         final Field<Gradient>         field = offsetCompensatedDate.getField();
  457.         final FieldVector3D<Gradient> zero  = FieldVector3D.getZero(field);
  458.         final FieldVector3D<Gradient> plusI = FieldVector3D.getPlusI(field);
  459.         final FieldVector3D<Gradient> plusK = FieldVector3D.getPlusK(field);

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

  463.         // take station offsets into account
  464.         final Gradient  x          = eastOffsetDriver.getValue(freeParameters, indices);
  465.         final Gradient  y          = northOffsetDriver.getValue(freeParameters, indices);
  466.         final Gradient  z          = zenithOffsetDriver.getValue(freeParameters, indices);
  467.         final BodyShape            baseShape  = baseFrame.getParentShape();
  468.         final Transform            baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), (AbsoluteDate) null);

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

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

  481.         return new FieldTransform<>(offsetCompensatedDate,
  482.                                     offsetToIntermediate,
  483.                                     new FieldTransform<>(offsetCompensatedDate, intermediateToBody, bodyToInert));

  484.     }

  485. }