Module Documentation

Below you’ll find the documentation for the various classes and methods in WeatherAlerts.

Note

This page is dynamically generated from the documentation written into the code

WeatherAlerts.nws

File Information

Project Home:
http://github.com/zebpalmer/WeatherAlerts
Original Author:
Zeb Palmer http://www.zebpalmer.com
Documentation:
http://weatheralerts.readthedocs.org
License:
GPLv3 - full text included in LICENSE.txt

License Notice:

This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Code Documentation

class weatheralerts.nws.Alerts(state='', geocodes='', load=True)

Alerts object that controls interaction with the samecodes and capparser classes/methods. Pass state=’’ or geocodes=’samecodes_list’ to change which feed is being parsed passing a list of samecodes will determine if they are in the same state and pick the correct feed or use the US feed if they’re in different states

alerts_by_county_state(req_location)

returns alerts for given county, state

alerts_by_samecodes(geocodes)

returns alerts for a given SAME code

json

returns json object of all alerts on specified feed (National feed by default)

load_alerts()

manually load the cap feed/alerts

pyobj

returns python object of all alerts for specified feed(National by default)

set_state(state)

sets state, reloads alerts unless told otherwise

state_summary(state='')

print all alerts for a given state

target_area(locations)

TODO: not used yet sets target areas to be used in all limiting functions

class weatheralerts.nws.CapAlertsFeed(state='US', geo=None, maxage=3, reload=False)

Class to fetch and load the NWS CAP/XML Alerts feed for the US or a single state if requested if an instance of the SameCodes class has already been (to do a geo lookup), you can pass that as well to save some processing

alerts

returns all alerts on feed

check_objectage()

check age of alerts in this object, reload if past max cache time

reload_alerts()

Reload alerts bypassing cache

class weatheralerts.nws.GeoDB

Interact with samecodes object and other geolocation data that will be added soon

get_states_from_samecodes(geocodes)

Returns all states for a given list of SAME codes Shouldn’t be used to determine feed scope, please use getfeedscope()

getfeedscope(geocodes)

Given multiple SAME codes, determine if they are all in one state. If so, it returns that state. Otherwise return ‘US’. This is used to determine which NWS feed needs to be parsed to get all alerts for the requested SAME codes

getstate(geosame)

Given a SAME code, return the state that SAME code is in

location_lookup(req_location)

returns full location given samecode or county and state. Returns False if not valid. currently locations are a dictionary, once other geo data is added, they will move to a location class/obj

lookup_samecode(local, state)

Given County, State return the SAME code for specified location. Return False if not found

class weatheralerts.nws.SameCodes

Is used to download, parse and cache the SAME codes data from the web. All interaction with the SAME codes data should be done in the GeoGB classy

reload()

force refresh of Same Codes (mainly for testing)

samecodes

public method to return the same codes list

weatheralerts.nws.alert_type(alert)

return alert type for a given alert

Project Versions

Table Of Contents

Previous topic

Release Changes

This Page