diff options
| author | Yuval Adam <_@yuv.al> | 2020-09-28 14:39:59 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2020-09-28 14:39:59 +0300 |
| commit | d3caed4241328258dee6190463bae8b4b5f3800d (patch) | |
| tree | 0077dd6f31bc5c81124c34b35f215ef1648c275c /iss/predictions.py | |
| parent | 6ca40df643842932c9b36557ce69fd7a2ed0e6c4 (diff) | |
Use grouped predictions for dates in table
Diffstat (limited to 'iss/predictions.py')
| -rw-r--r-- | iss/predictions.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/iss/predictions.py b/iss/predictions.py index bab9f17..df6326a 100644 --- a/iss/predictions.py +++ b/iss/predictions.py @@ -1,3 +1,4 @@ +from collections import defaultdict from skyfield.api import Topos, load from .utils import chunks @@ -90,3 +91,18 @@ class Predictions(object): def get_predictions(self): preds = self.get_prediction_events() return [self.get_prediction_details(*p) for p in preds] + + def truncate_prediction_dates(self, pred): + for t in ["rise", "culminate", "set"]: + pred[t]["time"] = pred[t]["time"][11:] + return pred + + def get_grouped_predictions(self): + preds = self.get_predictions() + res = defaultdict(list) + + for pred in preds: + date = pred["rise"]["time"][:10] + res[date].append(self.truncate_prediction_dates(pred)) + + return res |
