Skip to content

Commit

Permalink
Merge pull request #105 from astrojuanlu/fix-los-corner-case
Browse files Browse the repository at this point in the history
Fix LOS computation corner case
  • Loading branch information
astrojuanlu committed Sep 28, 2020
2 parents 55805b5 + 0e53c51 commit c03e11a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
@@ -1,5 +1,9 @@
# orbit-predictor changelog

## 1.13.2 (2020-09-28)

* Make LOS computation more robust in new pass predictor

## 1.13.1 (2020-09-28)

* Fix version number
Expand Down
4 changes: 2 additions & 2 deletions orbit_predictor/predictors/pass_iterators.py
Expand Up @@ -264,11 +264,11 @@ def elevation(delta_seconds):
# Ensure location is visible at AOS by adding atol
aos = start_date + dt.timedelta(seconds=t_aos + self.tolerance_s)

# LOS must be between TCA and an elapsed time around (TCA - AOS)
# LOS must be between TCA and half the next period
try:
t_los = root_scalar(
lambda t: elevation(t) - self.aos_at,
bracket=(t_tca, t_tca + (t_tca - t_aos) + 60),
bracket=(t_tca, t_tca + period_s / 2),
xtol=self.tolerance_s,
).root
except ValueError as e:
Expand Down
2 changes: 1 addition & 1 deletion orbit_predictor/version.py
@@ -1,2 +1,2 @@
# https://www.python.org/dev/peps/pep-0440/
__version__ = '1.13.1'
__version__ = '1.13.2'
36 changes: 36 additions & 0 deletions tests/test_accurate_predictor.py
Expand Up @@ -294,3 +294,39 @@ def test_pass_is_not_skipped_smart(self):
))

assert predicted_passes


class LOSComputationRegressionTests(TestCase):
"""Check that we the LOS is computed correctly"""
# See https://github.com/satellogic/orbit-predictor/issues/104

def setUp(self):
tle_lines = (
"1 42760U 17034C 19070.46618549 .00000282 00000-0 30543-4 0 9995",
"2 42760 43.0166 56.1509 0009676 356.3576 146.0151 15.09909885 95848",
)
self.db = MemoryTLESource()
self.db.add_tle("42760U", tle_lines, dt.datetime.now())
self.predictor = TLEPredictor("42760U", self.db)

@pytest.mark.skipif(sys.version_info < (3, 5), reason="Not installing SciPy in Python 3.4")
def test_los_is_correctly_computed(self):
loc = Location(
name='loc',
latitude_deg=-34.61315,
longitude_deg=-58.37723,
elevation_m=30,
)

PASS_DATE = dt.datetime(2019, 1, 1, 0, 0)
LIMIT_DATE = dt.datetime(2019, 1, 15, 0, 0)

predicted_passes = list(self.predictor.passes_over(
loc,
when_utc=PASS_DATE,
limit_date=LIMIT_DATE,
aos_at_dg=0, max_elevation_gt=0,
location_predictor_class=SmartLocationPredictor,
))

assert predicted_passes

0 comments on commit c03e11a

Please sign in to comment.