1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.propagation.events;
18
19 import java.util.List;
20
21 import org.hipparchus.geometry.euclidean.threed.Vector3D;
22 import org.hipparchus.ode.events.Action;
23 import org.hipparchus.util.FastMath;
24 import org.junit.After;
25 import org.junit.Assert;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.orekit.Utils;
29 import org.orekit.bodies.BodyShape;
30 import org.orekit.bodies.GeodeticPoint;
31 import org.orekit.bodies.OneAxisEllipsoid;
32 import org.orekit.frames.Frame;
33 import org.orekit.frames.FramesFactory;
34 import org.orekit.frames.TopocentricFrame;
35 import org.orekit.models.AtmosphericRefractionModel;
36 import org.orekit.models.earth.EarthStandardAtmosphereRefraction;
37 import org.orekit.orbits.EquinoctialOrbit;
38 import org.orekit.orbits.KeplerianOrbit;
39 import org.orekit.orbits.Orbit;
40 import org.orekit.orbits.PositionAngle;
41 import org.orekit.propagation.Propagator;
42 import org.orekit.propagation.SpacecraftState;
43 import org.orekit.propagation.analytical.EcksteinHechlerPropagator;
44 import org.orekit.propagation.analytical.KeplerianPropagator;
45 import org.orekit.propagation.events.EventsLogger.LoggedEvent;
46 import org.orekit.propagation.events.handlers.ContinueOnEvent;
47 import org.orekit.propagation.events.handlers.EventHandler;
48 import org.orekit.propagation.events.handlers.StopOnIncreasing;
49 import org.orekit.propagation.sampling.OrekitFixedStepHandler;
50 import org.orekit.time.AbsoluteDate;
51 import org.orekit.time.TimeScale;
52 import org.orekit.time.TimeScalesFactory;
53 import org.orekit.utils.Constants;
54 import org.orekit.utils.ElevationMask;
55 import org.orekit.utils.IERSConventions;
56 import org.orekit.utils.PVCoordinates;
57
58 public class ElevationDetectorTest {
59
60 private double mu;
61 private double ae;
62 private double c20;
63 private double c30;
64 private double c40;
65 private double c50;
66 private double c60;
67
68 @Test
69 public void testAgata() {
70
71 final TimeScale utc = TimeScalesFactory.getUTC();
72 final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
73 final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
74 final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
75 final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity),
76 FramesFactory.getEME2000(), date, mu);
77
78 Propagator propagator =
79 new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
80
81
82 double ae = 6378137.0;
83 double f = 1.0 / 298.257223563;
84 Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
85 BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
86 GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833),
87 FastMath.toRadians(2.333),
88 0.0);
89 TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
90 Checking checking = new Checking(topo);
91 ElevationDetector detector =
92 new ElevationDetector(topo).
93 withConstantElevation(FastMath.toRadians(5.0)).
94 withHandler(checking);
95 Assert.assertNull(detector.getElevationMask());
96 Assert.assertNull(detector.getRefractionModel());
97 Assert.assertSame(topo, detector.getTopocentricFrame());
98 Assert.assertEquals(FastMath.toRadians(5.0), detector.getMinElevation(), 1.0e-15);
99
100 AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 12, 0, 0, utc);
101 propagator.resetInitialState(propagator.propagate(startDate));
102 propagator.addEventDetector(detector);
103 propagator.setStepHandler(10.0, checking);
104 propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
105
106 }
107
108 private static class Checking implements EventHandler<ElevationDetector>, OrekitFixedStepHandler {
109
110 private TopocentricFrame topo;
111 private boolean visible;
112
113 public Checking(final TopocentricFrame topo) {
114 this.topo = topo;
115 this.visible = false;
116 }
117
118 public Action eventOccurred(SpacecraftState s, ElevationDetector detector, boolean increasing) {
119 visible = increasing;
120 return Action.CONTINUE;
121 }
122
123 public void handleStep(SpacecraftState currentState)
124 {
125 BodyShape shape = topo.getParentShape();
126 GeodeticPoint p =
127 shape.transform(currentState.getPVCoordinates().getPosition(),
128 currentState.getFrame(), currentState.getDate());
129 Vector3D subSat = shape.transform(new GeodeticPoint(p.getLatitude(), p.getLongitude(), 0.0));
130 double range = topo.getRange(subSat, shape.getBodyFrame(), currentState.getDate());
131
132 if (visible) {
133 Assert.assertTrue(range < 2.45e6);
134 } else {
135 Assert.assertTrue(range > 2.02e6);
136 }
137 }
138
139 @Override
140 public void init(SpacecraftState initialState, AbsoluteDate target, double step) {
141 }
142
143 }
144
145 @Test
146 public void testEventForMask() {
147
148 final TimeScale utc = TimeScalesFactory.getUTC();
149 final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
150 final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
151 final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
152 final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity),
153 FramesFactory.getEME2000(), date, mu);
154
155 Propagator propagator =
156 new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
157
158
159 double ae = 6378137.0;
160 double f = 1.0 / 298.257223563;
161 Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
162 BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
163 GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833),
164 FastMath.toRadians(2.333),
165 0.0);
166 TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
167 double [][] maskValues = {{ FastMath.toRadians( 0), FastMath.toRadians(5)},
168 { FastMath.toRadians( 30), FastMath.toRadians(4)},
169 { FastMath.toRadians( 60), FastMath.toRadians(3)},
170 { FastMath.toRadians( 90), FastMath.toRadians(2)},
171 { FastMath.toRadians(120), FastMath.toRadians(3)},
172 { FastMath.toRadians(150), FastMath.toRadians(4)},
173 { FastMath.toRadians(180), FastMath.toRadians(5)},
174 { FastMath.toRadians(210), FastMath.toRadians(6)},
175 { FastMath.toRadians(240), FastMath.toRadians(5)},
176 { FastMath.toRadians(270), FastMath.toRadians(4)},
177 { FastMath.toRadians(300), FastMath.toRadians(3)},
178 { FastMath.toRadians(330), FastMath.toRadians(4)}};
179 ElevationMask mask = new ElevationMask(maskValues);
180 ElevationDetector detector = new ElevationDetector(topo)
181 .withElevationMask(mask)
182 .withHandler(new StopOnIncreasing<ElevationDetector>());
183 Assert.assertSame(mask, detector.getElevationMask());
184
185 AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 20, 0, 0, utc);
186 propagator.resetInitialState(propagator.propagate(startDate));
187 propagator.addEventDetector(detector);
188 final SpacecraftState fs = propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
189 double elevation = topo.getElevation(fs.getPVCoordinates().getPosition(), fs.getFrame(), fs.getDate());
190 Assert.assertEquals(0.065, elevation, 2.0e-5);
191
192 }
193
194
195 @Test
196 public void testHorizon() {
197
198 final TimeScale utc = TimeScalesFactory.getUTC();
199 final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
200 final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
201 final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
202 final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity),
203 FramesFactory.getEME2000(), date, mu);
204
205 Propagator propagator =
206 new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
207
208
209 double ae = 6378137.0;
210 double f = 1.0 / 298.257223563;
211 Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
212 BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
213 GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833),
214 FastMath.toRadians(2.333),
215 0.0);
216 TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
217 AtmosphericRefractionModel refractionModel = new EarthStandardAtmosphereRefraction();
218 ElevationDetector detector = new ElevationDetector(topo)
219 .withRefraction(refractionModel)
220 .withHandler(new StopOnIncreasing<ElevationDetector>());
221 Assert.assertSame(refractionModel, detector.getRefractionModel());
222
223 AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 20, 0, 0, utc);
224 propagator.resetInitialState(propagator.propagate(startDate));
225 propagator.addEventDetector(detector);
226 final SpacecraftState fs = propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
227 double elevation = topo.getElevation(fs.getPVCoordinates().getPosition(), fs.getFrame(), fs.getDate());
228 Assert.assertEquals(FastMath.toRadians(-0.5746255623877098), elevation, 2.0e-5);
229
230 }
231
232
233 @Test
234 public void testIssue136() {
235
236
237 AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
238 Frame inertialFrame = FramesFactory.getEME2000();
239 Orbit initialOrbit = new KeplerianOrbit(6828137.005, 7.322641382145889e-10, 1.6967079057368113,
240 0.0, 1.658054062748353,
241 0.0001223149429077902, PositionAngle.MEAN,
242 inertialFrame, initialDate, Constants.EIGEN5C_EARTH_MU);
243
244
245 Propagator kepler = new EcksteinHechlerPropagator(initialOrbit,
246 Constants.EGM96_EARTH_EQUATORIAL_RADIUS, Constants.EGM96_EARTH_MU,
247 Constants.EGM96_EARTH_C20, 0.0, 0.0, 0.0, 0.0);
248
249
250 double ae = 6378137.0;
251 double f = 1.0 / 298.257223563;
252 Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
253 BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
254
255
256 final double longitude = FastMath.toRadians(-147.5);
257 final double latitude = FastMath.toRadians(64);
258 final double altitude = 160;
259 final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude);
260 final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1");
261
262
263 final double maxcheck = 120.0;
264 final double elevation = FastMath.toRadians(5.);
265 final double threshold = 10.0;
266 final EventDetector rawEvent = new ElevationDetector(maxcheck, threshold, sta1Frame)
267 .withConstantElevation(elevation)
268 .withHandler(new ContinueOnEvent<ElevationDetector>());
269 final EventsLogger logger = new EventsLogger();
270 kepler.addEventDetector(logger.monitorDetector(rawEvent));
271
272
273 kepler.propagate(initialDate.shiftedBy(60*60*24.0*40));
274 int countIncreasing = 0;
275 int countDecreasing = 0;
276 for (LoggedEvent le : logger.getLoggedEvents()) {
277 if (le.isIncreasing()) {
278 ++countIncreasing;
279 } else {
280 ++countDecreasing;
281 }
282 }
283 Assert.assertEquals(314, countIncreasing);
284 Assert.assertEquals(314, countDecreasing);
285
286 }
287
288 @Test
289 public void testIssue110() {
290
291
292 final Frame eme2000Frame = FramesFactory.getEME2000();
293 final AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH;
294 final double a = 7000000.0;
295 final Orbit initialOrbit = new KeplerianOrbit(a, 0.0,
296 FastMath.PI / 2.2, 0.0, FastMath.PI / 2., 0.0,
297 PositionAngle.TRUE, eme2000Frame, initDate,
298 Constants.EGM96_EARTH_MU);
299 final KeplerianPropagator kProp = new KeplerianPropagator(initialOrbit);
300
301
302 final OneAxisEllipsoid earthShape = new OneAxisEllipsoid(
303 Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
304 Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
305
306 final GeodeticPoint stat = new GeodeticPoint(FastMath.toRadians(35.),
307 FastMath.toRadians(149.8), 0.);
308 final TopocentricFrame station = new TopocentricFrame(earthShape, stat,
309 "GSTATION");
310
311
312
313 final double maxCheck = 600.;
314 final double threshold = 1.0e-3;
315 final EventDetector rawEvent = new ElevationDetector(maxCheck, threshold, station)
316 .withConstantElevation(FastMath.toRadians(5.0))
317 .withHandler(new ContinueOnEvent<ElevationDetector>());
318 final EventsLogger logger = new EventsLogger();
319 kProp.addEventDetector(logger.monitorDetector(rawEvent));
320
321
322 final AbsoluteDate finalDate = initDate.shiftedBy(30 * 60.);
323
324 kProp.propagate(finalDate);
325 Assert.assertEquals(2, logger.getLoggedEvents().size());
326 Assert.assertTrue(logger.getLoggedEvents().get(0).isIncreasing());
327 Assert.assertEquals(478.945, logger.getLoggedEvents().get(0).getState().getDate().durationFrom(initDate), 1.0e-3);
328 Assert.assertFalse(logger.getLoggedEvents().get(1).isIncreasing());
329 Assert.assertEquals(665.721, logger.getLoggedEvents().get(1).getState().getDate().durationFrom(initDate), 1.0e-3);
330
331 }
332
333
334 public void testPresTemp() {
335
336 final TimeScale utc = TimeScalesFactory.getUTC();
337 final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
338 final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
339 final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
340 final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity),
341 FramesFactory.getEME2000(), date, mu);
342
343 Propagator propagator =
344 new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
345
346
347 double ae = 6378137.0;
348 double f = 1.0 / 298.257223563;
349 Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
350 BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
351 GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833),
352 FastMath.toRadians(2.333),
353 0.0);
354 TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
355 EarthStandardAtmosphereRefraction refractionModel = new EarthStandardAtmosphereRefraction();
356 ElevationDetector detector = new ElevationDetector(topo)
357 .withRefraction(refractionModel)
358 .withHandler(new StopOnIncreasing<ElevationDetector>());
359 refractionModel.setPressure(101325);
360 refractionModel.setTemperature(290);
361
362 AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 20, 0, 0, utc);
363 propagator.resetInitialState(propagator.propagate(startDate));
364 propagator.addEventDetector(detector);
365 final SpacecraftState fs = propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
366 double elevation = topo.getElevation(fs.getPVCoordinates().getPosition(), fs.getFrame(), fs.getDate());
367 Assert.assertEquals(FastMath.toRadians(1.7026104902251749), elevation, 2.0e-5);
368
369 }
370
371 @Test
372 public void testIssue203() {
373
374
375 AbsoluteDate initialDate = new AbsoluteDate("2012-01-26T07:00:00.000", TimeScalesFactory.getUTC());
376
377 Frame inertialFrame = FramesFactory.getEME2000();
378
379 Orbit initialOrbit = new KeplerianOrbit(6828137.5, 7.322641060181212E-8, 1.7082667003713938, 0.0, 1.658054062748353, 1.2231496082116026E-4, PositionAngle.TRUE , inertialFrame, initialDate, Constants.WGS84_EARTH_MU);
380
381 Propagator propagator =
382 new EcksteinHechlerPropagator(initialOrbit,
383 Constants.EGM96_EARTH_EQUATORIAL_RADIUS,
384 Constants.EGM96_EARTH_MU,
385 Constants.EGM96_EARTH_C20,
386 Constants.EGM96_EARTH_C30,
387 Constants.EGM96_EARTH_C40,
388 Constants.EGM96_EARTH_C50,
389 Constants.EGM96_EARTH_C60);
390
391
392 Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
393 BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
394 Constants.WGS84_EARTH_FLATTENING,
395 earthFrame);
396
397
398 final double longitude = FastMath.toRadians(21.0);
399 final double latitude = FastMath.toRadians(67.9);
400 final double altitude = 300.0;
401
402 final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude);
403 final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1");
404
405 double [][] maskValues = {
406 {-0.017453292519943098, 0.006981317007977318}, {0.0, 0.006981317007977318},
407 {0.017453292519943295, 0.006981317007977318}, {0.03490658503988659, 0.010471975511965976},
408 {0.05235987755982989, 0.012217304763960306}, {0.06981317007977318, 0.010471975511965976},
409 {0.08726646259971647, 0.010471975511965976}, {0.10471975511965978, 0.012217304763960306},
410 {0.12217304763960307, 0.010471975511965976}, {0.13962634015954636, 0.008726646259971648},
411 {0.15707963267948966, 0.008726646259971648}, {0.17453292519943295, 0.006981317007977318},
412 {0.19198621771937624, 0.006981317007977318}, {0.20943951023931956, 0.006981317007977318},
413 {0.22689280275926285, 0.005235987755982988}, {0.24434609527920614, 0.005235987755982988},
414 {0.2617993877991494, 0.003490658503988659}, {0.2792526803190927, 0.003490658503988659},
415 {0.29670597283903605, 0.0017453292519943296}, {0.3141592653589793, 0.003490658503988659},
416 {0.33161255787892263, 0.0017453292519943296}, {0.3490658503988659, 0.0},
417 {0.3665191429188092, 0.012217304763960306}, {0.3839724354387525, 0.012217304763960306},
418 {0.4014257279586958, 0.0}, {0.4188790204786391, 0.010471975511965976},
419 {0.4363323129985824, 0.029670597283903602}, {0.4537856055185257, 0.029670597283903602},
420 {0.47123889803846897, 0.017453292519943295}, {0.4886921905584123, 0.0},
421 {0.5061454830783556, 0.029670597283903602}, {0.5235987755982988, 0.015707963267948967},
422 {0.5410520681182421, 0.005235987755982988}, {0.5585053606381855, 0.024434609527920613},
423 {0.5759586531581288, 0.041887902047863905}, {0.5934119456780721, 0.06283185307179587},
424 {0.6108652381980153, 0.05235987755982989}, {0.6283185307179586, 0.05759586531581287},
425 {0.6457718232379019, 0.061086523819801536}, {0.6632251157578453, 0.05759586531581287},
426 {0.6806784082777885, 0.04363323129985824}, {0.6981317007977318, 0.059341194567807204},
427 {0.7155849933176751, 0.07504915783575616}, {0.7330382858376184, 0.08726646259971647},
428 {0.7504915783575618, 0.08726646259971647}, {0.767944870877505, 0.07330382858376185},
429 {0.7853981633974483, 0.07853981633974483}, {0.8028514559173916, 0.09075712110370514},
430 {0.8203047484373349, 0.0942477796076938}, {0.8377580409572782, 0.11519173063162574},
431 {0.8552113334772214, 0.11519173063162574}, {0.8726646259971648, 0.12566370614359174},
432 {0.8901179185171081, 0.12566370614359174}, {0.9075712110370514, 0.10122909661567112},
433 {0.9250245035569946, 0.11868238913561441}, {0.9424777960769379, 0.11868238913561441},
434 {0.9599310885968813, 0.11868238913561441}, {0.9773843811168246, 0.10821041362364843},
435 {0.9948376736367679, 0.12217304763960307}, {1.0122909661567112, 0.12740903539558607},
436 {1.0297442586766545, 0.11344640137963143}, {1.0471975511965976, 0.11344640137963143},
437 {1.064650843716541, 0.06632251157578452}, {1.0821041362364843, 0.12391837689159739},
438 {1.0995574287564276, 0.12391837689159739}, {1.117010721276371, 0.10995574287564276},
439 {1.1344640137963142, 0.09250245035569947}, {1.1519173063162575, 0.12740903539558607},
440 {1.1693705988362009, 0.1308996938995747}, {1.1868238913561442, 0.1117010721276371},
441 {1.2042771838760873, 0.1117010721276371}, {1.2217304763960306, 0.0942477796076938},
442 {1.239183768915974, 0.10821041362364843}, {1.2566370614359172, 0.09599310885968812},
443 {1.2740903539558606, 0.09948376736367678}, {1.2915436464758039, 0.09773843811168245},
444 {1.3089969389957472, 0.08726646259971647}, {1.3264502315156905, 0.09250245035569947},
445 {1.3439035240356338, 0.10122909661567112}, {1.361356816555577, 0.09250245035569947},
446 {1.3788101090755203, 0.08552113334772216}, {1.3962634015954636, 0.08726646259971647},
447 {1.413716694115407, 0.08028514559173916}, {1.4311699866353502, 0.05759586531581287},
448 {1.4486232791552935, 0.054105206811824215}, {1.4660765716752369, 0.06632251157578452},
449 {1.4835298641951802, 0.08028514559173916}, {1.5009831567151235, 0.061086523819801536},
450 {1.5184364492350666, 0.048869219055841226}, {1.53588974175501, 0.0715584993317675},
451 {1.5533430342749532, 0.07504915783575616}, {1.5707963267948966, 0.05235987755982989},
452 {1.5882496193148399, 0.05235987755982989}, {1.6057029118347832, 0.06981317007977318},
453 {1.6231562043547265, 0.054105206811824215}, {1.6406094968746698, 0.0645771823237902},
454 {1.6580627893946132, 0.059341194567807204}, {1.6755160819145565, 0.029670597283903602},
455 {1.6929693744344996, 0.03316125578789226}, {1.710422666954443, 0.059341194567807204},
456 {1.7278759594743862, 0.0645771823237902}, {1.7453292519943295, 0.06283185307179587},
457 {1.7627825445142729, 0.061086523819801536}, {1.7802358370342162, 0.06806784082777885},
458 {1.7976891295541595, 0.06632251157578452}, {1.8151424220741028, 0.059341194567807204},
459 {1.8325957145940461, 0.05759586531581287}, {1.8500490071139892, 0.05759586531581287},
460 {1.8675022996339325, 0.0471238898038469}, {1.8849555921538759, 0.059341194567807204},
461 {1.9024088846738192, 0.05061454830783556}, {1.9198621771937625, 0.05061454830783556},
462 {1.9373154697137058, 0.024434609527920613}, {1.9547687622336491, 0.027925268031909273},
463 {1.9722220547535925, 0.041887902047863905}, {1.9896753472735358, 0.024434609527920613},
464 {2.007128639793479, 0.029670597283903602}, {2.0245819323134224, 0.03316125578789226},
465 {2.0420352248333655, 0.03665191429188092}, {2.059488517353309, 0.04537856055185257},
466 {2.076941809873252, 0.041887902047863905}, {2.0943951023931953, 0.05759586531581287},
467 {2.111848394913139, 0.06283185307179587}, {2.129301687433082, 0.06806784082777885},
468 {2.1467549799530254, 0.05759586531581287}, {2.1642082724729685, 0.059341194567807204},
469 {2.181661564992912, 0.06806784082777885}, {2.199114857512855, 0.06283185307179587},
470 {2.2165681500327987, 0.054105206811824215}, {2.234021442552742, 0.05235987755982989},
471 {2.251474735072685, 0.059341194567807204}, {2.2689280275926285, 0.07330382858376185},
472 {2.2863813201125716, 0.06283185307179587}, {2.303834612632515, 0.05235987755982989},
473 {2.321287905152458, 0.061086523819801536}, {2.3387411976724017, 0.048869219055841226},
474 {2.356194490192345, 0.06632251157578452}, {2.3736477827122884, 0.05061454830783556},
475 {2.3911010752322315, 0.07679448708775051}, {2.4085543677521746, 0.06283185307179587},
476 {2.426007660272118, 0.05585053606381855}, {2.443460952792061, 0.061086523819801536},
477 {2.4609142453120048, 0.06806784082777885}, {2.478367537831948, 0.0645771823237902},
478 {2.4958208303518914, 0.06283185307179587}, {2.5132741228718345, 0.06283185307179587},
479 {2.530727415391778, 0.0645771823237902}, {2.548180707911721, 0.07504915783575616},
480 {2.5656340004316642, 0.0715584993317675}, {2.5830872929516078, 0.0645771823237902},
481 {2.600540585471551, 0.059341194567807204}, {2.6179938779914944, 0.06283185307179587},
482 {2.6354471705114375, 0.06632251157578452}, {2.652900463031381, 0.06283185307179587},
483 {2.670353755551324, 0.06632251157578452}, {2.6878070480712677, 0.0645771823237902}};
484 ElevationMask mask = new ElevationMask(maskValues);
485
486
487 final AbsoluteDate start = new AbsoluteDate("2012-02-10T22:00:00.000", TimeScalesFactory.getUTC());
488 final AbsoluteDate end = initialDate.shiftedBy(1000 * Constants.JULIAN_DAY);
489
490
491 final double maxcheck = 60.0;
492 final double threshold = 2.0;
493 final EventDetector sta1Visi =
494 new ElevationDetector(maxcheck, threshold, sta1Frame).
495 withElevationMask(mask).
496 withHandler(new EventHandler<ElevationDetector>() {
497
498 private int count = 6;
499 @Override
500 public Action eventOccurred(SpacecraftState s, ElevationDetector detector, boolean increasing) {
501 return (--count > 0) ? Action.CONTINUE : Action.STOP;
502 }
503
504 });
505
506
507 EventsLogger logger = new EventsLogger();
508 propagator.addEventDetector(logger.monitorDetector(sta1Visi));
509
510
511 propagator.propagate(start, end);
512
513 List<LoggedEvent> events = logger.getLoggedEvents();
514 Assert.assertEquals(6, events.size());
515
516
517
518 AbsoluteDate d2 = events.get(2).getState().getDate();
519 AbsoluteDate d3 = events.get(3).getState().getDate();
520 Assert.assertEquals(1.529, d3.durationFrom(d2), 0.01);
521
522 }
523
524 @Before
525 public void setUp() {
526 Utils.setDataRoot("regular-data");
527 mu = 3.9860047e14;
528 ae = 6.378137e6;
529 c20 = -1.08263e-3;
530 c30 = 2.54e-6;
531 c40 = 1.62e-6;
532 c50 = 2.3e-7;
533 c60 = -5.5e-7;
534 }
535
536 @After
537 public void tearDown() {
538 mu = Double.NaN;
539 ae = Double.NaN;
540 c20 = Double.NaN;
541 c30 = Double.NaN;
542 c40 = Double.NaN;
543 c50 = Double.NaN;
544 c60 = Double.NaN;
545 }
546
547 }
548