zebpalmer / weatheralerts Goto Github PK
View Code? Open in Web Editor NEWPython script to parse the National Weather Service 'Cap' Alerts Feed and do interesting things with it.
License: MIT License
Python script to parse the National Weather Service 'Cap' Alerts Feed and do interesting things with it.
License: MIT License
from weatheralerts import WeatherAlerts
# Alerts by a Samecode
nws = WeatherAlerts(samecodes='005029')
for alert in nws.alerts:
print (alert.title)
(base) william@william:~/CODE/Weather-NOAA-Alert-Example$ python3.6 w.py
Traceback (most recent call last):
File "w.py", line 7, in <module>
nws = WeatherAlerts(samecodes='005029')
File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/weather_alerts.py", line 27, in __init__
self.geo = GeoDB()
File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 17, in __init__
self.__same = SameCodes()
File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 95, in __init__
self._load_same_codes()
File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 111, in _load_same_codes
self._cached_same_codes()
File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 148, in _cached_same_codes
self.reload()
File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 104, in reload
self._load_same_codes(refresh=True)
File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 109, in _load_same_codes
self._get_same_codes()
File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 121, in _get_same_codes
code, local, state = str(row).strip().split(',')
ValueError: not enough values to unpack (expected 3, got 1)
Relatively dumb when it comes to coding. Tried specifying one SAMECODE, got that. Specified 2, got the same results. Same happened when I tried to use a state. Omitting most of the unnecessary code to save 180 or so lines.
import weatheralerts
from weatheralerts import WeatherAlerts
nws = WeatherAlerts(samecodes='022055') #not my SAMECODE, random one I planned on using to test as it had a flash flood warning in effect
for alert in nws.alerts:
print(f"{alert.areadesc}: {alert.title}")
Originally was writing to a file as well, but shouldn't make a difference here whether or not I change it to a print string.
need to parse any location given and verify it's valid, wouldn't want a typo preventing someone from getting an alert....
if a program using the alerts object is long running and then the cache time logic won't be hit and thus never reloaded. need to provide method to check the age of the alerts object and reload new data after the cache maxage is reached
The NOAA url used for the SameCode List does not seem to be active anymore. This is causing init with samecodes to fail.
WeatherAlerts/weatheralerts/geo.py
Line 116 in b995135
Awesome job on this project! Very new to Python is there a way to run the script then have it sleep for say 2 minutes then automatically run again and check for any new alerts? Look forward to your response.
Looks like there may be an error in the library. The following oss project uses this library and it's been causing some issues: Please see this: custom-components/weatheralerts#17 and custom-components/weatheralerts#16
Do you know if there are any issues with pulling some ids like 055009
?
Currently, WeatherAlerts only supports National and State level feeds. The NWS does offer Zone and County feeds (but not samecode based feed) For basic use, pulling the zone/county needed for a samecode would save a lot of processing and bandwidth.
In geo.py, SameCodes._cached_same_codes() returns True regardless of the contents of the cache file. After a failed run, the cache file existed on my file system but was empty. Subsequent attempts all failed because no SAME codes were available.
In addition to checking if the file exists, please ensure that the cache also has useful information and if not, reload().
Thanks!
old interface was using the nws.py file now in the module, need to create new script to handle the command line interaction
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.