GroundStation.java

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

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

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

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

  90.     /** Suffix for ground clock drift parameters name.
  91.      * @since 12.1
  92.      */
  93.     public static final String ACCELERATION_SUFFIX = "-acceleration-clock";

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

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

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

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

  112.     /** Base frame associated with the station. */
  113.     private final TopocentricFrame baseFrame;

  114.     /** Fundamental nutation arguments. */
  115.     private final FundamentalNutationArguments arguments;

  116.     /** Displacement models. */
  117.     private final StationDisplacement[] displacements;

  118.     /** Driver for clock offset. */
  119.     private final ParameterDriver clockOffsetDriver;

  120.     /** Driver for clock drift. */
  121.     private final ParameterDriver clockDriftDriver;

  122.     /** Driver for clock acceleration.
  123.      * @since 12.1
  124.      */
  125.     private final ParameterDriver clockAccelerationDriver;

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

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

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

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

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

  175.         this.baseFrame = baseFrame;

  176.         if (eopHistory == null) {
  177.             throw new OrekitException(OrekitMessages.NO_EARTH_ORIENTATION_PARAMETERS);
  178.         }

  179.         final UT1Scale baseUT1 = eopHistory.getTimeScales()
  180.                 .getUT1(eopHistory.getConventions(), eopHistory.isSimpleEop());
  181.         this.estimatedEarthFrameProvider = new EstimatedEarthFrameProvider(baseUT1);
  182.         this.estimatedEarthFrame = new Frame(baseFrame.getParent(), estimatedEarthFrameProvider,
  183.                                              baseFrame.getParent() + "-estimated");

  184.         if (displacements.length == 0) {
  185.             arguments = null;
  186.         } else {
  187.             arguments = eopHistory.getConventions().getNutationArguments(
  188.                     estimatedEarthFrameProvider.getEstimatedUT1(),
  189.                     eopHistory.getTimeScales());
  190.         }

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

  192.         this.clockOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-clock",
  193.                                                      0.0, CLOCK_OFFSET_SCALE,
  194.                                                      Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  195.         this.clockDriftDriver = new ParameterDriver(baseFrame.getName() + DRIFT_SUFFIX,
  196.                                                     0.0, CLOCK_OFFSET_SCALE,
  197.                                                     Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  198.         this.clockAccelerationDriver = new ParameterDriver(baseFrame.getName() + ACCELERATION_SUFFIX,
  199.                                                     0.0, CLOCK_OFFSET_SCALE,
  200.                                                     Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  201.         this.eastOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-East",
  202.                                                     0.0, POSITION_OFFSET_SCALE,
  203.                                                     Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  204.         this.northOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-North",
  205.                                                      0.0, POSITION_OFFSET_SCALE,
  206.                                                      Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  207.         this.zenithOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-Zenith",
  208.                                                       0.0, POSITION_OFFSET_SCALE,
  209.                                                       Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  210.     }

  211.     /** Get the displacement models.
  212.      * @return displacement models (empty if no model has been set up)
  213.      * @since 9.1
  214.      */
  215.     public StationDisplacement[] getDisplacements() {
  216.         return displacements.clone();
  217.     }

  218.     /** Get a driver allowing to change station clock (which is related to measurement date).
  219.      * @return driver for station clock offset
  220.      * @since 9.3
  221.      */
  222.     public ParameterDriver getClockOffsetDriver() {
  223.         return clockOffsetDriver;
  224.     }

  225.     /** Get a driver allowing to change station clock drift (which is related to measurement date).
  226.      * @return driver for station clock drift
  227.      * @since 10.3
  228.      */
  229.     public ParameterDriver getClockDriftDriver() {
  230.         return clockDriftDriver;
  231.     }

  232.     /** Get a driver allowing to change station clock acceleration (which is related to measurement date).
  233.      * @return driver for station clock acceleration
  234.      * @since 12.1
  235.      */
  236.     public ParameterDriver getClockAccelerationDriver() {
  237.         return clockAccelerationDriver;
  238.     }

  239.     /** Get a driver allowing to change station position along East axis.
  240.      * @return driver for station position offset along East axis
  241.      */
  242.     public ParameterDriver getEastOffsetDriver() {
  243.         return eastOffsetDriver;
  244.     }

  245.     /** Get a driver allowing to change station position along North axis.
  246.      * @return driver for station position offset along North axis
  247.      */
  248.     public ParameterDriver getNorthOffsetDriver() {
  249.         return northOffsetDriver;
  250.     }

  251.     /** Get a driver allowing to change station position along Zenith axis.
  252.      * @return driver for station position offset along Zenith axis
  253.      */
  254.     public ParameterDriver getZenithOffsetDriver() {
  255.         return zenithOffsetDriver;
  256.     }

  257.     /** Get a driver allowing to add a prime meridian rotation.
  258.      * <p>
  259.      * The parameter is an angle in radians. In order to convert this
  260.      * value to a DUT1 in seconds, the value must be divided by
  261.      * {@code ave = 7.292115146706979e-5} (which is the nominal Angular Velocity
  262.      * of Earth from the TIRF model).
  263.      * </p>
  264.      * @return driver for prime meridian rotation
  265.      */
  266.     public ParameterDriver getPrimeMeridianOffsetDriver() {
  267.         return estimatedEarthFrameProvider.getPrimeMeridianOffsetDriver();
  268.     }

  269.     /** Get a driver allowing to add a prime meridian rotation rate.
  270.      * <p>
  271.      * The parameter is an angle rate in radians per second. In order to convert this
  272.      * value to a LOD in seconds, the value must be multiplied by -86400 and divided by
  273.      * {@code ave = 7.292115146706979e-5} (which is the nominal Angular Velocity
  274.      * of Earth from the TIRF model).
  275.      * </p>
  276.      * @return driver for prime meridian rotation rate
  277.      */
  278.     public ParameterDriver getPrimeMeridianDriftDriver() {
  279.         return estimatedEarthFrameProvider.getPrimeMeridianDriftDriver();
  280.     }

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

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

  299.     /** Get a driver allowing to add a polar offset along Y.
  300.      * <p>
  301.      * The parameter is an angle in radians
  302.      * </p>
  303.      * @return driver for polar offset along Y
  304.      */
  305.     public ParameterDriver getPolarOffsetYDriver() {
  306.         return estimatedEarthFrameProvider.getPolarOffsetYDriver();
  307.     }

  308.     /** Get a driver allowing to add a polar drift along Y.
  309.      * <p>
  310.      * The parameter is an angle rate in radians per second
  311.      * </p>
  312.      * @return driver for polar drift along Y
  313.      */
  314.     public ParameterDriver getPolarDriftYDriver() {
  315.         return estimatedEarthFrameProvider.getPolarDriftYDriver();
  316.     }

  317.     /** Get the base frame associated with the station.
  318.      * <p>
  319.      * The base frame corresponds to a null position offset, null
  320.      * polar motion, null meridian shift
  321.      * </p>
  322.      * @return base frame associated with the station
  323.      */
  324.     public TopocentricFrame getBaseFrame() {
  325.         return baseFrame;
  326.     }

  327.     /** Get the estimated Earth frame, including the estimated linear models for pole and prime meridian.
  328.      * <p>
  329.      * This frame is bound to the {@link #getPrimeMeridianOffsetDriver() driver for prime meridian offset},
  330.      * {@link #getPrimeMeridianDriftDriver() driver prime meridian drift},
  331.      * {@link #getPolarOffsetXDriver() driver for polar offset along X},
  332.      * {@link #getPolarDriftXDriver() driver for polar drift along X},
  333.      * {@link #getPolarOffsetYDriver() driver for polar offset along Y},
  334.      * {@link #getPolarDriftYDriver() driver for polar drift along Y}, so its orientation changes when
  335.      * the {@link ParameterDriver#setValue(double) setValue} methods of the drivers are called.
  336.      * </p>
  337.      * @return estimated Earth frame
  338.      * @since 9.1
  339.      */
  340.     public Frame getEstimatedEarthFrame() {
  341.         return estimatedEarthFrame;
  342.     }

  343.     /** Get the estimated UT1 scale, including the estimated linear models for prime meridian.
  344.      * <p>
  345.      * This time scale is bound to the {@link #getPrimeMeridianOffsetDriver() driver for prime meridian offset},
  346.      * and {@link #getPrimeMeridianDriftDriver() driver prime meridian drift}, so its offset from UTC changes when
  347.      * the {@link ParameterDriver#setValue(double) setValue} methods of the drivers are called.
  348.      * </p>
  349.      * @return estimated Earth frame
  350.      * @since 9.1
  351.      */
  352.     public UT1Scale getEstimatedUT1() {
  353.         return estimatedEarthFrameProvider.getEstimatedUT1();
  354.     }

  355.     /** Get the station displacement.
  356.      * @param date current date
  357.      * @param position raw position of the station in Earth frame
  358.      * before displacement is applied
  359.      * @return station displacement
  360.      * @since 9.1
  361.      */
  362.     private Vector3D computeDisplacement(final AbsoluteDate date, final Vector3D position) {
  363.         Vector3D displacement = Vector3D.ZERO;
  364.         if (arguments != null) {
  365.             final BodiesElements elements = arguments.evaluateAll(date);
  366.             for (final StationDisplacement sd : displacements) {
  367.                 // we consider all displacements apply to the same initial position,
  368.                 // i.e. they apply simultaneously, not according to some order
  369.                 displacement = displacement.add(sd.displacement(elements, estimatedEarthFrame, position));
  370.             }
  371.         }
  372.         return displacement;
  373.     }

  374.     /** Get the geodetic point at the center of the offset frame.
  375.      * @param date current date (may be null if displacements are ignored)
  376.      * @return geodetic point at the center of the offset frame
  377.      * @since 9.1
  378.      */
  379.     public GeodeticPoint getOffsetGeodeticPoint(final AbsoluteDate date) {

  380.         // take station offset into account
  381.         final double    x          = eastOffsetDriver.getValue();
  382.         final double    y          = northOffsetDriver.getValue();
  383.         final double    z          = zenithOffsetDriver.getValue();
  384.         final BodyShape baseShape  = baseFrame.getParentShape();
  385.         final StaticTransform baseToBody = baseFrame.getStaticTransformTo(baseShape.getBodyFrame(), date);
  386.         Vector3D        origin     = baseToBody.transformPosition(new Vector3D(x, y, z));

  387.         if (date != null) {
  388.             origin = origin.add(computeDisplacement(date, origin));
  389.         }

  390.         return baseShape.transform(origin, baseShape.getBodyFrame(), date);

  391.     }

  392.     /** Get the geodetic point at the center of the offset frame.
  393.      * @param <T> type of the field elements
  394.      * @param date current date(<em>must</em> be non-null, which is a more stringent condition
  395.      *      *                    than in {@link #getOffsetGeodeticPoint(AbsoluteDate)}
  396.      * @return geodetic point at the center of the offset frame
  397.      * @since 12.1
  398.      */
  399.     public <T extends CalculusFieldElement<T>> FieldGeodeticPoint<T> getOffsetGeodeticPoint(final FieldAbsoluteDate<T> date) {

  400.         // take station offset into account
  401.         final double    x          = eastOffsetDriver.getValue();
  402.         final double    y          = northOffsetDriver.getValue();
  403.         final double    z          = zenithOffsetDriver.getValue();
  404.         final BodyShape baseShape  = baseFrame.getParentShape();
  405.         final FieldStaticTransform<T> baseToBody = baseFrame.getStaticTransformTo(baseShape.getBodyFrame(), date);
  406.         FieldVector3D<T> origin    = baseToBody.transformPosition(new Vector3D(x, y, z));
  407.         origin = origin.add(computeDisplacement(date.toAbsoluteDate(), origin.toVector3D()));

  408.         return baseShape.transform(origin, baseShape.getBodyFrame(), date);

  409.     }

  410.     /** Get the transform between offset frame and inertial frame.
  411.      * <p>
  412.      * The offset frame takes the <em>current</em> position offset,
  413.      * polar motion and the meridian shift into account. The frame
  414.      * returned is disconnected from later changes in the parameters.
  415.      * When the {@link ParameterDriver parameters} managing these
  416.      * offsets are changed, the method must be called again to retrieve
  417.      * a new offset frame.
  418.      * </p>
  419.      * @param inertial inertial frame to transform to
  420.      * @param date date of the transform
  421.      * @param clockOffsetAlreadyApplied if true, the specified {@code date} is as read
  422.      * by the ground station clock (i.e. clock offset <em>not</em> compensated), if false,
  423.      * the specified {@code date} was already compensated and is a physical absolute date
  424.      * @return transform between offset frame and inertial frame, at <em>real</em> measurement
  425.      * date (i.e. with clock, Earth and station offsets applied)
  426.      */
  427.     public Transform getOffsetToInertial(final Frame inertial,
  428.                                          final AbsoluteDate date, final boolean clockOffsetAlreadyApplied) {

  429.         // take clock offset into account
  430.         final AbsoluteDate offsetCompensatedDate = clockOffsetAlreadyApplied ?
  431.                                                    date :
  432.                                                    new AbsoluteDate(date, -clockOffsetDriver.getValue());

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

  435.         // take station offsets into account
  436.         final double    x          = eastOffsetDriver.getValue();
  437.         final double    y          = northOffsetDriver.getValue();
  438.         final double    z          = zenithOffsetDriver.getValue();
  439.         final BodyShape baseShape  = baseFrame.getParentShape();
  440.         final StaticTransform baseToBody = baseFrame
  441.                 .getStaticTransformTo(baseShape.getBodyFrame(), offsetCompensatedDate);
  442.         Vector3D        origin     = baseToBody.transformPosition(new Vector3D(x, y, z));
  443.         origin = origin.add(computeDisplacement(offsetCompensatedDate, origin));

  444.         final GeodeticPoint originGP = baseShape.transform(origin, baseShape.getBodyFrame(), offsetCompensatedDate);
  445.         final Transform offsetToIntermediate =
  446.                         new Transform(offsetCompensatedDate,
  447.                                       new Transform(offsetCompensatedDate,
  448.                                                     new Rotation(Vector3D.PLUS_I, Vector3D.PLUS_K,
  449.                                                                  originGP.getEast(), originGP.getZenith()),
  450.                                                     Vector3D.ZERO),
  451.                                       new Transform(offsetCompensatedDate, origin));

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

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

  455.     }

  456.     /** Get the transform between offset frame and inertial frame with derivatives.
  457.      * <p>
  458.      * As the East and North vectors are not well defined at pole, the derivatives
  459.      * of these two vectors diverge to infinity as we get closer to the pole.
  460.      * So this method should not be used for stations less than 0.0001 degree from
  461.      * either poles.
  462.      * </p>
  463.      * @param inertial inertial frame to transform to
  464.      * @param clockDate date of the transform as read by the ground station clock (i.e. clock offset <em>not</em> compensated)
  465.      * @param freeParameters total number of free parameters in the gradient
  466.      * @param indices indices of the estimated parameters in derivatives computations, must be driver
  467.      * span name in map, not driver name or will not give right results (see {@link ParameterDriver#getValue(int, Map)})
  468.      * @return transform between offset frame and inertial frame, at <em>real</em> measurement
  469.      * date (i.e. with clock, Earth and station offsets applied)
  470.      * @see #getOffsetToInertial(Frame, FieldAbsoluteDate, int, Map)
  471.      * @since 10.2
  472.      */
  473.     public FieldTransform<Gradient> getOffsetToInertial(final Frame inertial,
  474.                                                         final AbsoluteDate clockDate,
  475.                                                         final int freeParameters,
  476.                                                         final Map<String, Integer> indices) {
  477.         // take clock offset into account
  478.         final Gradient offset = clockOffsetDriver.getValue(freeParameters, indices, clockDate);
  479.         final FieldAbsoluteDate<Gradient> offsetCompensatedDate =
  480.                         new FieldAbsoluteDate<>(clockDate, offset.negate());

  481.         return getOffsetToInertial(inertial, offsetCompensatedDate, freeParameters, indices);
  482.     }

  483.     /** Get the transform between offset frame and inertial frame with derivatives.
  484.      * <p>
  485.      * As the East and North vectors are not well defined at pole, the derivatives
  486.      * of these two vectors diverge to infinity as we get closer to the pole.
  487.      * So this method should not be used for stations less than 0.0001 degree from
  488.      * either poles.
  489.      * </p>
  490.      * @param inertial inertial frame to transform to
  491.      * @param offsetCompensatedDate date of the transform, clock offset and its derivatives already compensated
  492.      * @param freeParameters total number of free parameters in the gradient
  493.      * @param indices indices of the estimated parameters in derivatives computations, must be driver
  494.      * span name in map, not driver name or will not give right results (see {@link ParameterDriver#getValue(int, Map)})
  495.      * @return transform between offset frame and inertial frame, at specified date
  496.      * @since 10.2
  497.      */
  498.     public FieldTransform<Gradient> getOffsetToInertial(final Frame inertial,
  499.                                                         final FieldAbsoluteDate<Gradient> offsetCompensatedDate,
  500.                                                         final int freeParameters,
  501.                                                         final Map<String, Integer> indices) {

  502.         final Field<Gradient>         field = offsetCompensatedDate.getField();
  503.         final FieldVector3D<Gradient> zero  = FieldVector3D.getZero(field);
  504.         final FieldVector3D<Gradient> plusI = FieldVector3D.getPlusI(field);
  505.         final FieldVector3D<Gradient> plusK = FieldVector3D.getPlusK(field);

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

  509.         // take station offsets into account
  510.         final Gradient                       x          = eastOffsetDriver.getValue(freeParameters, indices);
  511.         final Gradient                       y          = northOffsetDriver.getValue(freeParameters, indices);
  512.         final Gradient                       z          = zenithOffsetDriver.getValue(freeParameters, indices);
  513.         final BodyShape                      baseShape  = baseFrame.getParentShape();
  514.         final FieldStaticTransform<Gradient> baseToBody = baseFrame.getStaticTransformTo(baseShape.getBodyFrame(), offsetCompensatedDate);

  515.         FieldVector3D<Gradient> origin = baseToBody.transformPosition(new FieldVector3D<>(x, y, z));
  516.         origin = origin.add(computeDisplacement(offsetCompensatedDate.toAbsoluteDate(), origin.toVector3D()));
  517.         final FieldGeodeticPoint<Gradient> originGP = baseShape.transform(origin, baseShape.getBodyFrame(), offsetCompensatedDate);
  518.         final FieldTransform<Gradient> offsetToIntermediate =
  519.                         new FieldTransform<>(offsetCompensatedDate,
  520.                                              new FieldTransform<>(offsetCompensatedDate,
  521.                                                                   new FieldRotation<>(plusI, plusK,
  522.                                                                                       originGP.getEast(), originGP.getZenith()),
  523.                                                                   zero),
  524.                                              new FieldTransform<>(offsetCompensatedDate, origin));

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

  527.         return new FieldTransform<>(offsetCompensatedDate,
  528.                                     offsetToIntermediate,
  529.                                     new FieldTransform<>(offsetCompensatedDate, intermediateToBody, bodyToInert));

  530.     }

  531. }