RangeRateTroposphericDelayModifier.java

  1. /* Copyright 2002-2018 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.modifiers;

  18. import java.util.Arrays;
  19. import java.util.Collections;
  20. import java.util.List;

  21. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  22. import org.orekit.errors.OrekitException;
  23. import org.orekit.errors.OrekitExceptionWrapper;
  24. import org.orekit.estimation.measurements.EstimatedMeasurement;
  25. import org.orekit.estimation.measurements.EstimationModifier;
  26. import org.orekit.estimation.measurements.GroundStation;
  27. import org.orekit.estimation.measurements.RangeRate;
  28. import org.orekit.models.earth.TroposphericModel;
  29. import org.orekit.orbits.OrbitType;
  30. import org.orekit.orbits.PositionAngle;
  31. import org.orekit.propagation.Propagator;
  32. import org.orekit.propagation.SpacecraftState;
  33. import org.orekit.utils.Differentiation;
  34. import org.orekit.utils.ParameterDriver;
  35. import org.orekit.utils.ParameterFunction;
  36. import org.orekit.utils.StateFunction;

  37. /** Class modifying theoretical range-rate measurements with tropospheric delay.
  38.  * The effect of tropospheric correction on the range-rate is directly computed
  39.  * through the computation of the tropospheric delay difference with respect to
  40.  * time.
  41.  *
  42.  * In general, for GNSS, VLBI, ... there is hardly any frequency dependence in the delay.
  43.  * For SLR techniques however, the frequency dependence is sensitive.
  44.  *
  45.  * @author Joris Olympio
  46.  * @since 8.0
  47.  */
  48. public class RangeRateTroposphericDelayModifier implements EstimationModifier<RangeRate> {

  49.     /** Tropospheric delay model. */
  50.     private final TroposphericModel tropoModel;

  51.     /** Two-way measurement factor. */
  52.     private final double fTwoWay;

  53.     /** Constructor.
  54.      *
  55.      * @param model  Tropospheric delay model appropriate for the current range-rate measurement method.
  56.      * @param tw     Flag indicating whether the measurement is two-way.
  57.      */
  58.     public RangeRateTroposphericDelayModifier(final TroposphericModel model, final boolean tw) {
  59.         tropoModel = model;
  60.         if (tw) {
  61.             fTwoWay = 2.;
  62.         } else {
  63.             fTwoWay = 1.;
  64.         }
  65.     }

  66.     /** Get the station height above mean sea level.
  67.      *
  68.      * @param station  ground station (or measuring station)
  69.      * @return the measuring station height above sea level, m
  70.      */
  71.     private double getStationHeightAMSL(final GroundStation station) {
  72.         // FIXME heigth should be computed with respect to geoid WGS84+GUND = EGM2008 for example
  73.         final double height = station.getBaseFrame().getPoint().getAltitude();
  74.         return height;
  75.     }

  76.     /** Compute the measurement error due to Troposphere.
  77.      * @param station station
  78.      * @param state spacecraft state
  79.      * @return the measurement error due to Troposphere
  80.      * @throws OrekitException  if frames transformations cannot be computed
  81.      */
  82.     public double rangeRateErrorTroposphericModel(final GroundStation station,
  83.                                                   final SpacecraftState state)
  84.         throws OrekitException {
  85.         // The effect of tropospheric correction on the range rate is
  86.         // computed using finite differences.

  87.         final double dt = 10; // s

  88.         // station altitude AMSL in meters
  89.         final double height = getStationHeightAMSL(station);

  90.         // spacecraft position and elevation as seen from the ground station
  91.         final Vector3D position = state.getPVCoordinates().getPosition();

  92.         // elevation
  93.         final double elevation1 = station.getBaseFrame().getElevation(position,
  94.                                                                       state.getFrame(),
  95.                                                                       state.getDate());

  96.         // only consider measures above the horizon
  97.         if (elevation1 > 0) {
  98.             // tropospheric delay in meters
  99.             final double d1 = tropoModel.pathDelay(elevation1, height);

  100.             // propagate spacecraft state forward by dt
  101.             final SpacecraftState state2 = state.shiftedBy(dt);

  102.             // spacecraft position and elevation as seen from the ground station
  103.             final Vector3D position2 = state2.getPVCoordinates().getPosition();

  104.             // elevation
  105.             final double elevation2 = station.getBaseFrame().getElevation(position2,
  106.                                                                           state2.getFrame(),
  107.                                                                           state2.getDate());

  108.             // tropospheric delay dt after
  109.             final double d2 = tropoModel.pathDelay(elevation2, height);

  110.             return fTwoWay * (d2 - d1) / dt;
  111.         }

  112.         return 0;
  113.     }


  114.     /** Compute the Jacobian of the delay term wrt state.
  115.      *
  116.      * @param station station
  117.      * @param refstate spacecraft state
  118.      * @param delay current tropospheric delay
  119.      * @return Jacobian of the delay wrt state
  120.      * @throws OrekitException  if frames transformations cannot be computed
  121.      */
  122.     private double[][] rangeRateErrorJacobianState(final GroundStation station,
  123.                                                    final SpacecraftState refstate,
  124.                                                    final double delay)
  125.         throws OrekitException {
  126.         final double[][] finiteDifferencesJacobian =
  127.                         Differentiation.differentiate(new StateFunction() {
  128.                             public double[] value(final SpacecraftState state) throws OrekitException {
  129.                                 try {
  130.                                     // evaluate target's elevation with a changed target position
  131.                                     final double value = rangeRateErrorTroposphericModel(station, state);

  132.                                     return new double[] {value };

  133.                                 } catch (OrekitException oe) {
  134.                                     throw new OrekitExceptionWrapper(oe);
  135.                                 }
  136.                             }
  137.                         }, 1, Propagator.DEFAULT_LAW, OrbitType.CARTESIAN,
  138.                         PositionAngle.TRUE, 15.0, 3).value(refstate);

  139.         return finiteDifferencesJacobian;
  140.     }

  141.     /** Compute the derivative of the delay term wrt parameters.
  142.     *
  143.     * @param station ground station
  144.     * @param driver driver for the station offset parameter
  145.     * @param state spacecraft state
  146.     * @param delay current ionospheric delay
  147.     * @return derivative of the delay wrt station offset parameter
  148.     * @throws OrekitException  if frames transformations cannot be computed
  149.     */
  150.     private double rangeRateErrorParameterDerivative(final GroundStation station,
  151.                                                      final ParameterDriver driver,
  152.                                                      final SpacecraftState state,
  153.                                                      final double delay)
  154.         throws OrekitException {

  155.         final ParameterFunction rangeError = new ParameterFunction() {
  156.             /** {@inheritDoc} */
  157.             @Override
  158.             public double value(final ParameterDriver parameterDriver) throws OrekitException {
  159.                 return rangeRateErrorTroposphericModel(station, state);
  160.             }
  161.         };

  162.         final ParameterFunction rangeErrorDerivative =
  163.                         Differentiation.differentiate(rangeError, driver, 3, 10.0);

  164.         return rangeErrorDerivative.value(driver);

  165.     }

  166.     /** {@inheritDoc} */
  167.     @Override
  168.     public List<ParameterDriver> getParametersDrivers() {
  169.         return Collections.emptyList();
  170.     }

  171.     /** {@inheritDoc} */
  172.     @Override
  173.     public void modify(final EstimatedMeasurement<RangeRate> estimated)
  174.         throws OrekitException {
  175.         final RangeRate       measurement = estimated.getObservedMeasurement();
  176.         final GroundStation   station     = measurement.getStation();
  177.         final SpacecraftState state       = estimated.getStates()[0];

  178.         final double[] oldValue = estimated.getEstimatedValue();

  179.         final double delay = rangeRateErrorTroposphericModel(station, state);

  180.         // update estimated value taking into account the tropospheric delay.
  181.         // The tropospheric delay is directly added to the range.
  182.         final double[] newValue = oldValue.clone();
  183.         newValue[0] = newValue[0] + delay;
  184.         estimated.setEstimatedValue(newValue);

  185.         // update estimated derivatives with Jacobian of the measure wrt state
  186.         final double[][] djac = rangeRateErrorJacobianState(station,
  187.                                       state,
  188.                                       delay);
  189.         final double[][] stateDerivatives = estimated.getStateDerivatives(0);
  190.         for (int irow = 0; irow < stateDerivatives.length; ++irow) {
  191.             for (int jcol = 0; jcol < stateDerivatives[0].length; ++jcol) {
  192.                 stateDerivatives[irow][jcol] += djac[irow][jcol];
  193.             }
  194.         }
  195.         estimated.setStateDerivatives(0, stateDerivatives);

  196.         for (final ParameterDriver driver : Arrays.asList(station.getEastOffsetDriver(),
  197.                                                           station.getNorthOffsetDriver(),
  198.                                                           station.getZenithOffsetDriver())) {
  199.             if (driver.isSelected()) {
  200.                 // update estimated derivatives with derivative of the modification wrt station parameters
  201.                 double parameterDerivative = estimated.getParameterDerivatives(driver)[0];
  202.                 parameterDerivative += rangeRateErrorParameterDerivative(station, driver, state, delay);
  203.                 estimated.setParameterDerivatives(driver, parameterDerivative);
  204.             }
  205.         }

  206.     }

  207. }