1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.models.earth.atmosphere;
18
19
20 import java.util.TimeZone;
21
22 import org.hipparchus.geometry.euclidean.threed.Rotation;
23 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
24 import org.hipparchus.geometry.euclidean.threed.Vector3D;
25 import org.hipparchus.util.Decimal64;
26 import org.hipparchus.util.FastMath;
27 import org.junit.Assert;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.orekit.SolarInputs97to05;
31 import org.orekit.Utils;
32 import org.orekit.bodies.CelestialBodyFactory;
33 import org.orekit.bodies.OneAxisEllipsoid;
34 import org.orekit.frames.Frame;
35 import org.orekit.frames.FramesFactory;
36 import org.orekit.frames.Transform;
37 import org.orekit.time.AbsoluteDate;
38 import org.orekit.time.TimeScale;
39 import org.orekit.time.TimeScalesFactory;
40 import org.orekit.utils.Constants;
41 import org.orekit.utils.IERSConventions;
42 import org.orekit.utils.PVCoordinatesProvider;
43
44 public class DTM2000Test {
45
46 @Test
47 public void testWithOriginalTestsCases() {
48
49 Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
50 PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
51 OneAxisEllipsoid earth = new OneAxisEllipsoid(6378136.460, 1.0 / 298.257222101, itrf);
52 SolarInputs97to05 in = SolarInputs97to05.getInstance();
53 earth.setAngularThreshold(1e-10);
54 DTM2000 atm = new DTM2000(in, sun, earth);
55 double roTestCase;
56 double myRo;
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 roTestCase = 1.8710001353820e-17 * 1000;
75
76
77 myRo = atm.getDensity(185, 800*1000, 0, FastMath.toRadians(40), 16*FastMath.PI/12, 150, 150, 0, 0);
78 Assert.assertEquals(roTestCase, myRo , roTestCase * 1e-14);
79
80
81
82 roTestCase= 2.8524195214905e-17* 1000;
83
84 myRo = atm.getDensity(275, 800*1000, 0, FastMath.toRadians(40), 16*FastMath.PI/12, 150, 150, 0, 0);
85 Assert.assertEquals(roTestCase, myRo , roTestCase * 1e-14);
86
87
88
89 roTestCase= 1.7343324462212e-17* 1000;
90
91 myRo = atm.getDensity(355, 800*1000, 0, FastMath.toRadians(40), 16*FastMath.PI/12, 150, 150, 0, 0);
92 Assert.assertEquals(roTestCase, myRo , roTestCase * 2e-14);
93
94
95 roTestCase= 2.9983740796297e-17* 1000;
96
97 myRo = atm.getDensity(85, 800*1000, 0, FastMath.toRadians(40), 16*FastMath.PI/12, 150, 150, 0, 0);
98 Assert.assertEquals(roTestCase, myRo , roTestCase * 1e-14);
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 roTestCase = 1.5699108952425600E-016* 1000;
125
126 myRo = atm.getDensity(15, 500*1000, 0, FastMath.toRadians(-70), 16*FastMath.PI/12, 70, 70, 0, 0);
127 Assert.assertEquals(roTestCase, myRo , roTestCase * 1e-14);
128
129
130
131
132
133
134
135
136
137
138
139
140 roTestCase = 2.4123751406975562E-018* 1000;
141 myRo = atm.getDensity(15, 800*1000, 0, FastMath.toRadians(-70), 16*FastMath.PI/12, 70, 70, 0, 0);
142 Assert.assertEquals(roTestCase, myRo , roTestCase * 1e-14);
143
144 }
145
146 @Test
147 public void testNonEarthRotationAxisAlignedFrame() {
148
149 AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
150 Frame ecef = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
151 Rotation rotation = new Rotation(Vector3D.PLUS_I, FastMath.PI / 2, RotationConvention.VECTOR_OPERATOR);
152 Frame frame = new Frame(ecef, new Transform(date, rotation), "other");
153 Vector3D pEcef = new Vector3D(6378137 + 300e3, 0, 0);
154 Vector3D pFrame = ecef.getTransformTo(frame, date)
155 .transformPosition(pEcef);
156 PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
157 OneAxisEllipsoid earth = new OneAxisEllipsoid(
158 6378136.460, 1.0 / 298.257222101, ecef);
159 SolarInputs97to05 in = SolarInputs97to05.getInstance();
160 earth.setAngularThreshold(1e-10);
161 DTM2000 atm = new DTM2000(in, sun, earth);
162
163
164 final double actual = atm.getDensity(date, pFrame, frame);
165
166
167 Assert.assertEquals(atm.getDensity(date, pEcef, ecef), actual, 0.0);
168 }
169
170 @Test
171 public void testField() {
172 Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
173 PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
174 OneAxisEllipsoid earth = new OneAxisEllipsoid(6378136.460, 1.0 / 298.257222101, itrf);
175 SolarInputs97to05 in = SolarInputs97to05.getInstance();
176 earth.setAngularThreshold(1e-10);
177 DTM2000 atm = new DTM2000(in, sun, earth);
178
179
180 for (double alti = 400; alti < 1000; alti += 50) {
181 for (double lon = 0; lon < 6; lon += 0.5) {
182 for (double lat = -1.5; lat < 1.5; lat += 0.5) {
183 for (double hl = 0; hl < 6; hl += 0.5) {
184 double rhoD = atm.getDensity(185, alti*1000, lon, lat, hl, 50, 150, 0, 0);
185 Decimal64 rho64 = atm.getDensity(185, new Decimal64(alti*1000),
186 new Decimal64(lon), new Decimal64(lat),
187 new Decimal64(hl), 50, 150, 0, 0);
188 Assert.assertEquals(rhoD, rho64.getReal(), rhoD * 1e-14);
189 }
190 }
191 }
192 }
193
194 }
195
196
197
198
199 @Test
200 public void testTimeZoneIndependantIssue539() {
201
202
203
204 TimeScale utc = TimeScalesFactory.getUTC();
205 AbsoluteDate date = new AbsoluteDate("2000-04-01T22:30:00.000", utc);
206
207
208 Vector3D position = new Vector3D(-1038893.194, -4654348.144, 5021579.14);
209 Frame gcrf = FramesFactory.getGCRF();
210
211
212 Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
213 PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
214 OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.GRIM5C1_EARTH_EQUATORIAL_RADIUS,
215 Constants.GRIM5C1_EARTH_FLATTENING, itrf);
216 SolarInputs97to05 in = SolarInputs97to05.getInstance();
217 earth.setAngularThreshold(1e-10);
218 DTM2000 atm = new DTM2000(in, sun, earth);
219
220
221 TimeZone defaultTZ = TimeZone.getDefault();
222
223
224 TimeZone.setDefault(TimeZone.getTimeZone("Etc/UTC"));
225 double rhoUtc = atm.getDensity(date, position, gcrf);
226
227
228 TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris"));
229 double rhoParis = atm.getDensity(date, position, gcrf);
230
231
232 Assert.assertEquals(0., rhoUtc - rhoParis, 0.);
233
234
235 TimeZone.setDefault(defaultTZ);
236 }
237
238 @Before
239 public void setUp() {
240 Utils.setDataRoot("regular-data");
241 }
242
243 }