Skip to content

Commit

Permalink
Validate SatelliteVisibilityEvent
Browse files Browse the repository at this point in the history
Reformat

Reformat
  • Loading branch information
Yash-10 committed Aug 27, 2021
1 parent 8e925e5 commit 637042d
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions orekit/tests/validate_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from astropy import units as u
from astropy.tests.helper import assert_quantity_allclose
from astropy.time import Time
from org.orekit.bodies import CelestialBodyFactory, OneAxisEllipsoid
from org.orekit.frames import FramesFactory
from org.orekit.bodies import CelestialBodyFactory, GeodeticPoint, OneAxisEllipsoid
from org.orekit.frames import FramesFactory, TopocentricFrame
from org.orekit.orbits import KeplerianOrbit, PositionAngle
from org.orekit.propagation.analytical import KeplerianPropagator
from org.orekit.propagation.events import (
EclipseDetector,
ElevationDetector,
LatitudeCrossingDetector,
NodeDetector,
)
Expand All @@ -25,6 +26,7 @@
LatitudeCrossEvent,
NodeCrossEvent,
PenumbraEvent,
SatelliteVisibilityEvent,
UmbraEvent,
)
from poliastro.twobody.propagation import cowell
Expand All @@ -43,7 +45,7 @@
Sun_orekit, RSun_orekit = CelestialBodyFactory.getSun(), Constants.SUN_RADIUS
# orekit requires that the attractor is of the ~OneAxisEllipsoid so its event
# detector can properly function. Therefore, the Earth is instantiated from this
# class although the flatteing factor is set to zero so it still becomes a
# class although the flattening factor is set to zero so it still becomes a
# perfect sphere
REarth_orekit = Constants.WGS84_EARTH_EQUATORIAL_RADIUS
Earth_orekit = OneAxisEllipsoid(
Expand All @@ -52,6 +54,13 @@
FramesFactory.getITRF(IERSConventions.IERS_2010, True),
)

# Define a flattened Earth instead of a perfect sphere model for the satellite visibility event.
Earth_orekit_satellite_visibility = OneAxisEllipsoid(
Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
Constants.WGS84_EARTH_FLATTENING,
FramesFactory.getITRF(IERSConventions.IERS_2010, True),
)

# The COE for the orbit to be defined
a, ecc, inc, raan, argp, nu = (6828137.0, 0.0073, 87.0, 20.0, 10.0, 0)

Expand Down Expand Up @@ -82,6 +91,9 @@
epoch0_poliastro,
)

point = GeodeticPoint(47 * DEG_TO_RAD, 45 * DEG_TO_RAD, 5.0) # lat, lon, h
topo_frame = TopocentricFrame(Earth_orekit_satellite_visibility, point, "earth-station")

DICT_OF_EVENTS = {
"umbra-entry": [
# orekit umbra eclipse detector
Expand Down Expand Up @@ -135,6 +147,12 @@
NodeDetector(ss0_orekit, ss0_orekit.frame).withHandler(StopOnEvent()),
NodeCrossEvent(terminal=True),
],
"satellite-visibility": [
ElevationDetector(topo_frame).withHandler(StopOnEvent()),
SatelliteVisibilityEvent(
ss0_poliastro, 46 * u.deg, 45 * u.deg, 5.0 * u.m, terminal=True
),
],
}
"""A dictionary holding the orekitEvent, the poliastroEvent and the absolute and
relative tolerances for the assertion test."""
Expand All @@ -160,7 +178,6 @@ def validate_event_detector(event_name):
orekit_event_epoch_str = orekit_event_epoch_raw.toString(TimeScalesFactory.getUTC())
orekit_event_epoch = Time(orekit_event_epoch_str, scale="utc", format="isot")
orekit_event_epoch.format = "iso"
print(f"{orekit_event_epoch}")

# Propagate poliastro's orbit
_, _ = cowell(
Expand All @@ -172,7 +189,6 @@ def validate_event_detector(event_name):
events=[poliastro_event],
)
poliastro_event_epoch = ss0_poliastro.epoch + poliastro_event.last_t
print(f"{poliastro_event_epoch}")

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

0 comments on commit 637042d

Please sign in to comment.