1 /* Copyright 2002-2024 Thales Alenia Space
2 * Licensed to CS Communication & Systèmes (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.models.earth.troposphere;
18
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.hipparchus.CalculusFieldElement;
23 import org.hipparchus.Field;
24 import org.hipparchus.analysis.interpolation.LinearInterpolator;
25 import org.hipparchus.analysis.polynomials.PolynomialSplineFunction;
26 import org.hipparchus.util.FastMath;
27 import org.orekit.bodies.FieldGeodeticPoint;
28 import org.orekit.bodies.GeodeticPoint;
29 import org.orekit.models.earth.weather.FieldPressureTemperatureHumidity;
30 import org.orekit.models.earth.weather.HeightDependentPressureTemperatureHumidityConverter;
31 import org.orekit.models.earth.weather.PressureTemperatureHumidity;
32 import org.orekit.time.AbsoluteDate;
33 import org.orekit.time.FieldAbsoluteDate;
34 import org.orekit.utils.FieldTrackingCoordinates;
35 import org.orekit.utils.ParameterDriver;
36 import org.orekit.utils.TrackingCoordinates;
37
38 /** The canonical Saastamoinen model.
39 * <p>
40 * Estimates the path delay imposed to
41 * electro-magnetic signals by the troposphere according to the formula:
42 * \[
43 * \delta = \frac{0.002277}{\cos z (1 - 0.00266\cos 2\varphi - 0.00028 h})}
44 * \left[P+(\frac{1255}{T}+0.005)e - B(h) \tan^2 z\right]
45 * \]
46 * with the following input data provided to the model:
47 * <ul>
48 * <li>z: zenith angle</li>
49 * <li>P: atmospheric pressure</li>
50 * <li>T: temperature</li>
51 * <li>e: partial pressure of water vapor</li>
52 * </ul>
53 * @author Luc Maisonobe
54 * @see "J Saastamoinen, Atmospheric Correction for the Troposphere and Stratosphere in Radio
55 * Ranging of Satellites"
56 * @since 12.1
57 */
58 public class CanonicalSaastamoinenModel implements TroposphericModel {
59
60 /** Default lowest acceptable elevation angle [rad]. */
61 public static final double DEFAULT_LOW_ELEVATION_THRESHOLD = 0.05;
62
63 /** Base delay coefficient. */
64 private static final double L0 = 2.2768e-5;
65
66 /** Temperature numerator. */
67 private static final double T_NUM = 1255;
68
69 /** Wet offset. */
70 private static final double WET_OFFSET = 0.05;
71
72 /** X values for the B function (table 1 in reference paper). */
73 private static final double[] X_VALUES_FOR_B = {
74 0.0, 200.0, 400.0, 600.0, 800.0, 1000.0, 1500.0, 2000.0, 2500.0, 3000.0, 4000.0, 5000.0, 6000.0
75 };
76
77 /** Y values for the B function (table 1 in reference paper).
78 * <p>
79 * The values have been scaled up by a factor 100.0 due to conversion from hPa to Pa.
80 * </p>
81 */
82 private static final double[] Y_VALUES_FOR_B = {
83 116.0, 113.0, 110.0, 107.0, 104.0, 101.0, 94.0, 88.0, 82.0, 76.0, 66.0, 57.0, 49.0
84 };
85
86 /** Interpolation function for the B correction term. */
87 private static final PolynomialSplineFunction B_FUNCTION;
88
89 static {
90 B_FUNCTION = new LinearInterpolator().interpolate(X_VALUES_FOR_B, Y_VALUES_FOR_B);
91 }
92
93 /** Lowest acceptable elevation angle [rad]. */
94 private double lowElevationThreshold;
95
96 /**
97 * Create a new Saastamoinen model for the troposphere using the given environmental
98 * conditions and table from the reference book.
99 *
100 * @see HeightDependentPressureTemperatureHumidityConverter
101 */
102 public CanonicalSaastamoinenModel() {
103 this.lowElevationThreshold = DEFAULT_LOW_ELEVATION_THRESHOLD;
104 }
105
106 /** {@inheritDoc}
107 * <p>
108 * The Saastamoinen model is not defined for altitudes below 0.0. for continuity
109 * reasons, we use the value for h = 0 when altitude is negative.
110 * </p>
111 * <p>
112 * There are also numerical issues for elevation angles close to zero. For continuity reasons,
113 * elevations lower than a threshold will use the value obtained
114 * for the threshold itself.
115 * </p>
116 * @see #getLowElevationThreshold()
117 * @see #setLowElevationThreshold(double)
118 */
119 @Override
120 public TroposphericDelay pathDelay(final TrackingCoordinates trackingCoordinates, final GeodeticPoint point,
121 final PressureTemperatureHumidity weather,
122 final double[] parameters, final AbsoluteDate date) {
123
124 // there are no data in the model for negative altitudes and altitude bigger than 6000 m
125 // limit the height to a range of [0, 5000] m
126 final double fixedHeight = FastMath.min(FastMath.max(point.getAltitude(), X_VALUES_FOR_B[0]),
127 X_VALUES_FOR_B[X_VALUES_FOR_B.length - 1]);
128
129 // interpolate the b correction term
130 final double B = B_FUNCTION.value(fixedHeight);
131
132 // calculate the zenith angle from the elevation
133 final double z = FastMath.abs(0.5 * FastMath.PI - FastMath.max(trackingCoordinates.getElevation(),
134 lowElevationThreshold));
135
136 // calculate the path delay
137 final double invCos = 1.0 / FastMath.cos(z);
138 final double tan = FastMath.tan(z);
139 final double zh = L0 * weather.getPressure();
140 final double zw = L0 * (T_NUM / weather.getTemperature() + WET_OFFSET) * weather.getWaterVaporPressure();
141 final double sh = zh * invCos;
142 final double sw = (zw - L0 * B * tan * tan) * invCos;
143 return new TroposphericDelay(zh, zw, sh, sw);
144
145 }
146
147 /** {@inheritDoc}
148 * <p>
149 * The Saastamoinen model is not defined for altitudes below 0.0. for continuity
150 * reasons, we use the value for h = 0 when altitude is negative.
151 * </p>
152 * <p>
153 * There are also numerical issues for elevation angles close to zero. For continuity reasons,
154 * elevations lower than a threshold will use the value obtained
155 * for the threshold itself.
156 * </p>
157 * @see #getLowElevationThreshold()
158 * @see #setLowElevationThreshold(double)
159 */
160 @Override
161 public <T extends CalculusFieldElement<T>> FieldTroposphericDelay<T> pathDelay(final FieldTrackingCoordinates<T> trackingCoordinates,
162 final FieldGeodeticPoint<T> point,
163 final FieldPressureTemperatureHumidity<T> weather,
164 final T[] parameters, final FieldAbsoluteDate<T> date) {
165
166 final Field<T> field = date.getField();
167 final T zero = field.getZero();
168
169 // there are no data in the model for negative altitudes and altitude bigger than 5000 m
170 // limit the height to a range of [0, 5000] m
171 final T fixedHeight = FastMath.min(FastMath.max(point.getAltitude(), X_VALUES_FOR_B[0]),
172 X_VALUES_FOR_B[X_VALUES_FOR_B.length - 1]);
173
174 // interpolate the b correction term
175 final T B = B_FUNCTION.value(fixedHeight);
176
177 // calculate the zenith angle from the elevation
178 final T z = FastMath.abs(zero.getPi().multiply(0.5).
179 subtract(FastMath.max(trackingCoordinates.getElevation(), lowElevationThreshold)));
180
181 // calculate the path delay in m
182 final T invCos = FastMath.cos(z).reciprocal();
183 final T tan = FastMath.tan(z);
184 final T zh = weather.getPressure().multiply(L0);
185 final T zw = weather.getTemperature().reciprocal().multiply(T_NUM).add(WET_OFFSET).
186 multiply(weather.getWaterVaporPressure()).multiply(L0);
187 final T sh = zh.multiply(invCos);
188 final T sw = zw.subtract(B.multiply(tan).multiply(tan).multiply(L0)).multiply(invCos);
189 return new FieldTroposphericDelay<>(zh, zw, sh, sw);
190
191 }
192
193 /** {@inheritDoc} */
194 @Override
195 public List<ParameterDriver> getParametersDrivers() {
196 return Collections.emptyList();
197 }
198
199 /** Get the low elevation threshold value for path delay computation.
200 * @return low elevation threshold, in rad.
201 * @see #pathDelay(TrackingCoordinates, GeodeticPoint, PressureTemperatureHumidity, double[], AbsoluteDate)
202 * @see #pathDelay(FieldTrackingCoordinates, FieldGeodeticPoint, FieldPressureTemperatureHumidity, CalculusFieldElement[], FieldAbsoluteDate)
203 */
204 public double getLowElevationThreshold() {
205 return lowElevationThreshold;
206 }
207
208 /** Set the low elevation threshold value for path delay computation.
209 * @param lowElevationThreshold The new value for the threshold [rad]
210 * @see #pathDelay(TrackingCoordinates, GeodeticPoint, PressureTemperatureHumidity, double[], AbsoluteDate)
211 * @see #pathDelay(FieldTrackingCoordinates, FieldGeodeticPoint, FieldPressureTemperatureHumidity, CalculusFieldElement[], FieldAbsoluteDate)
212 */
213 public void setLowElevationThreshold(final double lowElevationThreshold) {
214 this.lowElevationThreshold = lowElevationThreshold;
215 }
216
217 }
218