Skip to content

abidinz/NWS-CAP-parser

 
 

Repository files navigation

NWS CAP Parser

A Python module to make parsing National Weather Service (NWS) alerts simple.

Common Alerting Protocol (CAP)

The NWS publishes weather alerts and advisories in the CAP format via Atom feeds. More information - and a full list of US feeds - can be found on the NWS CAP home page.

Module Details

NWSCAPParser

The nwscapparser module exports a single class, NWSCAPParser. Pass a string containing the XML from a CAP alert as the only param to the initialization call:

from nwscapparser import NWSCAPParser
f = r'cap.IL124CA04A2F50.SevereThunderstormWarning.xml'	# included (actual) alert
src = open(f,'r').read()
alert = NWSCAPParser(src)

Of note, the instance exposes the FIPS6 county codes (also known as SAME codes) that the alert references, so that affected counties may be more easily referenced. See the demo file demo.py for complete examples of the methods and fields available in a NWSCAPParser instance.

us_states

The module also exports a dictionary us_states with keys that are two-letter US state abbreviations and values that are full state names, to aid in iterating through the feeds offered by the NWS, which are published by state abbreviations. For example, the CAP feed for Arizona (AZ) can be accessed at the URL http://alerts.weather.gov/cap/az.php?x=1.

About

A simple python class to parse the XML of a Common Alerting Protocol (CAP) message as issued by the National Weather Service (NWS). See http://alerts.weather.gov/ for current CAP messages and more information.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published