RangeRateIonosphericDelayModifier.java

  1. /* Copyright 2002-2019 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.estimation.measurements.EstimatedMeasurement;
  23. import org.orekit.estimation.measurements.EstimationModifier;
  24. import org.orekit.estimation.measurements.GroundStation;
  25. import org.orekit.estimation.measurements.RangeRate;
  26. import org.orekit.models.earth.IonosphericModel;
  27. import org.orekit.orbits.OrbitType;
  28. import org.orekit.orbits.PositionAngle;
  29. import org.orekit.propagation.Propagator;
  30. import org.orekit.propagation.SpacecraftState;
  31. import org.orekit.utils.Differentiation;
  32. import org.orekit.utils.ParameterDriver;
  33. import org.orekit.utils.ParameterFunction;
  34. import org.orekit.utils.StateFunction;

  35. /** Class modifying theoretical range-rate measurement with ionospheric delay.
  36.  * The effect of ionospheric correction on the range-rate is directly computed
  37.  * through the computation of the ionospheric delay difference with respect to
  38.  * time.
  39.  *
  40.  * The ionospheric delay depends on the frequency of the signal (GNSS, VLBI, ...).
  41.  * For optical measurements (e.g. SLR), the ray is not affected by ionosphere charged particles.
  42.  *
  43.  * @author Joris Olympio
  44.  * @since 8.0
  45.  */
  46. public class RangeRateIonosphericDelayModifier implements EstimationModifier<RangeRate> {

  47.     /** Ionospheric delay model. */
  48.     private final IonosphericModel ionoModel;

  49.     /** Coefficient for measurment configuration (one-way, two-way). */
  50.     private final double fTwoWay;

  51.     /** Constructor.
  52.      *
  53.      * @param model Ionospheric delay model appropriate for the current range-rate measurement method.
  54.      * @param twoWay Flag indicating whether the measurement is two-way.
  55.      */
  56.     public RangeRateIonosphericDelayModifier(final IonosphericModel model, final boolean twoWay) {
  57.         ionoModel = model;

  58.         if (twoWay) {
  59.             fTwoWay = 2.;
  60.         } else {
  61.             fTwoWay = 1.;
  62.         }
  63.     }

  64.     /** Compute the measurement error due to Ionosphere.
  65.      * @param station station
  66.      * @param state spacecraft state
  67.      * @return the measurement error due to Ionosphere
  68.      */
  69.     private double rangeRateErrorIonosphericModel(final GroundStation station, final SpacecraftState state) {
  70.         // The effect of ionospheric correction on the range rate is
  71.         // computed using finite differences.

  72.         final double dt = 10; // s

  73.         //
  74.         final Vector3D position = state.getPVCoordinates().getPosition();

  75.         // elevation
  76.         final double elevation = station.getBaseFrame().getElevation(position,
  77.                                                                      state.getFrame(),
  78.                                                                      state.getDate());

  79.         // only consider measures above the horizon
  80.         if (elevation > 0) {

  81.             // compute azimuth
  82.             final double azimuth = station.getBaseFrame().getAzimuth(position,
  83.                                                                      state.getFrame(),
  84.                                                                      state.getDate());

  85.             // delay in meters
  86.             final double delay1 = ionoModel.pathDelay(state.getDate(),
  87.                                                       station.getBaseFrame().getPoint(),
  88.                                                       elevation,
  89.                                                       azimuth);

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

  92.             // spacecraft position and elevation as seen from the ground station
  93.             final Vector3D position2 = state2.getPVCoordinates().getPosition();
  94.             final double elevation2 = station.getBaseFrame().getElevation(position2,
  95.                                                                           state2.getFrame(),
  96.                                                                           state2.getDate());

  97.             // compute azimuth in degrees
  98.             final double azimuth2 = station.getBaseFrame().getAzimuth(position2,
  99.                                                                       state2.getFrame(),
  100.                                                                       state2.getDate());

  101.             // ionospheric delay dt after in meters
  102.             final double delay2 = ionoModel.pathDelay(state2.getDate(),
  103.                                                       station.getBaseFrame().getPoint(),
  104.                                                       elevation2,
  105.                                                       azimuth2);

  106.             // delay in meters
  107.             return fTwoWay * (delay2 - delay1) / dt;
  108.         }

  109.         return 0;
  110.     }

  111.     /** Compute the Jacobian of the delay term wrt state.
  112.      *
  113.      * @param station station
  114.      * @param refstate reference spacecraft state
  115.      *
  116.      * @return Jacobian of the delay wrt state
  117.      */
  118.     private double[][] rangeErrorJacobianState(final GroundStation station,
  119.                                                final SpacecraftState refstate) {
  120.         final double[][] finiteDifferencesJacobian =
  121.                         Differentiation.differentiate(new StateFunction() {
  122.                             public double[] value(final SpacecraftState state) {
  123.                                 // evaluate target's elevation with a changed target position
  124.                                 final double value = rangeRateErrorIonosphericModel(station, state);

  125.                                 return new double[] {value };
  126.                             }
  127.                         }, 1, Propagator.DEFAULT_LAW, OrbitType.CARTESIAN,
  128.                         PositionAngle.TRUE, 15.0, 3).value(refstate);

  129.         return finiteDifferencesJacobian;
  130.     }


  131.     /** Compute the derivative of the delay term wrt parameters.
  132.     *
  133.     * @param station ground station
  134.     * @param driver driver for the station offset parameter
  135.     * @param state spacecraft state
  136.     * @param delay current ionospheric delay
  137.     * @return derivative of the delay wrt station offset parameter
  138.     */
  139.     private double rangeRateErrorParameterDerivative(final GroundStation station,
  140.                                                      final ParameterDriver driver,
  141.                                                      final SpacecraftState state,
  142.                                                      final double delay) {

  143.         final ParameterFunction rangeError = new ParameterFunction() {
  144.             /** {@inheritDoc} */
  145.             @Override
  146.             public double value(final ParameterDriver parameterDriver) {
  147.                 return rangeRateErrorIonosphericModel(station, state);
  148.             }
  149.         };

  150.         final ParameterFunction rangeErrorDerivative =
  151.                         Differentiation.differentiate(rangeError, 3, 10.0 * driver.getScale());

  152.         return rangeErrorDerivative.value(driver);

  153.     }

  154.     /** {@inheritDoc} */
  155.     @Override
  156.     public List<ParameterDriver> getParametersDrivers() {
  157.         return Collections.emptyList();
  158.     }

  159.     /** {@inheritDoc} */
  160.     @Override
  161.     public void modify(final EstimatedMeasurement<RangeRate> estimated) {

  162.         final RangeRate       measurement = estimated.getObservedMeasurement();
  163.         final GroundStation   station     = measurement.getStation();
  164.         final SpacecraftState state       = estimated.getStates()[0];

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

  166.         final double delay = rangeRateErrorIonosphericModel(station, state);

  167.         // update estimated value taking into account the ionospheric delay.
  168.         // The ionospheric delay is directly added to the range.
  169.         final double[] newValue = oldValue.clone();
  170.         newValue[0] = newValue[0] + delay;
  171.         estimated.setEstimatedValue(newValue);

  172.         // update estimated derivatives with Jacobian of the measure wrt state
  173.         final double[][] djac = rangeErrorJacobianState(station,
  174.                                       state);
  175.         final double[][] stateDerivatives = estimated.getStateDerivatives(0);
  176.         for (int irow = 0; irow < stateDerivatives.length; ++irow) {
  177.             for (int jcol = 0; jcol < stateDerivatives[0].length; ++jcol) {
  178.                 stateDerivatives[irow][jcol] += djac[irow][jcol];
  179.             }
  180.         }
  181.         estimated.setStateDerivatives(0, stateDerivatives);

  182.         for (final ParameterDriver driver : Arrays.asList(station.getClockOffsetDriver(),
  183.                                                           station.getEastOffsetDriver(),
  184.                                                           station.getNorthOffsetDriver(),
  185.                                                           station.getZenithOffsetDriver())) {
  186.             if (driver.isSelected()) {
  187.                 // update estimated derivatives with derivative of the modification wrt station parameters
  188.                 double parameterDerivative = estimated.getParameterDerivatives(driver)[0];
  189.                 parameterDerivative += rangeRateErrorParameterDerivative(station, driver, state, delay);
  190.                 estimated.setParameterDerivatives(driver, parameterDerivative);
  191.             }
  192.         }

  193.     }

  194. }