diff options
author | Aki <please@ignore.pl> | 2023-04-08 01:11:49 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-04-08 01:11:49 +0200 |
commit | e3774e25c7e6afd415f3a64843a416047efa629b (patch) | |
tree | 7ebd72e7c60cfcd3ce58ba6101eb1c5aed188a28 /waterspout_radar | |
parent | d7e9b83def504b352b25bb1432a6621e720fb4cd (diff) | |
download | waterspout-radar-master.zip waterspout-radar-master.tar.gz waterspout-radar-master.tar.bz2 |
Diffstat (limited to 'waterspout_radar')
-rw-r--r-- | waterspout_radar/_radar.py | 6 | ||||
-rw-r--r-- | waterspout_radar/web.py | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/waterspout_radar/_radar.py b/waterspout_radar/_radar.py index 380c70b..336edd5 100644 --- a/waterspout_radar/_radar.py +++ b/waterspout_radar/_radar.py @@ -16,6 +16,7 @@ _L = point_forecast.Level @dataclasses.dataclass class Prediction: time: datetime.datetime + made: datetime.datetime latitude: float longitude: float temperature_difference: pint.Quantity @@ -27,6 +28,7 @@ class Prediction: def json(self): return { "time": self.time.isoformat(), + "made": self.made.isoformat(), "latitude": self.latitude, "longitude": self.longitude, "dt": self.temperature_difference.m_as("kelvin"), @@ -40,6 +42,7 @@ class Prediction: def from_json(cls, json): return cls( datetime.datetime.fromisoformat(json["time"]), + datetime.datetime.fromisoformat(json["made"]), json["latitude"], json["longitude"], json["dt"] * metunits.units.kelvin, @@ -53,6 +56,7 @@ class Prediction: def calculate(config) -> typing.List[Prediction]: units = metunits.units windy = Windy(units) + now = datetime.datetime.now() def _calculate(latitude, longitude): forecasts = windy.point_forecast( @@ -79,7 +83,7 @@ def calculate(config) -> typing.List[Prediction]: wind = [cast.at("wind_u", _L.H850), cast.at("wind_v", _L.H850)] wind = np.array([x.m_as("kts") for x in wind]) wind = np.linalg.norm(wind) * units.kts - yield Prediction(cast.timestamp, latitude, longitude, dt, ccd, wind, clouds, swi) + yield Prediction(cast.timestamp, now, latitude, longitude, dt, ccd, wind, clouds, swi) predictions = [] locator = geocoders.Nominatim(user_agent="waterspout-radar") diff --git a/waterspout_radar/web.py b/waterspout_radar/web.py index f43d2c0..332c533 100644 --- a/waterspout_radar/web.py +++ b/waterspout_radar/web.py @@ -8,5 +8,5 @@ config = _config.load(_config.effective_pathname()) @app.route("/") def predictions(): - predictions = sorted(_storage.Storage(config.db), key=lambda x: (x.time, x.swi)) + predictions = sorted(_storage.Storage(config.db), key=lambda x: (x.time, x.made)) return flask.render_template("predictions.html", predictions=predictions) |