33from astropy import units as u
44from astropy .tests .helper import assert_quantity_allclose
55from 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
88from org .orekit .orbits import KeplerianOrbit , PositionAngle
99from org .orekit .propagation .analytical import KeplerianPropagator
1010from org .orekit .propagation .events import (
1111 EclipseDetector ,
12+ ElevationDetector ,
1213 LatitudeCrossingDetector ,
1314 NodeDetector ,
1415)
2526 LatitudeCrossEvent ,
2627 NodeCrossEvent ,
2728 PenumbraEvent ,
29+ SatelliteVisibilityEvent ,
2830 UmbraEvent ,
2931)
3032from poliastro .twobody .propagation import cowell
4345Sun_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
4850REarth_orekit = Constants .WGS84_EARTH_EQUATORIAL_RADIUS
4951Earth_orekit = OneAxisEllipsoid (
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
5665a , ecc , inc , raan , argp , nu = (6828137.0 , 0.0073 , 87.0 , 20.0 , 10.0 , 0 )
5766
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+
8597DICT_OF_EVENTS = {
8698 "umbra-entry" : [
8799 # orekit umbra eclipse detector
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
140156relative 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