From c0e0bd9fd69e07298d94bd278ab018b5bb4f9759 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 2 Apr 2023 23:17:31 +0200 Subject: Extended intermediate prediciton representation with some criteria --- waterspout_radar/_radar.py | 12 ++++++++++-- waterspout_radar/_storage.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'waterspout_radar') 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) -- cgit v1.1