From 0de875b0dbfce11138cdea16432ee740bebc736a Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 8 Oct 2022 11:28:08 +0200 Subject: Switched to use vertical profiles from windy package --- waterspout-radar.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/waterspout-radar.py b/waterspout-radar.py index 40c0ff4..c6d5ad5 100644 --- a/waterspout-radar.py +++ b/waterspout-radar.py @@ -9,6 +9,9 @@ from windy import point_forecast from windy import Windy +_L = point_forecast.Level + + def main(): parser = argparse.ArgumentParser() parser.add_argument("location") @@ -21,24 +24,21 @@ def main(): coords = (location.latitude, location.longitude) registry = units model = point_forecast.Model.ICONEU - levels = (point_forecast.Level.SURFACE, point_forecast.Level.H850, point_forecast.Level.H700, point_forecast.Level.H500) + levels = tuple(_L) windy = Windy(registry) forecast = windy.point_forecast(key, *coords, model, ("temp", "dewpoint", "wind", "pressure"), levels) - for entry in forecast: - dt = abs(entry["temp-850h"] - entry["temp-surface"]) - pressure, _ = calc.lcl(entry["pressure-surface"], entry["temp-surface"], entry["dewpoint-surface"]) + for pred in forecast: + dt = abs(pred.at('temp', _L.H850) - pred.at('temp', _L.SURFACE)) + pressure, _ = calc.lcl(pred["pressure"][0], pred["temp"][0], pred["dewpoint"][0]) lcl = calc.pressure_to_height_std(pressure) - pressure, _ = calc.el( - [entry["pressure-surface"].m_as(units.hPa), 850, 700, 500] * units.hPa, - [entry["temp-" + str(x)].m_as(units.degK) for x in levels] * units.degK, - [entry["dewpoint-" + str(x)].m_as(units.degK) for x in levels] * units.degK) + pressure, _ = calc.el(pred['pressure'], pred['temp'], pred['dewpoint']) el = calc.pressure_to_height_std(pressure) ccd = (el - lcl).to(units.ft) try: swi = szilagyi.calculate_swi(dt, ccd) except ValueError: swi = -10 - print(entry.timestamp, dt, ccd, swi) + print(pred.timestamp, dt, ccd, swi) if __name__ == '__main__': -- cgit v1.1