summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-10-08 11:28:08 +0200
committerAki <please@ignore.pl>2022-10-08 11:28:08 +0200
commit0de875b0dbfce11138cdea16432ee740bebc736a (patch)
treeba82982708899a8e31975d6ef77a1a9a11c3bb5f
parent55e8aae0156b06558df7806ccb6c436fa3775951 (diff)
downloadwaterspout-radar-0de875b0dbfce11138cdea16432ee740bebc736a.zip
waterspout-radar-0de875b0dbfce11138cdea16432ee740bebc736a.tar.gz
waterspout-radar-0de875b0dbfce11138cdea16432ee740bebc736a.tar.bz2
Switched to use vertical profiles from windy package
-rw-r--r--waterspout-radar.py18
1 files 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__':