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