GroundStation.java

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

  18. import java.util.Map;

  19. import org.hipparchus.Field;
  20. import org.hipparchus.analysis.differentiation.DSFactory;
  21. import org.hipparchus.analysis.differentiation.DerivativeStructure;
  22. import org.hipparchus.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.FieldTransform;
  36. import org.orekit.frames.Frame;
  37. import org.orekit.frames.FramesFactory;
  38. import org.orekit.frames.TopocentricFrame;
  39. import org.orekit.frames.Transform;
  40. import org.orekit.models.earth.displacement.StationDisplacement;
  41. import org.orekit.time.AbsoluteDate;
  42. import org.orekit.time.FieldAbsoluteDate;
  43. import org.orekit.time.UT1Scale;
  44. import org.orekit.utils.ParameterDriver;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  162.         this.baseFrame = baseFrame;

  163.         if (eopHistory == null) {
  164.             throw new OrekitException(OrekitMessages.NO_EARTH_ORIENTATION_PARAMETERS);
  165.         }

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

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

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

  179.         this.clockOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-clock",
  180.                                                      0.0, CLOCK_OFFSET_SCALE,
  181.                                                      Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  182.         this.eastOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-East",
  183.                                                     0.0, POSITION_OFFSET_SCALE,
  184.                                                     Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

  185.         this.northOffsetDriver = new ParameterDriver(baseFrame.getName() + OFFSET_SUFFIX + "-North",
  186.                                                      0.0, POSITION_OFFSET_SCALE,
  187.                                                      Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);

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

  191.     }

  192.     /** Get the displacement models.
  193.      * @return displacement models (empty if no model has been set up)
  194.      * @since 9.1
  195.      */
  196.     public StationDisplacement[] getDisplacements() {
  197.         return displacements.clone();
  198.     }

  199.     /** Get a driver allowing to change station clock (which is related to measurement date).
  200.      * @return driver for station clock offset
  201.      * @since 9.3
  202.      */
  203.     public ParameterDriver getClockOffsetDriver() {
  204.         return clockOffsetDriver;
  205.     }

  206.     /** Get a driver allowing to change station position along East axis.
  207.      * @return driver for station position offset along East axis
  208.      */
  209.     public ParameterDriver getEastOffsetDriver() {
  210.         return eastOffsetDriver;
  211.     }

  212.     /** Get a driver allowing to change station position along North axis.
  213.      * @return driver for station position offset along North axis
  214.      */
  215.     public ParameterDriver getNorthOffsetDriver() {
  216.         return northOffsetDriver;
  217.     }

  218.     /** Get a driver allowing to change station position along Zenith axis.
  219.      * @return driver for station position offset along Zenith axis
  220.      */
  221.     public ParameterDriver getZenithOffsetDriver() {
  222.         return zenithOffsetDriver;
  223.     }

  224.     /** Get a driver allowing to add a prime meridian rotation.
  225.      * <p>
  226.      * The parameter is an angle in radians. In order to convert this
  227.      * value to a DUT1 in seconds, the value must be divided by
  228.      * {@code ave = 7.292115146706979e-5} (which is the nominal Angular Velocity
  229.      * of Earth from the TIRF model).
  230.      * </p>
  231.      * @return driver for prime meridian rotation
  232.      */
  233.     public ParameterDriver getPrimeMeridianOffsetDriver() {
  234.         return estimatedEarthFrameProvider.getPrimeMeridianOffsetDriver();
  235.     }

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

  248.     /** Get a driver allowing to add a polar offset along X.
  249.      * <p>
  250.      * The parameter is an angle in radians
  251.      * </p>
  252.      * @return driver for polar offset along X
  253.      */
  254.     public ParameterDriver getPolarOffsetXDriver() {
  255.         return estimatedEarthFrameProvider.getPolarOffsetXDriver();
  256.     }

  257.     /** Get a driver allowing to add a polar drift along X.
  258.      * <p>
  259.      * The parameter is an angle rate in radians per second
  260.      * </p>
  261.      * @return driver for polar drift along X
  262.      */
  263.     public ParameterDriver getPolarDriftXDriver() {
  264.         return estimatedEarthFrameProvider.getPolarDriftXDriver();
  265.     }

  266.     /** Get a driver allowing to add a polar offset along Y.
  267.      * <p>
  268.      * The parameter is an angle in radians
  269.      * </p>
  270.      * @return driver for polar offset along Y
  271.      */
  272.     public ParameterDriver getPolarOffsetYDriver() {
  273.         return estimatedEarthFrameProvider.getPolarOffsetYDriver();
  274.     }

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

  284.     /** Get the base frame associated with the station.
  285.      * <p>
  286.      * The base frame corresponds to a null position offset, null
  287.      * polar motion, null meridian shift
  288.      * </p>
  289.      * @return base frame associated with the station
  290.      */
  291.     public TopocentricFrame getBaseFrame() {
  292.         return baseFrame;
  293.     }

  294.     /** Get the estimated Earth frame, including the estimated linear models for pole and prime meridian.
  295.      * <p>
  296.      * This frame is bound to the {@link #getPrimeMeridianOffsetDriver() driver for prime meridian offset},
  297.      * {@link #getPrimeMeridianDriftDriver() driver prime meridian drift},
  298.      * {@link #getPolarOffsetXDriver() driver for polar offset along X},
  299.      * {@link #getPolarDriftXDriver() driver for polar drift along X},
  300.      * {@link #getPolarOffsetYDriver() driver for polar offset along Y},
  301.      * {@link #getPolarDriftYDriver() driver for polar drift along Y}, so its orientation changes when
  302.      * the {@link ParameterDriver#setValue(double) setValue} methods of the drivers are called.
  303.      * </p>
  304.      * @return estimated Earth frame
  305.      * @since 9.1
  306.      */
  307.     public Frame getEstimatedEarthFrame() {
  308.         return estimatedEarthFrame;
  309.     }

  310.     /** Get the estimated UT1 scale, including the estimated linear models for prime meridian.
  311.      * <p>
  312.      * This time scale is bound to the {@link #getPrimeMeridianOffsetDriver() driver for prime meridian offset},
  313.      * and {@link #getPrimeMeridianDriftDriver() driver prime meridian drift}, so its offset from UTC changes when
  314.      * the {@link ParameterDriver#setValue(double) setValue} methods of the drivers are called.
  315.      * </p>
  316.      * @return estimated Earth frame
  317.      * @since 9.1
  318.      */
  319.     public UT1Scale getEstimatedUT1() {
  320.         return estimatedEarthFrameProvider.getEstimatedUT1();
  321.     }

  322.     /** Get the station displacement.
  323.      * @param date current date
  324.      * @param position raw position of the station in Earth frame
  325.      * before displacement is applied
  326.      * @return station displacement
  327.      * @since 9.1
  328.      */
  329.     private Vector3D computeDisplacement(final AbsoluteDate date, final Vector3D position) {
  330.         Vector3D displacement = Vector3D.ZERO;
  331.         if (arguments != null) {
  332.             final BodiesElements elements = arguments.evaluateAll(date);
  333.             for (final StationDisplacement sd : displacements) {
  334.                 // we consider all displacements apply to the same initial position,
  335.                 // i.e. they apply simultaneously, not according to some order
  336.                 displacement = displacement.add(sd.displacement(elements, estimatedEarthFrame, position));
  337.             }
  338.         }
  339.         return displacement;
  340.     }

  341.     /** Get the geodetic point at the center of the offset frame.
  342.      * @param date current date (may be null if displacements are ignored)
  343.      * @return geodetic point at the center of the offset frame
  344.      * @since 9.1
  345.      */
  346.     public GeodeticPoint getOffsetGeodeticPoint(final AbsoluteDate date) {

  347.         // take station offset into account
  348.         final double    x          = eastOffsetDriver.getValue();
  349.         final double    y          = northOffsetDriver.getValue();
  350.         final double    z          = zenithOffsetDriver.getValue();
  351.         final BodyShape baseShape  = baseFrame.getParentShape();
  352.         final Transform baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), date);
  353.         Vector3D        origin     = baseToBody.transformPosition(new Vector3D(x, y, z));

  354.         if (date != null) {
  355.             origin = origin.add(computeDisplacement(date, origin));
  356.         }

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

  358.     }

  359.     /** Get the transform between offset frame and inertial frame.
  360.      * <p>
  361.      * The offset frame takes the <em>current</em> position offset,
  362.      * polar motion and the meridian shift into account. The frame
  363.      * returned is disconnected from later changes in the parameters.
  364.      * When the {@link ParameterDriver parameters} managing these
  365.      * offsets are changed, the method must be called again to retrieve
  366.      * a new offset frame.
  367.      * </p>
  368.      * @param inertial inertial frame to transform to
  369.      * @param clockDate date of the transform as read by the ground station clock (i.e. clock offset <em>not</em> compensated)
  370.      * @return transform between offset frame and inertial frame, at <em>real</em> measurement
  371.      * date (i.e. with clock, Earth and station offsets applied)
  372.      */
  373.     public Transform getOffsetToInertial(final Frame inertial, final AbsoluteDate clockDate) {

  374.         // take clock offset into account
  375.         final double offset = clockOffsetDriver.getValue();
  376.         final AbsoluteDate offsetCompensatedDate = new AbsoluteDate(clockDate, -offset);

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

  379.         // take station offsets into account
  380.         final double    x          = eastOffsetDriver.getValue();
  381.         final double    y          = northOffsetDriver.getValue();
  382.         final double    z          = zenithOffsetDriver.getValue();
  383.         final BodyShape baseShape  = baseFrame.getParentShape();
  384.         final Transform baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), offsetCompensatedDate);
  385.         Vector3D        origin     = baseToBody.transformPosition(new Vector3D(x, y, z));
  386.         origin = origin.add(computeDisplacement(offsetCompensatedDate, origin));

  387.         final GeodeticPoint originGP = baseShape.transform(origin, baseShape.getBodyFrame(), offsetCompensatedDate);
  388.         final Transform offsetToIntermediate =
  389.                         new Transform(offsetCompensatedDate,
  390.                                       new Transform(offsetCompensatedDate,
  391.                                                     new Rotation(Vector3D.PLUS_I, Vector3D.PLUS_K,
  392.                                                                  originGP.getEast(), originGP.getZenith()),
  393.                                                     Vector3D.ZERO),
  394.                                       new Transform(offsetCompensatedDate, origin));

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

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

  398.     }

  399.     /** Get the transform between offset frame and inertial frame with derivatives.
  400.      * <p>
  401.      * As the East and North vectors are not well defined at pole, the derivatives
  402.      * of these two vectors diverge to infinity as we get closer to the pole.
  403.      * So this method should not be used for stations less than 0.0001 degree from
  404.      * either poles.
  405.      * </p>
  406.      * @param inertial inertial frame to transform to
  407.      * @param clockDate date of the transform as read by the ground station clock (i.e. clock offset <em>not</em> compensated)
  408.      * @param factory factory for the derivatives
  409.      * @param indices indices of the estimated parameters in derivatives computations
  410.      * @return transform between offset frame and inertial frame, at <em>real</em> measurement
  411.      * date (i.e. with clock, Earth and station offsets applied)
  412.      * @see #getOffsetToInertial(Frame, FieldAbsoluteDate, DSFactory, Map)
  413.      * @since 9.3
  414.      */
  415.     public FieldTransform<DerivativeStructure> getOffsetToInertial(final Frame inertial,
  416.                                                                    final AbsoluteDate clockDate,
  417.                                                                    final DSFactory factory,
  418.                                                                    final Map<String, Integer> indices) {
  419.         // take clock offset into account
  420.         final DerivativeStructure offset = clockOffsetDriver.getValue(factory, indices);
  421.         final FieldAbsoluteDate<DerivativeStructure> offsetCompensatedDate =
  422.                         new FieldAbsoluteDate<DerivativeStructure>(clockDate, offset.negate());

  423.         return getOffsetToInertial(inertial, offsetCompensatedDate, factory, indices);
  424.     }

  425.     /** Get the transform between offset frame and inertial frame with derivatives.
  426.      * <p>
  427.      * As the East and North vectors are not well defined at pole, the derivatives
  428.      * of these two vectors diverge to infinity as we get closer to the pole.
  429.      * So this method should not be used for stations less than 0.0001 degree from
  430.      * either poles.
  431.      * </p>
  432.      * @param inertial inertial frame to transform to
  433.      * @param offsetCompensatedDate date of the transform, clock offset and its derivatives already compensated
  434.      * @param factory factory for the derivatives
  435.      * @param indices indices of the estimated parameters in derivatives computations
  436.      * @return transform between offset frame and inertial frame, at specified date
  437.      * @see #getOffsetToInertial(Frame, AbsoluteDate, DSFactory, Map)
  438.      * @since 9.0
  439.      */
  440.     public FieldTransform<DerivativeStructure> getOffsetToInertial(final Frame inertial,
  441.                                                                    final FieldAbsoluteDate<DerivativeStructure> offsetCompensatedDate,
  442.                                                                    final DSFactory factory,
  443.                                                                    final Map<String, Integer> indices) {

  444.         final Field<DerivativeStructure>         field = factory.getDerivativeField();
  445.         final FieldVector3D<DerivativeStructure> zero  = FieldVector3D.getZero(field);
  446.         final FieldVector3D<DerivativeStructure> plusI = FieldVector3D.getPlusI(field);
  447.         final FieldVector3D<DerivativeStructure> plusK = FieldVector3D.getPlusK(field);

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

  451.         // take station offsets into account
  452.         final DerivativeStructure  x          = eastOffsetDriver.getValue(factory, indices);
  453.         final DerivativeStructure  y          = northOffsetDriver.getValue(factory, indices);
  454.         final DerivativeStructure  z          = zenithOffsetDriver.getValue(factory, indices);
  455.         final BodyShape            baseShape  = baseFrame.getParentShape();
  456.         final Transform            baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), (AbsoluteDate) null);

  457.         FieldVector3D<DerivativeStructure>            origin   = baseToBody.transformPosition(new FieldVector3D<>(x, y, z));
  458.         origin = origin.add(computeDisplacement(offsetCompensatedDate.toAbsoluteDate(), origin.toVector3D()));
  459.         final FieldGeodeticPoint<DerivativeStructure> originGP = baseShape.transform(origin, baseShape.getBodyFrame(), offsetCompensatedDate);
  460.         final FieldTransform<DerivativeStructure> offsetToIntermediate =
  461.                         new FieldTransform<>(offsetCompensatedDate,
  462.                                              new FieldTransform<>(offsetCompensatedDate,
  463.                                                                   new FieldRotation<>(plusI, plusK,
  464.                                                                                       originGP.getEast(), originGP.getZenith()),
  465.                                                                   zero),
  466.                                              new FieldTransform<>(offsetCompensatedDate, origin));

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

  469.         return new FieldTransform<>(offsetCompensatedDate,
  470.                                     offsetToIntermediate,
  471.                                     new FieldTransform<>(offsetCompensatedDate, intermediateToBody, bodyToInert));

  472.     }

  473. }