summaryrefslogtreecommitdiff
path: root/waterspout_radar
diff options
context:
space:
mode:
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)