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

  49.     /** Ionospheric delay model. */
  50.     private final IonosphericModel ionoModel;

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

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

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

  66.     /** Compute the measurement error due to Ionosphere.
  67.      * @param station station
  68.      * @param state spacecraft state
  69.      * @return the measurement error due to Ionosphere
  70.      * @throws OrekitException  if frames transformations cannot be computed
  71.      */
  72.     private double rangeRateErrorIonosphericModel(final GroundStation station, final SpacecraftState state)
  73.         throws OrekitException {
  74.         // The effect of ionospheric correction on the range rate is
  75.         // computed using finite differences.

  76.         final double dt = 10; // s

  77.         //
  78.         final Vector3D position = state.getPVCoordinates().getPosition();

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

  83.         // only consider measures above the horizon
  84.         if (elevation > 0) {

  85.             // compute azimuth
  86.             final double azimuth = station.getBaseFrame().getAzimuth(position,
  87.                                                                      state.getFrame(),
  88.                                                                      state.getDate());

  89.             // delay in meters
  90.             final double delay1 = ionoModel.pathDelay(state.getDate(),
  91.                                                       station.getBaseFrame().getPoint(),
  92.                                                       elevation,
  93.                                                       azimuth);

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

  96.             // spacecraft position and elevation as seen from the ground station
  97.             final Vector3D position2 = state2.getPVCoordinates().getPosition();
  98.             final double elevation2 = station.getBaseFrame().getElevation(position2,
  99.                                                                           state2.getFrame(),
  100.                                                                           state2.getDate());

  101.             // compute azimuth in degrees
  102.             final double azimuth2 = station.getBaseFrame().getAzimuth(position2,
  103.                                                                       state2.getFrame(),
  104.                                                                       state2.getDate());

  105.             // ionospheric delay dt after in meters
  106.             final double delay2 = ionoModel.pathDelay(state2.getDate(),
  107.                                                       station.getBaseFrame().getPoint(),
  108.                                                       elevation2,
  109.                                                       azimuth2);

  110.             // delay in meters
  111.             return fTwoWay * (delay2 - delay1) / dt;
  112.         }

  113.         return 0;
  114.     }

  115.     /** Compute the Jacobian of the delay term wrt state.
  116.      *
  117.      * @param station station
  118.      * @param refstate reference spacecraft state
  119.      *
  120.      * @return Jacobian of the delay wrt state
  121.      * @throws OrekitException  if frames transformations cannot be computed
  122.      */
  123.     private double[][] rangeErrorJacobianState(final GroundStation station,
  124.                                                final SpacecraftState refstate)
  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 = rangeRateErrorIonosphericModel(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 rangeRateErrorIonosphericModel(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 = rangeRateErrorIonosphericModel(station, state);

  180.         // update estimated value taking into account the ionospheric delay.
  181.         // The ionospheric 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 = rangeErrorJacobianState(station,
  187.                                       state);
  188.         final double[][] stateDerivatives = estimated.getStateDerivatives(0);
  189.         for (int irow = 0; irow < stateDerivatives.length; ++irow) {
  190.             for (int jcol = 0; jcol < stateDerivatives[0].length; ++jcol) {
  191.                 stateDerivatives[irow][jcol] += djac[irow][jcol];
  192.             }
  193.         }
  194.         estimated.setStateDerivatives(0, stateDerivatives);

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

  205.     }

  206. }