diff options
author | Aki <please@ignore.pl> | 2023-04-03 23:27:10 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-04-03 23:27:10 +0200 |
commit | e433009ef3df8f3b27bdaf0bb3ff7c79909c89ba (patch) | |
tree | 5a35d287744ed604cc1d33b69abbe9529a3119bd | |
parent | 9451fa019cb084db820f3255b0da2cc863d0f990 (diff) | |
download | waterspout-radar-e433009ef3df8f3b27bdaf0bb3ff7c79909c89ba.zip waterspout-radar-e433009ef3df8f3b27bdaf0bb3ff7c79909c89ba.tar.gz waterspout-radar-e433009ef3df8f3b27bdaf0bb3ff7c79909c89ba.tar.bz2 |
Calculate wind speed and add it to predictions
-rw-r--r-- | waterspout_radar/_radar.py | 5 | ||||
-rw-r--r-- | waterspout_radar/web.py | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/waterspout_radar/_radar.py b/waterspout_radar/_radar.py index c8cca1f..380c70b 100644 --- a/waterspout_radar/_radar.py +++ b/waterspout_radar/_radar.py @@ -2,6 +2,7 @@ import dataclasses import datetime import typing +import numpy as np import pint import szilagyi from geopy import geocoders @@ -75,7 +76,9 @@ def calculate(config) -> typing.List[Prediction]: swi = szilagyi.calculate_swi(dt, ccd) except ValueError: swi = -10 - wind = 0.0 * units.kts + 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) predictions = [] diff --git a/waterspout_radar/web.py b/waterspout_radar/web.py index 67ac4ca..63fa3fa 100644 --- a/waterspout_radar/web.py +++ b/waterspout_radar/web.py @@ -10,8 +10,14 @@ def predictions(): body = "<!doctype html><html lang='en'><meta charset='utf-8'><title>Predictions</title>" body += "<h1>Prediction</h1><hr>" body += "<table>" - body += "<tr><th>Time<th>ΔTemp<th>Depth<th>SWI</tr>" + body += "<tr><th>Time<th>ΔTemp<th>Depth<th>Wind<th>SWI</tr>" for prediction in sorted(_storage.Storage(".waterspout/predictions.json"), key=lambda x: (x.time, x.swi)): - body += f"<tr><td>{prediction.time}<td>{prediction.temperature_difference}<td>{prediction.convective_cloud_depth}<td>{prediction.swi}</tr>" + body += "<tr>" + body += f"<td>{prediction.time}" + body += f"<td>{prediction.temperature_difference}" + body += f"<td>{prediction.convective_cloud_depth}" + body += f"<td>{prediction.wind}" + body += f"<td>{prediction.swi}" + body += "</tr>" body += "</table>" return body |