1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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.analysis.interpolation.PiecewiseBicubicSplineInterpolatingFunction;
24 import org.hipparchus.analysis.interpolation.PiecewiseBicubicSplineInterpolator;
25 import org.hipparchus.util.FastMath;
26 import org.hipparchus.util.MathUtils;
27 import org.orekit.annotation.DefaultDataContext;
28 import org.orekit.bodies.FieldGeodeticPoint;
29 import org.orekit.bodies.GeodeticPoint;
30 import org.orekit.data.DataContext;
31 import org.orekit.data.DataProvidersManager;
32 import org.orekit.errors.OrekitException;
33 import org.orekit.errors.OrekitMessages;
34 import org.orekit.models.earth.weather.FieldPressureTemperatureHumidity;
35 import org.orekit.models.earth.weather.PressureTemperatureHumidity;
36 import org.orekit.time.AbsoluteDate;
37 import org.orekit.time.FieldAbsoluteDate;
38 import org.orekit.utils.FieldTrackingCoordinates;
39 import org.orekit.utils.InterpolationTableLoader;
40 import org.orekit.utils.ParameterDriver;
41 import org.orekit.utils.TrackingCoordinates;
42
43
44
45
46
47
48 @SuppressWarnings("deprecation")
49 public class FixedTroposphericDelay implements DiscreteTroposphericModel, TroposphericModel {
50
51
52 private static FixedTroposphericDelay defaultModel;
53
54
55 private final double[] xArr;
56
57
58 private final double[] yArr;
59
60
61 private final double[][] fArr;
62
63
64 private PiecewiseBicubicSplineInterpolatingFunction delayFunction;
65
66
67
68
69
70
71 public FixedTroposphericDelay(final double[] xArr, final double[] yArr, final double[][] fArr) {
72 this.xArr = xArr.clone();
73 this.yArr = yArr.clone();
74 this.fArr = fArr.clone();
75 delayFunction = new PiecewiseBicubicSplineInterpolator().interpolate(xArr, yArr, fArr);
76 }
77
78
79
80
81
82
83
84
85 @DefaultDataContext
86 public FixedTroposphericDelay(final String supportedName) {
87 this(supportedName, DataContext.getDefault().getDataProvidersManager());
88 }
89
90
91
92
93
94
95
96
97
98 public FixedTroposphericDelay(final String supportedName,
99 final DataProvidersManager dataProvidersManager) {
100
101 final InterpolationTableLoader loader = new InterpolationTableLoader();
102 dataProvidersManager.feed(supportedName, loader);
103
104 if (!loader.stillAcceptsData()) {
105 xArr = loader.getAbscissaGrid();
106 yArr = loader.getOrdinateGrid();
107 for (int i = 0; i < yArr.length; ++i) {
108 yArr[i] = FastMath.toRadians(yArr[i]);
109 }
110 fArr = loader.getValuesSamples();
111 delayFunction = new PiecewiseBicubicSplineInterpolator().interpolate(xArr, yArr, fArr);
112 } else {
113 throw new OrekitException(OrekitMessages.UNABLE_TO_FIND_RESOURCE, supportedName);
114 }
115 }
116
117
118
119
120
121
122
123
124
125 @DefaultDataContext
126 public static FixedTroposphericDelay getDefaultModel() {
127 synchronized (FixedTroposphericDelay.class) {
128 if (defaultModel == null) {
129 defaultModel = new FixedTroposphericDelay("^tropospheric-delay\\.txt$");
130 }
131 }
132 return defaultModel;
133 }
134
135
136 @Override
137 @Deprecated
138 public double pathDelay(final double elevation, final GeodeticPoint point,
139 final double[] parameters, final AbsoluteDate date) {
140 return pathDelay(new TrackingCoordinates(0.0, elevation, 0.0), point,
141 TroposphericModelUtils.STANDARD_ATMOSPHERE, parameters, date).getDelay();
142 }
143
144
145
146
147
148
149
150
151 @Override
152 public TroposphericDelay pathDelay(final TrackingCoordinates trackingCoordinates, final GeodeticPoint point,
153 final PressureTemperatureHumidity weather,
154 final double[] parameters, final AbsoluteDate date) {
155
156 final double h = FastMath.min(FastMath.max(0, point.getAltitude()), 5000);
157
158 final double ele = FastMath.min(FastMath.PI, FastMath.max(0d, trackingCoordinates.getElevation()));
159
160 final double e = ele > 0.5 * FastMath.PI ? FastMath.PI - ele : ele;
161
162 return new TroposphericDelay(delayFunction.value(h, MathUtils.SEMI_PI), 0.0,
163 delayFunction.value(h, e), 0.0);
164 }
165
166
167 @Override
168 @Deprecated
169 public <T extends CalculusFieldElement<T>> T pathDelay(final T elevation, final FieldGeodeticPoint<T> point,
170 final T[] parameters, final FieldAbsoluteDate<T> date) {
171 return pathDelay(new FieldTrackingCoordinates<>(date.getField().getZero(), elevation, date.getField().getZero()),
172 point,
173 new FieldPressureTemperatureHumidity<>(date.getField(), TroposphericModelUtils.STANDARD_ATMOSPHERE),
174 parameters, date).getDelay();
175 }
176
177
178
179
180
181
182
183
184 @Override
185 public <T extends CalculusFieldElement<T>> FieldTroposphericDelay<T> pathDelay(final FieldTrackingCoordinates<T> trackingCoordinates,
186 final FieldGeodeticPoint<T> point,
187 final FieldPressureTemperatureHumidity<T> weather,
188 final T[] parameters, final FieldAbsoluteDate<T> date) {
189 final T zero = date.getField().getZero();
190 final T pi = zero.getPi();
191
192 final T h = FastMath.min(FastMath.max(zero, point.getAltitude()), zero.newInstance(5000));
193
194 final T ele = FastMath.min(pi, FastMath.max(zero, trackingCoordinates.getElevation()));
195
196 final T e = ele.getReal() > pi.multiply(0.5).getReal() ? ele.negate().add(pi) : ele;
197
198 return new FieldTroposphericDelay<>(delayFunction.value(h, date.getField().getZero().newInstance(MathUtils.SEMI_PI)),
199 date.getField().getZero(),
200 delayFunction.value(h, e),
201 date.getField().getZero());
202
203 }
204
205
206 @Override
207 public List<ParameterDriver> getParametersDrivers() {
208 return Collections.emptyList();
209 }
210
211 }