diff options
| author | Yuval Adam <_@yuv.al> | 2020-09-28 14:46:34 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2020-09-28 14:46:34 +0300 |
| commit | 4efa661b96d682cad76356ef1355482211c5efc5 (patch) | |
| tree | dcc6dafd3ef7b2a835936ffb254a0dc056b7772e | |
| parent | d3caed4241328258dee6190463bae8b4b5f3800d (diff) | |
Show directions and widen table
| -rw-r--r-- | iss/predictions.py | 8 | ||||
| -rw-r--r-- | iss/templates/base.html | 2 | ||||
| -rw-r--r-- | iss/templates/index.html | 10 | ||||
| -rw-r--r-- | 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 @@ <link rel="shortcut icon" href="favicon.ico"/> </head> <body class="bg-near-black near-white"> - <div class="pa4 mw7 center"> + <div class="pa4 mw8 center"> <h1 class="f1 moon-gray">ISS Pass Predictions</h1> <p class="light-red">Upcoming passes of the <a href="https://en.wikipedia.org/wiki/International_Space_Station" class="link red dim">International Space Station</a> at your location over the next 10 days.</p> 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 %} -<table class="tl pa1"> +<table class="tl pa1 w-100"> <tr class=" tc pa1 f3"> <th colspan="1">Total</th> <th colspan="2">Rise</th> @@ -23,17 +23,17 @@ {% for date, preds in predictions.items() %} {% set date_loop = loop %} {% for pred in preds %} - <tr class="pa2 {{ date_loop.cycle('light-gray', 'light-silver') }}"> + <tr class="pa1 {{ date_loop.cycle('light-gray', 'light-silver') }}"> {% if loop.first %}<td rowspan="{{ preds|length }}">{{ date }}</td>{% endif %} <td>{{ pred.length }}</td> <td>{{ pred.rise.time }}</td> - <td>{{ pred.rise.azimuth }}</td> + <td>{{ pred.rise.azimuth }} ({{ pred.rise.direction }})</td> <td>{{ pred.culminate.time }}</td> - <td>{{ pred.culminate.azimuth }}</td> + <td>{{ pred.culminate.azimuth }} ({{ pred.culminate.direction }})</td> <td>{{ pred.culminate.degrees }}</td> <td>{{ pred.culminate.distance }}</td> <td>{{ pred.set.time }}</td> - <td>{{ pred.set.azimuth }}</td> + <td>{{ pred.set.azimuth }} ({{ pred.set.direction }}) </td> </tr> {% endfor %} {% endfor %} diff --git a/iss/tests/test_predictions.py b/iss/tests/test_predictions.py index 29b939b..951186e 100644 --- a/iss/tests/test_predictions.py +++ b/iss/tests/test_predictions.py @@ -74,6 +74,6 @@ def test_get_grouped_predictions(): ) preds = p.get_grouped_predictions() assert "2020-09-28" in preds - assert preds["2020-09-28"][0]["rise"]["time"] == "10:14:44Z" - assert preds["2020-09-28"][1]["culminate"]["time"] == "11:51:14Z" - assert preds["2020-09-28"][1]["set"]["time"] == "11:56:36Z" + assert preds["2020-09-28"][0]["rise"]["time"] == "10:14:44" + assert preds["2020-09-28"][1]["culminate"]["time"] == "11:51:14" + assert preds["2020-09-28"][1]["set"]["time"] == "11:56:36" |
