summaryrefslogtreecommitdiff
path: root/waterspout_radar
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-04-02 23:17:31 +0200
committerAki <please@ignore.pl>2023-04-02 23:17:31 +0200
commitc0e0bd9fd69e07298d94bd278ab018b5bb4f9759 (patch)
treee35b8f5d79c8cc659a03a88e2bce9b98ce35e51b /waterspout_radar
parent87960bb32cded9ebbf0ba4a9c1fe59596cf59b1c (diff)
downloadwaterspout-radar-c0e0bd9fd69e07298d94bd278ab018b5bb4f9759.zip
waterspout-radar-c0e0bd9fd69e07298d94bd278ab018b5bb4f9759.tar.gz
waterspout-radar-c0e0bd9fd69e07298d94bd278ab018b5bb4f9759.tar.bz2
Extended intermediate prediciton representation with some criteria
Diffstat (limited to 'waterspout_radar')
-rw-r--r--waterspout_radar/_radar.py12
-rw-r--r--waterspout_radar/_storage.py2
2 files changed, 11 insertions, 3 deletions
diff --git a/waterspout_radar/_radar.py b/waterspout_radar/_radar.py
index 629ec55..345bbd6 100644
--- a/waterspout_radar/_radar.py
+++ b/waterspout_radar/_radar.py
@@ -2,6 +2,7 @@ import dataclasses
import datetime
import typing
+import pint
import szilagyi
from geopy import geocoders
from metpy import calc
@@ -14,6 +15,12 @@ _L = point_forecast.Level
@dataclasses.dataclass
class Prediction:
time: datetime.datetime
+ latitude: float
+ longitude: float
+ temperature_difference: pint.Quantity
+ convective_cloud_depth: pint.Quantity
+ wind: pint.Quantity
+ low_clouds: float
swi: float
@@ -26,7 +33,7 @@ def calculate(config) -> typing.List[Prediction]:
config.key,
latitude, longitude,
point_forecast.Model.ICONEU,
- ("temp", "dewpoint", "wind", "pressure"),
+ ("temp", "dewpoint", "wind", "pressure", "lclouds"),
tuple(_L))
for cast in forecasts:
dt = abs(cast.at("temp", _L.H850) - cast.at("temp", _L.SURFACE))
@@ -38,11 +45,12 @@ def calculate(config) -> typing.List[Prediction]:
pressure, _ = calc.el(cast["pressure"], cast["temp"], cast["dewpoint"])
el = calc.pressure_to_height_std(pressure)
ccd = (el - lcl).to(units.ft)
+ clouds = cast["lclouds"].magnitude / 100
try:
swi = szilagyi.calculate_swi(dt, ccd)
except ValueError:
swi = -10
- yield Prediction(time=cast.timestamp, swi=swi)
+ yield Prediction(cast.timestamp, latitude, longitude, dt, ccd, 0, clouds, swi)
predictions = []
locator = geocoders.Nominatim(user_agent="waterspout-radar")
diff --git a/waterspout_radar/_storage.py b/waterspout_radar/_storage.py
index a410259..6b9b968 100644
--- a/waterspout_radar/_storage.py
+++ b/waterspout_radar/_storage.py
@@ -15,4 +15,4 @@ class Storage:
def extend(self, predictions: typing.Iterable[_radar.Prediction]):
for prediction in predictions:
- print(prediction)
+ print(prediction.time, prediction.swi)