Skip to content

Commit

Permalink
Merge 0f1a8cf into ca67e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
astrojuanlu committed Aug 4, 2020
2 parents ca67e2e + 0f1a8cf commit a4711a6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
15 changes: 5 additions & 10 deletions orbit_predictor/predictors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,26 +329,21 @@ def _get_illumination(t):

# If found a minimum that is not illuminated, there is an eclipse here
if _get_illumination(eclipse_center_candidate_delta_s) < 0:
# The small time interval to search zeros around the center
# is estimated with the expected eclipse duration (which generally
# is smaller than expected, and that is the reason of the 1.5 coeficient).
# Also a minimum of 180 seconds was added because
# in some cases the estimation is 0 even though there is an eclipse.
eclipse_duration_estimation_s = self.get_eclipse_duration(start) * 60
zero_search_window_s = max(180, 1.5 * eclipse_duration_estimation_s)

# Search now both zeros to get the start and end of the eclipse
# We know that in (0, base_search_window_s) there is a minimum with negative value,
# and also on the opposite side of the eclipse we expect sunlight,
# therefore we already have two robust bracketing intervals
eclipse_start_delta_s = brentq(
_get_illumination,
eclipse_center_candidate_delta_s - zero_search_window_s,
eclipse_center_candidate_delta_s - orbital_period_s / 2,
eclipse_center_candidate_delta_s,
xtol=1e-2,
full_output=False,
)
eclipse_end_delta_s = brentq(
_get_illumination,
eclipse_center_candidate_delta_s,
eclipse_center_candidate_delta_s + zero_search_window_s,
eclipse_center_candidate_delta_s + orbital_period_s / 2,
xtol=1e-2,
full_output=False,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_numerical_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_sun_sync_from_altitude_and_inclination(self):
expected_ecc = 0.14546153131334466

pred = J2Predictor.sun_synchronous(alt_km=475, inc_deg=97)
self.assertAlmostEqual(pred.get_position().osculating_elements[1], expected_ecc, places=15)
self.assertAlmostEqual(pred.get_position().osculating_elements[1], expected_ecc, places=14)

def test_sun_sync_from_eccentricity_and_inclination(self):
# Vallado 3rd edition, example 11-2
Expand Down
17 changes: 17 additions & 0 deletions tests/test_predictors.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,20 @@ def test_eclipses_since_finds_all_eclipses_in_a_few_orbits(sate_predictors, sate
if get_shadow(pos, current_time) != 2:
assert any(ecl_start <= current_time <= ecl_end
for ecl_start, ecl_end in eclipses)


@fastversion
def test_eclipse_corner_case():
# See https://github.com/satellogic/orbit-predictor/issues/96
start = dt.datetime(2020, 9, 1)
end = dt.datetime(2020, 9, 2)
pred = J2Predictor.sun_synchronous(
alt_km=470.0,
ecc=0.001,
ltan_h=19,
ta_deg=0,
date=start,
)
eclipses = list(pred.eclipses_since(when_utc=start, limit_date=end))

assert len(eclipses) == 16

0 comments on commit a4711a6

Please sign in to comment.