summaryrefslogtreecommitdiff
path: root/waterspout-radar.py
diff options
context:
space:
mode:
Diffstat (limited to 'waterspout-radar.py')
-rw-r--r--waterspout-radar.py45
1 files changed, 0 insertions, 45 deletions
diff --git a/waterspout-radar.py b/waterspout-radar.py
deleted file mode 100644
index ec58e64..0000000
--- a/waterspout-radar.py
+++ /dev/null
@@ -1,45 +0,0 @@
-import argparse
-import os
-
-import szilagyi
-from geopy.geocoders import Nominatim
-from metpy import calc
-from metpy.units import units
-from windy import point_forecast
-from windy import Windy
-
-
-_L = point_forecast.Level
-
-
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("location")
- args = parser.parse_args()
- key = os.getenv("WINDY_KEY")
- if not key:
- raise RuntimeError("expected windy's api key")
- locator = Nominatim(user_agent="waterspout-radar")
- location = locator.geocode(args.location)
- coords = (location.latitude, location.longitude)
- registry = units
- model = point_forecast.Model.ICONEU
- levels = tuple(_L)
- windy = Windy(registry)
- forecast = windy.point_forecast(key, *coords, model, ("temp", "dewpoint", "wind", "pressure"), levels)
- 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(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, pred.at('wind_u', _L.H850)) # merge with wind_v
- except ValueError:
- swi = -10
- print(pred.timestamp, dt, ccd, swi)
-
-
-if __name__ == '__main__':
- main()