GroundStation.java

  1. /* Copyright 2002-2024 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.estimation.measurements;

  18. import java.util.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.FieldStaticTransform;
  35. import org.orekit.frames.FieldTransform;
  36. import org.orekit.frames.Frame;
  37. import org.orekit.frames.FramesFactory;
  38. import org.orekit.frames.StaticTransform;
  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 StaticTransform baseToBody = 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(), date);

  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 date date of the transform
  385.      * @param clockOffsetAlreadyApplied if true, the specified {@code date} is as read
  386.      * by the ground station clock (i.e. clock offset <em>not</em> compensated), if false,
  387.      * the specified {@code date} was already compensated and is a physical absolute date
  388.      * @return transform between offset frame and inertial frame, at <em>real</em> measurement
  389.      * date (i.e. with clock, Earth and station offsets applied)
  390.      */
  391.     public Transform getOffsetToInertial(final Frame inertial,
  392.                                          final AbsoluteDate date, final boolean clockOffsetAlreadyApplied) {

  393.         // take clock offset into account
  394.         final AbsoluteDate offsetCompensatedDate = clockOffsetAlreadyApplied ?
  395.                                                    date :
  396.                                                    new AbsoluteDate(date, -clockOffsetDriver.getValue());

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

  399.         // take station offsets into account
  400.         final double    x          = eastOffsetDriver.getValue();
  401.         final double    y          = northOffsetDriver.getValue();
  402.         final double    z          = zenithOffsetDriver.getValue();
  403.         final BodyShape baseShape  = baseFrame.getParentShape();
  404.         final StaticTransform baseToBody = baseFrame
  405.                 .getStaticTransformTo(baseShape.getBodyFrame(), offsetCompensatedDate);
  406.         Vector3D        origin     = baseToBody.transformPosition(new Vector3D(x, y, z));
  407.         origin = origin.add(computeDisplacement(offsetCompensatedDate, origin));

  408.         final GeodeticPoint originGP = baseShape.transform(origin, baseShape.getBodyFrame(), offsetCompensatedDate);
  409.         final Transform offsetToIntermediate =
  410.                         new Transform(offsetCompensatedDate,
  411.                                       new Transform(offsetCompensatedDate,
  412.                                                     new Rotation(Vector3D.PLUS_I, Vector3D.PLUS_K,
  413.                                                                  originGP.getEast(), originGP.getZenith()),
  414.                                                     Vector3D.ZERO),
  415.                                       new Transform(offsetCompensatedDate, origin));

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

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

  419.     }

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

  445.         return getOffsetToInertial(inertial, offsetCompensatedDate, freeParameters, indices);
  446.     }

  447.     /** Get the transform between offset frame and inertial frame with derivatives.
  448.      * <p>
  449.      * As the East and North vectors are not well defined at pole, the derivatives
  450.      * of these two vectors diverge to infinity as we get closer to the pole.
  451.      * So this method should not be used for stations less than 0.0001 degree from
  452.      * either poles.
  453.      * </p>
  454.      * @param inertial inertial frame to transform to
  455.      * @param offsetCompensatedDate date of the transform, clock offset and its derivatives already compensated
  456.      * @param freeParameters total number of free parameters in the gradient
  457.      * @param indices indices of the estimated parameters in derivatives computations, must be driver
  458.      * span name in map, not driver name or will not give right results (see {@link ParameterDriver#getValue(int, Map)})
  459.      * @return transform between offset frame and inertial frame, at specified date
  460.      * @since 10.2
  461.      */
  462.     public FieldTransform<Gradient> getOffsetToInertial(final Frame inertial,
  463.                                                         final FieldAbsoluteDate<Gradient> offsetCompensatedDate,
  464.                                                         final int freeParameters,
  465.                                                         final Map<String, Integer> indices) {

  466.         final Field<Gradient>         field = offsetCompensatedDate.getField();
  467.         final FieldVector3D<Gradient> zero  = FieldVector3D.getZero(field);
  468.         final FieldVector3D<Gradient> plusI = FieldVector3D.getPlusI(field);
  469.         final FieldVector3D<Gradient> plusK = FieldVector3D.getPlusK(field);

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

  473.         // take station offsets into account
  474.         final Gradient                       x          = eastOffsetDriver.getValue(freeParameters, indices);
  475.         final Gradient                       y          = northOffsetDriver.getValue(freeParameters, indices);
  476.         final Gradient                       z          = zenithOffsetDriver.getValue(freeParameters, indices);
  477.         final BodyShape                      baseShape  = baseFrame.getParentShape();
  478.         final FieldStaticTransform<Gradient> baseToBody = baseFrame.getStaticTransformTo(baseShape.getBodyFrame(), offsetCompensatedDate);

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

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

  491.         return new FieldTransform<>(offsetCompensatedDate,
  492.                                     offsetToIntermediate,
  493.                                     new FieldTransform<>(offsetCompensatedDate, intermediateToBody, bodyToInert));

  494.     }

  495. }