RangeTroposphericDelayModifier.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.Range;
  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 measurement with tropospheric delay.
  38.  * The effect of tropospheric correction on the range is directly computed
  39.  * through the computation of the tropospheric delay.
  40.  *
  41.  * In general, for GNSS, VLBI, ... there is hardly any frequency dependence in the delay.
  42.  * For SLR techniques however, the frequency dependence is sensitive.
  43.  *
  44.  * @author Maxime Journot
  45.  * @author Joris Olympio
  46.  * @since 8.0
  47.  */
  48. public class RangeTroposphericDelayModifier implements EstimationModifier<Range> {

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

  51.     /** Constructor.
  52.      *
  53.      * @param model  Tropospheric delay model appropriate for the current range measurement method.
  54.      */
  55.     public RangeTroposphericDelayModifier(final TroposphericModel model) {
  56.         tropoModel = model;
  57.     }

  58.     /** Get the station height above mean sea level.
  59.      *
  60.      * @param station  ground station (or measuring station)
  61.      * @return the measuring station height above sea level, m
  62.      */
  63.     private double getStationHeightAMSL(final GroundStation station) {
  64.         // FIXME heigth should be computed with respect to geoid WGS84+GUND = EGM2008 for example
  65.         final double height = station.getBaseFrame().getPoint().getAltitude();
  66.         return height;
  67.     }

  68.     /** Compute the measurement error due to Troposphere.
  69.      * @param station station
  70.      * @param state spacecraft state
  71.      * @return the measurement error due to Troposphere
  72.      * @throws OrekitException  if frames transformations cannot be computed
  73.      */
  74.     private double rangeErrorTroposphericModel(final GroundStation station, final SpacecraftState state)
  75.         throws OrekitException {
  76.         //
  77.         final Vector3D position = state.getPVCoordinates().getPosition();

  78.         // elevation
  79.         final double elevation = station.getBaseFrame().getElevation(position,
  80.                                                                      state.getFrame(),
  81.                                                                      state.getDate());

  82.         // only consider measures above the horizon
  83.         if (elevation > 0) {
  84.             // altitude AMSL in meters
  85.             final double height = getStationHeightAMSL(station);

  86.             // delay in meters
  87.             final double delay = tropoModel.pathDelay(elevation, height);

  88.             return delay;
  89.         }

  90.         return 0;
  91.     }

  92.     /** Compute the Jacobian of the delay term wrt state.
  93.      *
  94.      * @param station station
  95.      * @param refstate reference spacecraft state
  96.      *
  97.      * @return Jacobian of the delay wrt state
  98.      * @throws OrekitException  if frames transformations cannot be computed
  99.      */
  100.     private double[][] rangeErrorJacobianState(final GroundStation station, final SpacecraftState refstate)
  101.         throws OrekitException {
  102.         final double[][] finiteDifferencesJacobian =
  103.                         Differentiation.differentiate(new StateFunction() {
  104.                             public double[] value(final SpacecraftState state) throws OrekitException {
  105.                                 try {
  106.                                     // evaluate target's elevation with a changed target position
  107.                                     final double value = rangeErrorTroposphericModel(station, state);

  108.                                     return new double[] {value };

  109.                                 } catch (OrekitException oe) {
  110.                                     throw new OrekitExceptionWrapper(oe);
  111.                                 }
  112.                             }
  113.                         }, 1, Propagator.DEFAULT_LAW, OrbitType.CARTESIAN,
  114.                         PositionAngle.TRUE, 15.0, 3).value(refstate);

  115.         return finiteDifferencesJacobian;
  116.     }


  117.     /** Compute the derivative of the delay term wrt parameters.
  118.      *
  119.      * @param station ground station
  120.      * @param driver driver for the station offset parameter
  121.      * @param state spacecraft state
  122.      * @param delay current ionospheric delay
  123.      * @return derivative of the delay wrt station offset parameter
  124.      * @throws OrekitException  if frames transformations cannot be computed
  125.      */
  126.     private double rangeErrorParameterDerivative(final GroundStation station,
  127.                                                  final ParameterDriver driver,
  128.                                                  final SpacecraftState state,
  129.                                                  final double delay)
  130.         throws OrekitException {

  131.         final ParameterFunction rangeError = new ParameterFunction() {
  132.             /** {@inheritDoc} */
  133.             @Override
  134.             public double value(final ParameterDriver parameterDriver) throws OrekitException {
  135.                 return rangeErrorTroposphericModel(station, state);
  136.             }
  137.         };

  138.         final ParameterFunction rangeErrorDerivative =
  139.                         Differentiation.differentiate(rangeError, driver, 3, 10.0);

  140.         return rangeErrorDerivative.value(driver);

  141.     }

  142.     /** {@inheritDoc} */
  143.     @Override
  144.     public List<ParameterDriver> getParametersDrivers() {
  145.         return Collections.emptyList();
  146.     }

  147.     /** {@inheritDoc} */
  148.     @Override
  149.     public void modify(final EstimatedMeasurement<Range> estimated)
  150.         throws OrekitException {
  151.         final Range           measurement = estimated.getObservedMeasurement();
  152.         final GroundStation   station     = measurement.getStation();
  153.         final SpacecraftState state       = estimated.getStates()[0];

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

  155.         final double delay = rangeErrorTroposphericModel(station, state);

  156.         // update estimated value taking into account the tropospheric delay.
  157.         // The tropospheric delay is directly added to the range.
  158.         final double[] newValue = oldValue.clone();
  159.         newValue[0] = newValue[0] + delay;
  160.         estimated.setEstimatedValue(newValue);

  161.         // update estimated derivatives with Jacobian of the measure wrt state
  162.         final double[][] djac = rangeErrorJacobianState(station,
  163.                                       state);
  164.         final double[][] stateDerivatives = estimated.getStateDerivatives(0);
  165.         for (int irow = 0; irow < stateDerivatives.length; ++irow) {
  166.             for (int jcol = 0; jcol < stateDerivatives[0].length; ++jcol) {
  167.                 stateDerivatives[irow][jcol] += djac[irow][jcol];
  168.             }
  169.         }
  170.         estimated.setStateDerivatives(0, stateDerivatives);

  171.         for (final ParameterDriver driver : Arrays.asList(station.getEastOffsetDriver(),
  172.                                                           station.getNorthOffsetDriver(),
  173.                                                           station.getZenithOffsetDriver())) {
  174.             if (driver.isSelected()) {
  175.                 // update estimated derivatives with derivative of the modification wrt station parameters
  176.                 double parameterDerivative = estimated.getParameterDerivatives(driver)[0];
  177.                 parameterDerivative += rangeErrorParameterDerivative(station, driver, state, delay);
  178.                 estimated.setParameterDerivatives(driver, parameterDerivative);
  179.             }
  180.         }

  181.     }

  182. }