1   /* Copyright 2002-2021 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.modifiers;
18  
19  import java.util.List;
20  
21  import org.hipparchus.geometry.euclidean.threed.Vector3D;
22  import org.hipparchus.util.MathUtils;
23  import org.orekit.estimation.measurements.AngularAzEl;
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.frames.Frame;
28  import org.orekit.models.earth.troposphere.DiscreteTroposphericModel;
29  import org.orekit.propagation.SpacecraftState;
30  import org.orekit.time.AbsoluteDate;
31  import org.orekit.utils.Constants;
32  import org.orekit.utils.ParameterDriver;
33  
34  /** Class modifying theoretical angular measurement with tropospheric delay.
35   * The effect of tropospheric correction on the angular is computed
36   * through the computation of the tropospheric delay.The spacecraft state
37   * is shifted by the computed delay time and elevation and azimuth are computed
38   * again with the new spacecraft state.
39   *
40   * In general, for GNSS, VLBI, ... there is hardly any frequency dependence in the delay.
41   * For SLR techniques however, the frequency dependence is sensitive.
42   *
43   * @author Thierry Ceolin
44   * @since 8.0
45   */
46  public class AngularTroposphericDelayModifier implements EstimationModifier<AngularAzEl> {
47  
48      /** Tropospheric delay model. */
49      private final DiscreteTroposphericModel tropoModel;
50  
51      /** Constructor.
52       *
53       * @param model  Tropospheric delay model appropriate for the current angular measurement method.
54       */
55      public AngularTroposphericDelayModifier(final DiscreteTroposphericModel model) {
56          tropoModel = model;
57      }
58  
59      /** Compute the measurement error due to Troposphere.
60       * @param station station
61       * @param state spacecraft state
62       * @return the measurement error due to Troposphere
63       */
64      private double angularErrorTroposphericModel(final GroundStation station,
65                                                   final SpacecraftState state) {
66          //
67          final Vector3D position = state.getPVCoordinates().getPosition();
68  
69          // elevation
70          final double elevation = station.getBaseFrame().getElevation(position,
71                                                                       state.getFrame(),
72                                                                       state.getDate());
73  
74          // only consider measures above the horizon
75          if (elevation > 0.0) {
76              // delay in meters
77              final double delay = tropoModel.pathDelay(elevation, station.getBaseFrame().getPoint(), tropoModel.getParameters(), state.getDate());
78  
79              // one-way measurement.
80              return delay;
81          }
82  
83          return 0;
84      }
85  
86      /** {@inheritDoc} */
87      @Override
88      public List<ParameterDriver> getParametersDrivers() {
89          return tropoModel.getParametersDrivers();
90      }
91  
92      @Override
93      public void modify(final EstimatedMeasurement<AngularAzEl> estimated) {
94          final AngularAzEl     measure = estimated.getObservedMeasurement();
95          final GroundStation   station = measure.getStation();
96          final SpacecraftState state   = estimated.getStates()[0];
97  
98          final double delay = angularErrorTroposphericModel(station, state);
99          // Delay is taken into account to shift the spacecraft position
100         final double dt = delay / Constants.SPEED_OF_LIGHT;
101 
102         // Position of the spacecraft shifted of dt
103         final SpacecraftState transitState = state.shiftedBy(-dt);
104 
105         // Update measurement value taking into account the ionospheric delay.
106         final AbsoluteDate date      = transitState.getDate();
107         final Vector3D     position  = transitState.getPVCoordinates().getPosition();
108         final Frame        inertial  = transitState.getFrame();
109 
110         // Elevation and azimuth in radians
111         final double elevation   = station.getBaseFrame().getElevation(position, inertial, date);
112         final double baseAzimuth = station.getBaseFrame().getAzimuth(position, inertial, date);
113         final double twoPiWrap   = MathUtils.normalizeAngle(baseAzimuth, measure.getObservedValue()[0]) - baseAzimuth;
114         final double azimuth     = baseAzimuth + twoPiWrap;
115 
116         // Update estimated value taking into account the tropospheric delay.
117         // Azimuth - elevation values
118         estimated.setEstimatedValue(azimuth, elevation);
119     }
120 }