1   /* Copyright 2002-2024 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 org.hipparchus.CalculusFieldElement;
20  import org.orekit.attitudes.FrameAlignedProvider;
21  import org.orekit.estimation.measurements.EstimatedMeasurement;
22  import org.orekit.estimation.measurements.EstimatedMeasurementBase;
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.troposphere.TroposphericModel;
27  import org.orekit.propagation.FieldSpacecraftState;
28  import org.orekit.propagation.SpacecraftState;
29  
30  /** Class modifying theoretical range-rate measurements with tropospheric delay.
31   * <p>
32   * The effect of tropospheric correction on the range-rate is directly computed
33   * through the computation of the tropospheric delay difference with respect to
34   * time.
35   * </p>
36   * <p>
37   * In general, for GNSS, VLBI, ... there is hardly any frequency dependence in the delay.
38   * For SLR techniques however, the frequency dependence is sensitive.
39   * </p>
40   *
41   * @author Joris Olympio
42   * @since 8.0
43   */
44  public class RangeRateTroposphericDelayModifier extends BaseRangeRateTroposphericDelayModifier implements EstimationModifier<RangeRate> {
45  
46      /** Two-way measurement factor. */
47      private final double fTwoWay;
48  
49      /** Constructor.
50      *
51      * @param model  Tropospheric delay model appropriate for the current range-rate measurement method.
52      * @param tw     Flag indicating whether the measurement is two-way.
53      * @deprecated as of 12.1, replaced byb {@link #RangeRateTroposphericDelayModifier(TroposphericModel, boolean)}
54      */
55      @Deprecated
56      public RangeRateTroposphericDelayModifier(final org.orekit.models.earth.troposphere.DiscreteTroposphericModel model,
57                                                final boolean tw) {
58          super(model);
59          if (tw) {
60              fTwoWay = 2.;
61          } else {
62              fTwoWay = 1.;
63          }
64      }
65  
66      /** Constructor.
67       *
68       * @param model  Tropospheric delay model appropriate for the current range-rate measurement method.
69       * @param tw     Flag indicating whether the measurement is two-way.
70       * @since 12.1
71       */
72      public RangeRateTroposphericDelayModifier(final TroposphericModel model, final boolean tw) {
73          super(model);
74          if (tw) {
75              fTwoWay = 2.;
76          } else {
77              fTwoWay = 1.;
78          }
79      }
80  
81      /** Compute the measurement error due to Troposphere.
82       * @param station station
83       * @param state spacecraft state
84       * @return the measurement error due to Troposphere
85       */
86      @Override
87      public double rangeRateErrorTroposphericModel(final GroundStation station,
88                                                    final SpacecraftState state) {
89          return fTwoWay * super.rangeRateErrorTroposphericModel(station, state);
90      }
91  
92  
93      /** Compute the measurement error due to Troposphere.
94       * @param <T> type of the element
95       * @param station station
96       * @param state spacecraft state
97       * @param parameters tropospheric model parameters
98       * @return the measurement error due to Troposphere
99       */
100     @Override
101     public <T extends CalculusFieldElement<T>> T rangeRateErrorTroposphericModel(final GroundStation station,
102                                                                                  final FieldSpacecraftState<T> state,
103                                                                                  final T[] parameters) {
104         return super.rangeRateErrorTroposphericModel(station, state, parameters).multiply(fTwoWay);
105     }
106 
107     /** {@inheritDoc} */
108     @Override
109     public void modifyWithoutDerivatives(final EstimatedMeasurementBase<RangeRate> estimated) {
110 
111         final RangeRate       measurement = estimated.getObservedMeasurement();
112         final GroundStation   station     = measurement.getStation();
113 
114         RangeRateModifierUtil.modifyWithoutDerivatives(estimated,  station, this::rangeRateErrorTroposphericModel, this);
115 
116 
117     }
118 
119     /** {@inheritDoc} */
120     @Override
121     public void modify(final EstimatedMeasurement<RangeRate> estimated) {
122 
123         final RangeRate       measurement = estimated.getObservedMeasurement();
124         final GroundStation   station     = measurement.getStation();
125         final SpacecraftState state       = estimated.getStates()[0];
126 
127         RangeRateModifierUtil.modify(estimated, getTropoModel(),
128                                      new ModifierGradientConverter(state, 6, new FrameAlignedProvider(state.getFrame())),
129                                      station,
130                                      this::rangeRateErrorTroposphericModel,
131                                      this::rangeRateErrorTroposphericModel,
132                                      this);
133 
134 
135     }
136 
137 }