From 4efa661b96d682cad76356ef1355482211c5efc5 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Mon, 28 Sep 2020 14:46:34 +0300 Subject: Show directions and widen table --- iss/predictions.py | 8 +++++--- iss/templates/base.html | 2 +- iss/templates/index.html | 10 +++++----- iss/tests/test_predictions.py | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/iss/predictions.py b/iss/predictions.py index df6326a..b62465d 100644 --- a/iss/predictions.py +++ b/iss/predictions.py @@ -1,7 +1,7 @@ from collections import defaultdict from skyfield.api import Topos, load -from .utils import chunks +from .utils import chunks, deg_to_cardinal ISS = "ISS (ZARYA)" @@ -52,10 +52,12 @@ class Predictions(object): difference = self.satellite - self.location topocentric = difference.at(t) alt, az, distance = topocentric.altaz() + azimuth = int(az.degrees) return { "time": t.utc_iso(), "degrees": int(alt.degrees), - "azimuth": int(az.degrees), + "azimuth": azimuth, + "direction": deg_to_cardinal(azimuth), "distance": int(distance.km), } @@ -94,7 +96,7 @@ class Predictions(object): def truncate_prediction_dates(self, pred): for t in ["rise", "culminate", "set"]: - pred[t]["time"] = pred[t]["time"][11:] + pred[t]["time"] = pred[t]["time"][11:][:-1] return pred def get_grouped_predictions(self): diff --git a/iss/templates/base.html b/iss/templates/base.html index 952f948..eb9767d 100644 --- a/iss/templates/base.html +++ b/iss/templates/base.html @@ -11,7 +11,7 @@
-Upcoming passes of the International Space Station at your location over the next 10 days.
diff --git a/iss/templates/index.html b/iss/templates/index.html index e29da64..37b5f40 100644 --- a/iss/templates/index.html +++ b/iss/templates/index.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block content %} -| Total | Rise | @@ -23,17 +23,17 @@ {% for date, preds in predictions.items() %} {% set date_loop = loop %} {% for pred in preds %} -|||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ date }} | {% endif %}{{ pred.length }} | {{ pred.rise.time }} | -{{ pred.rise.azimuth }} | +{{ pred.rise.azimuth }} ({{ pred.rise.direction }}) | {{ pred.culminate.time }} | -{{ pred.culminate.azimuth }} | +{{ pred.culminate.azimuth }} ({{ pred.culminate.direction }}) | {{ pred.culminate.degrees }} | {{ pred.culminate.distance }} | {{ pred.set.time }} | -{{ pred.set.azimuth }} | +{{ pred.set.azimuth }} ({{ pred.set.direction }}) |