warning module

Store and process flood warning data from Flood Monitoring API.

class warning.SeverityLevel

Enum to map severity levels to descriptive severities.

severe = 1
high = 2
moderate = 3
low = 4
class warning.FloodWarning(identifier=None, county=None, label=None, description=None, severity_lev=None, tidal=None, message=None, region=None, geojson=None)

Bases: object

A flood warning data class, obtained from the Flood Monitoring API.

static check_warnings_at_location(warnings, loc)

Check for any flood warnings concerning a specified location.

Parameters
  • warnings (list[Warning]) – List of warnings generated from warningdata.build_warning_list.

  • loc ((lat, long)) –

Returns

warnings_at_loc – A list of warnings pertaining to the location provided.

Return type

list[Warning]

coord_in_region(coord)

Determine if a coordinate is within the region of the flood warning.

Parameters

coord ((lat, long)) – The coordinates of the point in question, as a tuple.

Returns

True if the point is in the region, false if the point is outside the region or the region is None.

Return type

bool

find_towns_affected(stations)

Find towns in the flood warning region with a monitoring station.

Parameters

stations (list[MonitoringStations]) – produced using stationdata.build_station_list().

Returns

list of names of the towns affected.

Return type

list[String]

static geo_json_to_shape(geo_json_obj)

Convert a geoJSON to a shapely object.

Parameters

geo_json_obj (dict) – geoJSON object to be converted.

Returns

The shapely object (of type corresponding to the type of the input) The shape is corrected to form a simple polygon, e.g. by adding points at self intersections.

Return type

shapely_object

static order_warning_list_with_severity(warnings)

Put warnings in order of decreasing severity (most severe first).

Parameters

warnings (list[FloodWarning]) – list of flood warnings.

Returns

warnings_sorted – Ordered list of flood warnings.

Return type

list[FloodWarning]

simplify_geojson(tol=0.001, buf=0.002)

Simplify polygon geometry for better plotting, update self.simplified_geojson.

Parameters
  • tol (float, optional) – Determines the maximum allowed deviation from the original shape. The default is 0.001.

  • buf (float, optional) – The amount to dilate the shapes in order to smooth them. The default is 0.002.

Returns

Return type

None.

stations_in_warning(stations)

Produce a list of stations which are within the warning.

Note it is often the case that a warning region may have no stations in it. This is because the Environmental Agency defines the warning regions based on flood planes or topology regions.

Parameters

stations (list[MonitoringStation]) –

Created using ::

stationdata.build_station_list()``.

Returns

warning_stations – List of monitoring stations whose coordinates are within the warning region.

Return type

list[MonitoringStation]