WxBDM / nwsapy

A pythonic way to implement the National Weather Service API.
https://nwsapy.readthedocs.io/en/latest/
Other
7 stars 1 forks source link

IndividualAlerts: .states #1

Closed WxBDM closed 2 years ago

WxBDM commented 3 years ago

Turns out that there's discontinuity within the API itself. If I wanted to get all of the alerts in Utah, I can easily make a request like this:

alerts = nwsapy.get_all_alerts(active = True, area = "UT", event = "Excessive Heat Warning")

Turns out that there's no way to get all the alerts in Utah directly if you were to do this:

alerts = nwsapy.get_all_alerts()

You'd have to parse the IndividualAlert.areaDesc string. It's not always a City, State structure: there's national parks, etc (such as Yavapai County Mountains; Yavapai County Valleys and Basins; Oak Creek and Sycamore Canyons), so something like [alert for alert in alerts if "UT" in alert.areaDesc] doesn't work.

The way to go about doing this is to parse (not get) the affectedZones list. At the end of the URL, it has zones where the alert is effecting it (i.e. FLZ001), where the first 2 letters is the name of the state.

WxBDM commented 2 years ago

Closed due to v1.0.0