Skip to content

Commit 387c59a

Browse files
committed
Validate SatelliteVisibilityEvent
1 parent 8e925e5 commit 387c59a

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

orekit/tests/validate_events.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
from astropy import units as u
44
from astropy.tests.helper import assert_quantity_allclose
55
from astropy.time import Time
6-
from org.orekit.bodies import CelestialBodyFactory, OneAxisEllipsoid
7-
from org.orekit.frames import FramesFactory
6+
from org.orekit.bodies import CelestialBodyFactory, GeodeticPoint, OneAxisEllipsoid
7+
from org.orekit.frames import FramesFactory, TopocentricFrame
88
from org.orekit.orbits import KeplerianOrbit, PositionAngle
99
from org.orekit.propagation.analytical import KeplerianPropagator
1010
from org.orekit.propagation.events import (
1111
EclipseDetector,
12+
ElevationDetector,
1213
LatitudeCrossingDetector,
1314
NodeDetector,
1415
)
@@ -25,6 +26,7 @@
2526
LatitudeCrossEvent,
2627
NodeCrossEvent,
2728
PenumbraEvent,
29+
SatelliteVisibilityEvent,
2830
UmbraEvent,
2931
)
3032
from poliastro.twobody.propagation import cowell
@@ -43,7 +45,7 @@
4345
Sun_orekit, RSun_orekit = CelestialBodyFactory.getSun(), Constants.SUN_RADIUS
4446
# orekit requires that the attractor is of the ~OneAxisEllipsoid so its event
4547
# detector can properly function. Therefore, the Earth is instantiated from this
46-
# class although the flatteing factor is set to zero so it still becomes a
48+
# class although the flattening factor is set to zero so it still becomes a
4749
# perfect sphere
4850
REarth_orekit = Constants.WGS84_EARTH_EQUATORIAL_RADIUS
4951
Earth_orekit = OneAxisEllipsoid(
@@ -52,6 +54,13 @@
5254
FramesFactory.getITRF(IERSConventions.IERS_2010, True),
5355
)
5456

57+
# Define a flattened Earth instead of a perfect sphere model for the satellite visibility event.
58+
Earth_orekit_satellite_visibility = OneAxisEllipsoid(
59+
Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
60+
Constants.WGS84_EARTH_FLATTENING,
61+
FramesFactory.getITRF(IERSConventions.IERS_2010, True),
62+
)
63+
5564
# The COE for the orbit to be defined
5665
a, ecc, inc, raan, argp, nu = (6828137.0, 0.0073, 87.0, 20.0, 10.0, 0)
5766

@@ -82,6 +91,9 @@
8291
epoch0_poliastro,
8392
)
8493

94+
point = GeodeticPoint(46 * DEG_TO_RAD, 45 * DEG_TO_RAD, 5.0) # lat, lon, h
95+
topo_frame = TopocentricFrame(Earth_orekit_satellite_visibility, point, "earth-station")
96+
8597
DICT_OF_EVENTS = {
8698
"umbra-entry": [
8799
# orekit umbra eclipse detector
@@ -135,6 +147,10 @@
135147
NodeDetector(ss0_orekit, ss0_orekit.frame).withHandler(StopOnEvent()),
136148
NodeCrossEvent(terminal=True),
137149
],
150+
"satellite-visibility": [
151+
ElevationDetector(topo_frame).withHandler(StopOnEvent()),
152+
SatelliteVisibilityEvent(ss0_poliastro, 46 * u.deg, 45 * u.deg, 5.0 * u.m, terminal=True),
153+
]
138154
}
139155
"""A dictionary holding the orekitEvent, the poliastroEvent and the absolute and
140156
relative tolerances for the assertion test."""
@@ -160,7 +176,6 @@ def validate_event_detector(event_name):
160176
orekit_event_epoch_str = orekit_event_epoch_raw.toString(TimeScalesFactory.getUTC())
161177
orekit_event_epoch = Time(orekit_event_epoch_str, scale="utc", format="isot")
162178
orekit_event_epoch.format = "iso"
163-
print(f"{orekit_event_epoch}")
164179

165180
# Propagate poliastro's orbit
166181
_, _ = cowell(
@@ -172,7 +187,6 @@ def validate_event_detector(event_name):
172187
events=[poliastro_event],
173188
)
174189
poliastro_event_epoch = ss0_poliastro.epoch + poliastro_event.last_t
175-
print(f"{poliastro_event_epoch}")
176190

177191
# Test both event epochs by checking the distance in seconds between them
178192
dt = np.abs((orekit_event_epoch - poliastro_event_epoch).to(u.s))

0 commit comments

Comments
 (0)