summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iss/predictions.py10
-rw-r--r--iss/tests/test_predictions.py19
2 files changed, 21 insertions, 8 deletions
diff --git a/iss/predictions.py b/iss/predictions.py
index eb02ef9..894191a 100644
--- a/iss/predictions.py
+++ b/iss/predictions.py
@@ -45,6 +45,9 @@ class Predictions(object):
by_name = {sat.name: sat for sat in satellites}
return by_name[self.satellite]
+ def get_prediction_details(self, rise, culminate, zet):
+ return {"rise": rise, "culminate": culminate, "set": zet}
+
def get_prediction_events(self):
satellite = self.get_satellite()
t0, t1 = self.get_next_days()
@@ -59,5 +62,8 @@ class Predictions(object):
# docs mention the possibilibity of several culminations
# https://rhodesmill.org/skyfield/earth-satellites.html#finding-when-a-satellite-rises-and-sets
# but this doesn't seem to happen in our case
- preds = chunks(ts, 3)
- return [[t.utc_iso() for t in p] for p in preds]
+ return list(chunks(ts, 3))
+
+ def get_predictions(self):
+ preds = self.get_prediction_events()
+ return [self.get_prediction_details(*p) for p in preds]
diff --git a/iss/tests/test_predictions.py b/iss/tests/test_predictions.py
index 035ab9a..3fbf12d 100644
--- a/iss/tests/test_predictions.py
+++ b/iss/tests/test_predictions.py
@@ -30,7 +30,7 @@ def test_get_location():
assert topos.longitude.degrees == tlv.longitude.degrees
-def test_get_predictions():
+def test_get_prediction_events():
start = 2459117.245895914
p = Predictions(
@@ -38,11 +38,8 @@ def test_get_predictions():
)
preds = p.get_prediction_events()
assert len(preds) == 16
- assert preds[0] == [
- "2020-09-24T21:31:31Z",
- "2020-09-24T21:32:57Z",
- "2020-09-24T21:34:24Z",
- ]
+ preds = [[t.ut1 for t in pred] for pred in preds]
+ assert preds[0] == [2459117.396875682, 2459117.39787489, 2459117.3988819383]
p = Predictions(
lat=32.0853,
@@ -55,3 +52,13 @@ def test_get_predictions():
)
preds = p.get_prediction_events()
assert len(preds) == 39
+
+
+def test_get_predictions():
+ start = 2459117.245895914
+ p = Predictions(
+ lat=32.0853, lng=34.7817, tz="Asia/Jerusalem", start=start, tle_file=STATIONS
+ )
+ preds = p.get_predictions()
+ assert len(preds) == 16
+ assert preds[0]["culminate"].ut1 == 2459117.39787489