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