generated from CambridgeEngineering/PartIA-Flood-Warning-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Flood.py
25 lines (21 loc) · 849 Bytes
/
Flood.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from floodsystem import station
from floodsystem.station import MonitoringStation
def stations_level_over_threshold(stations, tol):
rivers = []
stations = MonitoringStation.relative_water_level(stations)
"Filter out data with no relative level"
stations = [i for i in stations if None not in i]
"Checks ratio against tolerance"
for s in stations:
if s[1] > tol:
rivers += [(s[0], s[1])]
return rivers
def stations_highest_rel_level(stations, N):
"Returns a list of the N stations where the relative water level is highest"
stations = station.MonitoringStation.relative_water_level(stations)
stations = [i for i in stations if None not in i]
rivers = sorted(stations, key=lambda x: x[1], reverse=True)
s = []
for key, value in rivers:
s.append(key)
return s[:N]