py-ewr 1.0.8__py3-none-any.whl → 2.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_ewr/data_inputs.py +163 -249
- py_ewr/evaluate_EWRs.py +2747 -1248
- py_ewr/model_metadata/SiteID_MDBA.csv +87 -20
- py_ewr/model_metadata/SiteID_NSW.csv +49 -0
- py_ewr/observed_handling.py +63 -39
- py_ewr/parameter_metadata/ewr_calc_config.json +662 -0
- py_ewr/parameter_metadata/parameter_sheet.csv +3415 -0
- py_ewr/scenario_handling.py +55 -38
- py_ewr/summarise_results.py +67 -28
- py_ewr-2.1.0.dist-info/METADATA +221 -0
- py_ewr-2.1.0.dist-info/RECORD +15 -0
- {py_ewr-1.0.8.dist-info → py_ewr-2.1.0.dist-info}/WHEEL +1 -1
- py_ewr/climate_data/climate_cats.csv +0 -212
- py_ewr/climate_data/climate_cats_10000year.csv +0 -10003
- py_ewr/parameter_metadata/NSWEWR.csv +0 -2674
- py_ewr-1.0.8.dist-info/METADATA +0 -190
- py_ewr-1.0.8.dist-info/RECORD +0 -16
- {py_ewr-1.0.8.dist-info → py_ewr-2.1.0.dist-info}/LICENSE +0 -0
- {py_ewr-1.0.8.dist-info → py_ewr-2.1.0.dist-info}/top_level.txt +0 -0
py_ewr/data_inputs.py
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import requests
|
|
1
|
+
import json
|
|
3
2
|
import pandas as pd
|
|
4
3
|
import numpy as np
|
|
5
4
|
from pathlib import Path
|
|
6
5
|
import os
|
|
6
|
+
import logging
|
|
7
7
|
|
|
8
8
|
from cachetools import cached, TTLCache
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
log = logging.getLogger(__name__)
|
|
11
|
+
log.addHandler(logging.NullHandler())
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
BASE_PATH = Path(__file__).resolve().parent
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
@cached(cache=TTLCache(maxsize=1024, ttl=1800))
|
|
16
|
+
def get_ewr_calc_config(file_path:str = None) -> dict:
|
|
17
|
+
'''Loads the EWR calculation configuration file from repository or local file
|
|
18
|
+
system
|
|
17
19
|
|
|
18
20
|
Args:
|
|
19
|
-
|
|
21
|
+
file_path (str): Location of the EWR calculation configuration file
|
|
20
22
|
|
|
21
23
|
Returns:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
dict: Returns a dictionary of the EWR calculation configuration file
|
|
24
25
|
'''
|
|
25
26
|
|
|
26
|
-
if
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
if file_path:
|
|
28
|
+
with open(file_path, 'r') as fp:
|
|
29
|
+
ewr_calc_config = json.load(fp)
|
|
30
|
+
|
|
31
|
+
if not file_path:
|
|
32
|
+
repo_path = os.path.join(BASE_PATH, "parameter_metadata/ewr_calc_config.json")
|
|
33
|
+
with open(repo_path, 'r') as fp:
|
|
34
|
+
ewr_calc_config = json.load(fp)
|
|
35
|
+
|
|
36
|
+
return ewr_calc_config
|
|
33
37
|
|
|
34
38
|
@cached(cache=TTLCache(maxsize=1024, ttl=1800))
|
|
35
39
|
def get_EWR_table(file_path:str = None) -> dict:
|
|
@@ -49,26 +53,33 @@ def get_EWR_table(file_path:str = None) -> dict:
|
|
|
49
53
|
usecols=['PlanningUnitID', 'PlanningUnitName', 'LTWPShortName', 'CompliancePoint/Node', 'Gauge', 'Code', 'StartMonth',
|
|
50
54
|
'EndMonth', 'TargetFrequency', 'TargetFrequencyMin', 'TargetFrequencyMax', 'EventsPerYear', 'Duration', 'MinSpell',
|
|
51
55
|
'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event', 'WithinEventGapTolerance', 'WeirpoolGauge', 'FlowLevelVolume',
|
|
52
|
-
'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'AccumulationPeriod',
|
|
53
|
-
'Multigauge', 'MaxSpell', 'TriggerDay', 'TriggerMonth', 'DrawDownRateWeek'
|
|
54
|
-
|
|
56
|
+
'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'MaxLevelRise','AccumulationPeriod',
|
|
57
|
+
'Multigauge', 'MaxSpell', 'TriggerDay', 'TriggerMonth', 'DrawDownRateWeek', 'AnnualFlowSum','AnnualBarrageFlow',
|
|
58
|
+
'ThreeYearsBarrageFlow', 'HighReleaseWindowStart', 'HighReleaseWindowEnd', 'LowReleaseWindowStart', 'LowReleaseWindowEnd',
|
|
59
|
+
'PeakLevelWindowStart', 'PeakLevelWindowEnd', 'LowLevelWindowStart', 'LowLevelWindowEnd', 'NonFlowSpell', 'EggsDaysSpell',
|
|
60
|
+
'LarvaeDaysSpell','MinLevelRise', 'RateOfRiseMax1','RateOfRiseMax2','RateOfFallMin','RateOfRiseThreshold1',
|
|
61
|
+
'RateOfRiseThreshold2','RateOfRiseRiverLevel','RateOfFallRiverLevel', 'CtfThreshold', 'GaugeType'],
|
|
62
|
+
dtype='str', encoding='cp1252')
|
|
63
|
+
|
|
55
64
|
|
|
56
65
|
if not file_path:
|
|
57
|
-
my_url = os.path.join(BASE_PATH, "parameter_metadata/
|
|
66
|
+
my_url = os.path.join(BASE_PATH, "parameter_metadata/parameter_sheet.csv")
|
|
58
67
|
proxies={} # Populate with your proxy settings
|
|
59
|
-
|
|
60
|
-
df = pd.read_csv(my_url,#io.StringIO(s),
|
|
68
|
+
df = pd.read_csv(my_url,
|
|
61
69
|
usecols=['PlanningUnitID', 'PlanningUnitName', 'LTWPShortName', 'CompliancePoint/Node', 'Gauge', 'Code', 'StartMonth',
|
|
62
70
|
'EndMonth', 'TargetFrequency', 'TargetFrequencyMin', 'TargetFrequencyMax', 'EventsPerYear', 'Duration', 'MinSpell',
|
|
63
71
|
'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event', 'WithinEventGapTolerance', 'WeirpoolGauge', 'FlowLevelVolume',
|
|
64
|
-
'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'AccumulationPeriod',
|
|
65
|
-
'Multigauge', 'MaxSpell', 'TriggerDay', 'TriggerMonth', 'DrawDownRateWeek'
|
|
72
|
+
'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'MaxLevelRise', 'AccumulationPeriod',
|
|
73
|
+
'Multigauge', 'MaxSpell', 'TriggerDay', 'TriggerMonth', 'DrawDownRateWeek','AnnualFlowSum','AnnualBarrageFlow',
|
|
74
|
+
'ThreeYearsBarrageFlow', 'HighReleaseWindowStart', 'HighReleaseWindowEnd', 'LowReleaseWindowStart', 'LowReleaseWindowEnd',
|
|
75
|
+
'PeakLevelWindowStart', 'PeakLevelWindowEnd', 'LowLevelWindowStart', 'LowLevelWindowEnd', 'NonFlowSpell','EggsDaysSpell',
|
|
76
|
+
'LarvaeDaysSpell','MinLevelRise', 'RateOfRiseMax1','RateOfRiseMax2','RateOfFallMin','RateOfRiseThreshold1',
|
|
77
|
+
'RateOfRiseThreshold2','RateOfRiseRiverLevel','RateOfFallRiverLevel', 'CtfThreshold', 'GaugeType'],
|
|
66
78
|
dtype='str', encoding='cp1252'
|
|
67
79
|
)
|
|
68
80
|
|
|
69
81
|
df = df.replace('?','')
|
|
70
82
|
df = df.fillna('')
|
|
71
|
-
|
|
72
83
|
# removing the 'See notes'
|
|
73
84
|
okay_EWRs = df.loc[(df["StartMonth"] != 'See note') & (df["EndMonth"] != 'See note')]
|
|
74
85
|
see_notes = df.loc[(df["StartMonth"] == 'See note') & (df["EndMonth"] == 'See note')]
|
|
@@ -101,96 +112,6 @@ def get_EWR_table(file_path:str = None) -> dict:
|
|
|
101
112
|
|
|
102
113
|
return okay_EWRs, bad_EWRs
|
|
103
114
|
|
|
104
|
-
@cached(cache=TTLCache(maxsize=1024, ttl=1800))
|
|
105
|
-
def map_gauge_to_catchment(my_url:str = "parameter_metadata/NSWEWR.csv") -> dict:
|
|
106
|
-
''' Allocates all the locations in the ewr table with catchments, as indicated by the
|
|
107
|
-
first three numbers for each gauge
|
|
108
|
-
|
|
109
|
-
Args:
|
|
110
|
-
my_url (str): location of the EWR dataset
|
|
111
|
-
Returns:
|
|
112
|
-
dict[dict]: Dictinoary of catchments, for each catchment a dictionary of gauge number and name key value pairs
|
|
113
|
-
'''
|
|
114
|
-
|
|
115
|
-
lower_darling_gauges = ['425054', '425010', '425011', '425052', '425013', '425056', '425007',
|
|
116
|
-
'425057', '425005', '425050', '425048', '425019', '425014', '425023',
|
|
117
|
-
'425012', '425044', '425049', '425001', '425022', '42510037', '42510036',
|
|
118
|
-
'425034', '425046', '425020', ]
|
|
119
|
-
|
|
120
|
-
EWR_table, bad_EWRs = get_EWR_table(os.path.join(BASE_PATH, my_url))
|
|
121
|
-
|
|
122
|
-
gauge_number = EWR_table['Gauge'].values
|
|
123
|
-
gauge_name = EWR_table['CompliancePoint/Node'].values
|
|
124
|
-
|
|
125
|
-
gauge_to_name = dict()
|
|
126
|
-
for iteration, value in enumerate(gauge_number):
|
|
127
|
-
if type(value) == str:
|
|
128
|
-
gauge_to_name[value] = gauge_name[iteration]
|
|
129
|
-
|
|
130
|
-
gauge_to_catchment = dict()
|
|
131
|
-
namoi_catchment = dict()
|
|
132
|
-
gwydir_catchment = dict()
|
|
133
|
-
macquarie_catchment = dict()
|
|
134
|
-
lachlan_catchment = dict()
|
|
135
|
-
murray_catchment = dict()
|
|
136
|
-
lower_darling_catchment = dict()
|
|
137
|
-
barwon_darling_catchment = dict()
|
|
138
|
-
murrumbidgee_catchment = dict()
|
|
139
|
-
border_rivers_catchment = dict()
|
|
140
|
-
moonie_catchment = dict()
|
|
141
|
-
condamine_balonne = dict()
|
|
142
|
-
warrego_catchment = dict()
|
|
143
|
-
paroo_catchment = dict()
|
|
144
|
-
other_catchment = dict()
|
|
145
|
-
|
|
146
|
-
for k, v in gauge_to_name.items():
|
|
147
|
-
if k.startswith('419'):
|
|
148
|
-
namoi_catchment.update({k: v})
|
|
149
|
-
elif k.startswith('418'):
|
|
150
|
-
gwydir_catchment.update({k: v})
|
|
151
|
-
elif (k.startswith('421') or k.startswith('420')):
|
|
152
|
-
macquarie_catchment.update({k: v})
|
|
153
|
-
elif k.startswith('412'):
|
|
154
|
-
lachlan_catchment.update({k: v})
|
|
155
|
-
elif (k.startswith('401') or k.startswith('409') or k.startswith('A426') or k.startswith('414')):
|
|
156
|
-
murray_catchment.update({k: v})
|
|
157
|
-
elif k.startswith('425'):
|
|
158
|
-
if k in lower_darling_gauges:
|
|
159
|
-
lower_darling_catchment.update({k: v})
|
|
160
|
-
else:
|
|
161
|
-
barwon_darling_catchment.update({k: v})
|
|
162
|
-
elif k.startswith('410'):
|
|
163
|
-
murrumbidgee_catchment.update({k: v})
|
|
164
|
-
elif k.startswith('416'):
|
|
165
|
-
border_rivers_catchment.update({k: v})
|
|
166
|
-
elif k.startswith('417'):
|
|
167
|
-
moonie_catchment.update({k: v})
|
|
168
|
-
elif k.startswith('422'):
|
|
169
|
-
condamine_balonne.update({k: v})
|
|
170
|
-
elif k.startswith('423'):
|
|
171
|
-
warrego_catchment.update({k: v})
|
|
172
|
-
elif k.startswith('424'):
|
|
173
|
-
paroo_catchment.update({k: v})
|
|
174
|
-
else:
|
|
175
|
-
other_catchment.update({k: v})
|
|
176
|
-
|
|
177
|
-
gauge_to_catchment.update({'Namoi': namoi_catchment,
|
|
178
|
-
'Gwydir': gwydir_catchment,
|
|
179
|
-
'Macquarie-Castlereagh': macquarie_catchment,
|
|
180
|
-
'Lachlan': lachlan_catchment,
|
|
181
|
-
'Lower Darling': lower_darling_catchment,
|
|
182
|
-
'Barwon-Darling': barwon_darling_catchment,
|
|
183
|
-
'Murray': murray_catchment,
|
|
184
|
-
'Murrumbidgee': murrumbidgee_catchment,
|
|
185
|
-
'Border Rivers': border_rivers_catchment,
|
|
186
|
-
'Moonie' : moonie_catchment,
|
|
187
|
-
'Condamine-Balonne': condamine_balonne,
|
|
188
|
-
'Warrego': warrego_catchment,
|
|
189
|
-
'Paroo': paroo_catchment,
|
|
190
|
-
'Other': other_catchment
|
|
191
|
-
})
|
|
192
|
-
return gauge_to_catchment
|
|
193
|
-
|
|
194
115
|
def get_MDBA_codes() -> pd.DataFrame:
|
|
195
116
|
'''
|
|
196
117
|
Load MDBA model metadata file containing model nodes
|
|
@@ -217,54 +138,6 @@ def get_NSW_codes() -> pd.DataFrame:
|
|
|
217
138
|
|
|
218
139
|
return metadata
|
|
219
140
|
|
|
220
|
-
def gauge_to_catchment(input_gauge:str) -> str:
|
|
221
|
-
'''
|
|
222
|
-
Takes in a gauge, maps it to the catchment
|
|
223
|
-
returns the catchment
|
|
224
|
-
|
|
225
|
-
Args:
|
|
226
|
-
input_gauge (str): Gauge string
|
|
227
|
-
|
|
228
|
-
Returns:
|
|
229
|
-
str: The catchment name that the input gauge is located in
|
|
230
|
-
|
|
231
|
-
'''
|
|
232
|
-
catchments_gauges = map_gauge_to_catchment()
|
|
233
|
-
for catchment in catchments_gauges:
|
|
234
|
-
if input_gauge in catchments_gauges[catchment]:
|
|
235
|
-
return catchment
|
|
236
|
-
|
|
237
|
-
def wy_to_climate(water_years: np.array, catchment: str, climate_file: str) -> np.array:
|
|
238
|
-
'''
|
|
239
|
-
The function assigns a climate categorisation for every day, depending on the water year and catchment in the climate file
|
|
240
|
-
|
|
241
|
-
Args:
|
|
242
|
-
water_years (np.array): Daily water year array
|
|
243
|
-
catchment (str): The catchment that the gauge is in
|
|
244
|
-
climate file (str) = Which climate data to use
|
|
245
|
-
|
|
246
|
-
Returns:
|
|
247
|
-
np.array: Daily climate categorisation
|
|
248
|
-
|
|
249
|
-
'''
|
|
250
|
-
# Get the climate categorisation:
|
|
251
|
-
climate_cats = get_climate_cats(climate_file)
|
|
252
|
-
|
|
253
|
-
# Get the unique years covered in the flow dataframe, and how many days are in each year:
|
|
254
|
-
unique_years, count_years = np.unique(water_years, return_counts=True)
|
|
255
|
-
|
|
256
|
-
# Get the years covered by the climate cats, and filter them to those of interest (using min and max from flow dataframe)
|
|
257
|
-
climateCatchment = climate_cats[catchment]
|
|
258
|
-
climateFiltered = climateCatchment[(climateCatchment.index>=min(unique_years)) & (climateCatchment.index<=max(unique_years))].values
|
|
259
|
-
# Repeating the climate result for that year over the total days in each year
|
|
260
|
-
def mapper(climate, count):
|
|
261
|
-
return np.repeat(climate, count)
|
|
262
|
-
|
|
263
|
-
climateDailyYear = list(map(mapper, climateFiltered, count_years))
|
|
264
|
-
climateDaily = np.concatenate(climateDailyYear)
|
|
265
|
-
|
|
266
|
-
return climateDaily
|
|
267
|
-
|
|
268
141
|
def get_level_gauges() -> tuple:
|
|
269
142
|
'''Returning level gauges with EWRs
|
|
270
143
|
|
|
@@ -277,7 +150,7 @@ def get_level_gauges() -> tuple:
|
|
|
277
150
|
|
|
278
151
|
lachlanGauges = ['412107']
|
|
279
152
|
|
|
280
|
-
levelGauges = menindeeGauges + lachlanGauges
|
|
153
|
+
levelGauges = menindeeGauges + lachlanGauges
|
|
281
154
|
|
|
282
155
|
weirpoolGauges = {'414203': '414209',
|
|
283
156
|
'425010': 'A4260501',
|
|
@@ -313,74 +186,6 @@ def get_multi_gauges(dataType: str) -> dict:
|
|
|
313
186
|
|
|
314
187
|
return returnData
|
|
315
188
|
|
|
316
|
-
def get_simultaneous_gauges(dataType: str) -> dict:
|
|
317
|
-
'''
|
|
318
|
-
Call function to return a dictionary of simultaneous gauges.
|
|
319
|
-
Simultaneous gauges are for EWRs that need to be met simultaneously with EWRs at another location
|
|
320
|
-
|
|
321
|
-
Args:
|
|
322
|
-
dataType (str): Pass 'all' to get simultaneous gauges and their planning units, pass 'gauges' to get only gauges.
|
|
323
|
-
Returns:
|
|
324
|
-
dict: if 'all', nested dict returned with a level for planning units.
|
|
325
|
-
|
|
326
|
-
'''
|
|
327
|
-
|
|
328
|
-
all = {'PU_0000131': {'421090': '421022', '421022': '421090'},
|
|
329
|
-
'PU_0000132': {'421090': '421022', '421022': '421090'},
|
|
330
|
-
'PU_0000133': {'421090': '421022', '421022': '421090'}
|
|
331
|
-
}
|
|
332
|
-
returnData = {}
|
|
333
|
-
if dataType == 'all':
|
|
334
|
-
returnData = all
|
|
335
|
-
if dataType == 'gauges':
|
|
336
|
-
for i in all:
|
|
337
|
-
returnData = {**returnData, **all[i]}
|
|
338
|
-
|
|
339
|
-
return returnData
|
|
340
|
-
|
|
341
|
-
def get_complex_calcs() -> dict:
|
|
342
|
-
'''
|
|
343
|
-
Returns a dictionary of the complex EWRs, and the type of analysis that needs to be undertaken
|
|
344
|
-
These EWRs cannot be calculated using the standard suite of functions
|
|
345
|
-
|
|
346
|
-
Returns:
|
|
347
|
-
dict[dict]
|
|
348
|
-
'''
|
|
349
|
-
complexCalcs = {'409025': {'OB2_S': 'flowDurPostReq', 'OB2_P': 'flowDurPostReq',
|
|
350
|
-
'OB3_S': 'flowDurOutsideReq', 'OB3_P': 'flowDurOutsideReq'}}
|
|
351
|
-
|
|
352
|
-
return complexCalcs
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
def get_gauges(category: str) -> set:
|
|
356
|
-
'''
|
|
357
|
-
Gathers a list of either all gauges that have EWRs associated with them,
|
|
358
|
-
a list of all flow type gauges that have EWRs associated with them,
|
|
359
|
-
or a list of all level type gauges that have EWRs associated with them
|
|
360
|
-
|
|
361
|
-
Args:
|
|
362
|
-
category(str): options = 'all gauges', 'flow gauges', or 'level gauges'
|
|
363
|
-
Returns:
|
|
364
|
-
list: list of gauges in selected category.
|
|
365
|
-
|
|
366
|
-
'''
|
|
367
|
-
EWR_table, bad_EWRs = get_EWR_table()
|
|
368
|
-
menindee_gauges, wp_gauges = get_level_gauges()
|
|
369
|
-
wp_gauges = list(wp_gauges.values())
|
|
370
|
-
|
|
371
|
-
multi_gauges = get_multi_gauges('gauges')
|
|
372
|
-
simul_gauges = get_simultaneous_gauges('gauges')
|
|
373
|
-
multi_gauges = list(multi_gauges.values())
|
|
374
|
-
simul_gauges = list(simul_gauges.values())
|
|
375
|
-
if category == 'all gauges':
|
|
376
|
-
return set(EWR_table['Gauge'].to_list() + menindee_gauges + wp_gauges + multi_gauges + simul_gauges)
|
|
377
|
-
elif category == 'flow gauges':
|
|
378
|
-
return set(EWR_table['Gauge'].to_list() + multi_gauges + simul_gauges)
|
|
379
|
-
elif category == 'level gauges':
|
|
380
|
-
return set(menindee_gauges + wp_gauges)
|
|
381
|
-
else:
|
|
382
|
-
raise ValueError('''No gauge category sent to the "get_gauges" function''')
|
|
383
|
-
|
|
384
189
|
def get_EWR_components(category):
|
|
385
190
|
'''
|
|
386
191
|
Ingests EWR category, returns the components required to analyse this type of EWR.
|
|
@@ -398,13 +203,19 @@ def get_EWR_components(category):
|
|
|
398
203
|
if category == 'flow':
|
|
399
204
|
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'GP', 'EPY', 'MIE', 'FLV']
|
|
400
205
|
elif category == 'low flow':
|
|
401
|
-
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', '
|
|
206
|
+
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', 'MIE', 'FLV']
|
|
402
207
|
elif category == 'cease to flow':
|
|
403
|
-
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', '
|
|
208
|
+
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', 'MIE', 'FLV']
|
|
404
209
|
elif category == 'cumulative':
|
|
405
210
|
pull = ['SM', 'EM', 'MINV', 'DUR', 'ME', 'EPY', 'MINF', 'MAXF', 'MIE','AP','GP', 'FLV']
|
|
211
|
+
elif category == 'cumulative_bbr':
|
|
212
|
+
pull = ['SM', 'EM', 'MINV', 'DUR', 'ME', 'EPY', 'MINF', 'MAXF', 'MIE','AP','GP', 'FLV','MAXL','WPG']
|
|
213
|
+
elif category == 'water_stability':
|
|
214
|
+
pull = ['SM', 'EM', 'DUR', 'ME', 'EPY', 'MINF', 'MAXF', 'MIE','AP','GP', 'FLV','MAXL','WPG', 'EDS', 'LDS', 'ML', 'MD']
|
|
215
|
+
elif category == 'water_stability_level':
|
|
216
|
+
pull = ['SM', 'EM', 'DUR', 'ME', 'EPY', 'MINF', 'MIE','AP','GP', 'FLV','MAXL', 'MINL', 'WPG', 'EDS', 'LDS', 'ML', 'MD']
|
|
406
217
|
elif category == 'level':
|
|
407
|
-
pull = ['SM', 'EM', 'MINL', 'MAXL', 'DUR', 'ME', 'EPY', 'MD', 'MIE', 'FLV', 'MAXD','GP']
|
|
218
|
+
pull = ['SM', 'EM', 'MINL', 'MAXL', 'DUR', 'ME', 'EPY', 'MD', 'MIE', 'FLV', 'MAXD','GP','MLR']
|
|
408
219
|
elif category == 'weirpool-raising':
|
|
409
220
|
pull=['SM', 'EM', 'MINF', 'MAXF', 'MINL', 'DUR', 'ME', 'MD', 'EPY','WPG', 'MIE', 'FLV', 'GP']
|
|
410
221
|
elif category == 'weirpool-falling':
|
|
@@ -416,19 +227,21 @@ def get_EWR_components(category):
|
|
|
416
227
|
elif category == 'multi-gauge-flow':
|
|
417
228
|
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'GP', 'EPY', 'MG', 'MIE', 'FLV']
|
|
418
229
|
elif category == 'multi-gauge-low flow':
|
|
419
|
-
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', '
|
|
230
|
+
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', 'MG', 'MIE', 'FLV']
|
|
420
231
|
elif category == 'multi-gauge-cease to flow':
|
|
421
|
-
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', '
|
|
232
|
+
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', 'MG', 'MIE', 'FLV']
|
|
422
233
|
elif category == 'multi-gauge-cumulative':
|
|
423
234
|
pull = ['SM', 'EM', 'MINV', 'DUR', 'ME', 'EPY', 'MINF', 'MAXF','MG', 'MIE','AP','GP', 'FLV']
|
|
424
|
-
elif category == '
|
|
425
|
-
pull
|
|
426
|
-
elif category == '
|
|
427
|
-
pull
|
|
428
|
-
elif category == '
|
|
429
|
-
pull
|
|
430
|
-
elif category == '
|
|
431
|
-
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME',
|
|
235
|
+
elif category == 'flood-plains':
|
|
236
|
+
pull=['SM', 'EM', 'MINF', 'MAXF', 'MAXL', 'DUR', 'ME', 'MD', 'ML','EPY','WPG', 'MIE', 'FLV', 'GP']
|
|
237
|
+
elif category == 'barrage-flow':
|
|
238
|
+
pull=['SM', 'EM','DUR', 'ME','EPY','MIE','FLV','ABF','TYBF','HRWS', 'HRWE', 'LRWS', 'LRWE']
|
|
239
|
+
elif category == 'barrage-level':
|
|
240
|
+
pull=['SM', 'EM','DUR', 'ME','EPY','MIE','FLV','HRWS', 'HRWE', 'LRWS', 'LRWE','PLWS', 'PLWE', 'LLWS', 'LLWE','MINL','MAXL']
|
|
241
|
+
elif category == 'flow-ctf':
|
|
242
|
+
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'GP', 'EPY', 'MIE', 'FLV', 'NFS', 'CTFT']
|
|
243
|
+
elif category == 'rise_fall':
|
|
244
|
+
pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'GP', 'EPY', 'MIE', 'FLV', 'NFS', 'MLR', 'RRM1', 'RRM2', 'RFM', 'RRT1', 'RRT2', 'RRL', 'RFL' ]
|
|
432
245
|
return pull
|
|
433
246
|
|
|
434
247
|
def get_bad_QA_codes() -> list:
|
|
@@ -484,8 +297,109 @@ def ewr_parameter_grabber(EWR_TABLE: pd.DataFrame, GAUGE: str, PU: str, EWR: str
|
|
|
484
297
|
str: requested EWR component
|
|
485
298
|
|
|
486
299
|
'''
|
|
487
|
-
component =
|
|
300
|
+
component = (EWR_TABLE[((EWR_TABLE['Gauge'] == GAUGE) &
|
|
488
301
|
(EWR_TABLE['Code'] == EWR) &
|
|
489
302
|
(EWR_TABLE['PlanningUnitName'] == PU)
|
|
490
|
-
)][PARAMETER])[0]
|
|
491
|
-
return component if component else 0
|
|
303
|
+
)][PARAMETER]).to_list()[0]
|
|
304
|
+
return component if component else 0
|
|
305
|
+
|
|
306
|
+
def get_barrage_flow_gauges()-> dict:
|
|
307
|
+
"""Returns a dictionary of the flow gauges associated with each barrage.
|
|
308
|
+
Results:
|
|
309
|
+
dict: dictionary of flow gauges associated with each barrage.
|
|
310
|
+
"""
|
|
311
|
+
|
|
312
|
+
flow_barrage_gauges = {'A4261002': ['A4261002']}
|
|
313
|
+
|
|
314
|
+
return flow_barrage_gauges
|
|
315
|
+
|
|
316
|
+
def get_barrage_level_gauges()-> dict:
|
|
317
|
+
"""Returns a dictionary of the level gauges associated with each barrage.
|
|
318
|
+
Results:
|
|
319
|
+
dict: dictionary of level gauges associated with each barrage.
|
|
320
|
+
"""
|
|
321
|
+
|
|
322
|
+
level_barrage_gauges = {'A4260527': ['A4260527','A4261133', 'A4260524', 'A4260574', 'A4260575' ],
|
|
323
|
+
'A4260633' : ['A4260633','A4261209', 'A4261165']}
|
|
324
|
+
|
|
325
|
+
return level_barrage_gauges
|
|
326
|
+
|
|
327
|
+
def get_qld_level_gauges()-> list:
|
|
328
|
+
"""Returns a dictionary of the level gauges associated with each barrage.
|
|
329
|
+
Results:
|
|
330
|
+
dict: dictionary of level gauges associated with each barrage.
|
|
331
|
+
"""
|
|
332
|
+
return ['422015','422030', '422034', '416011', '416048']
|
|
333
|
+
|
|
334
|
+
def get_qld_flow_gauges()-> list:
|
|
335
|
+
"""Returns a dictionary of the flow gauges associated with each barrage.
|
|
336
|
+
Results:
|
|
337
|
+
dict: dictionary of flow gauges associated with each barrage.
|
|
338
|
+
"""
|
|
339
|
+
return ['422030','422207A',
|
|
340
|
+
'422209A',
|
|
341
|
+
'422211A',
|
|
342
|
+
'422502A',
|
|
343
|
+
'424201A',
|
|
344
|
+
'422034' ]
|
|
345
|
+
|
|
346
|
+
def get_vic_level_gauges()-> list:
|
|
347
|
+
"""Returns a list of the level gauges for VIC.
|
|
348
|
+
Results:
|
|
349
|
+
dict: dictionary of flow gauges associated with each barrage.
|
|
350
|
+
"""
|
|
351
|
+
return ['405201', '405202', '405200']
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def get_cllmm_gauges()->list:
|
|
355
|
+
return ["A4261002", "A4260527", "A4260633"]
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def get_gauges(category: str, ewr_table_path: str = None) -> set:
|
|
359
|
+
'''
|
|
360
|
+
Gathers a list of either all gauges that have EWRs associated with them,
|
|
361
|
+
a list of all flow type gauges that have EWRs associated with them,
|
|
362
|
+
or a list of all level type gauges that have EWRs associated with them
|
|
363
|
+
|
|
364
|
+
Args:
|
|
365
|
+
category(str): options = 'all gauges', 'flow gauges', or 'level gauges'
|
|
366
|
+
Returns:
|
|
367
|
+
list: list of gauges in selected category.
|
|
368
|
+
|
|
369
|
+
'''
|
|
370
|
+
EWR_table, bad_EWRs = get_EWR_table(file_path=ewr_table_path)
|
|
371
|
+
menindee_gauges, wp_gauges = get_level_gauges()
|
|
372
|
+
wp_gauges = list(wp_gauges.values())
|
|
373
|
+
flow_barrage_gauges = [ val for sublist in get_barrage_flow_gauges().values() for val in sublist]
|
|
374
|
+
level_barrage_gauges = [ val for sublist in get_barrage_level_gauges().values() for val in sublist]
|
|
375
|
+
qld_level_gauges = get_qld_level_gauges()
|
|
376
|
+
qld_flow_gauges = get_qld_flow_gauges()
|
|
377
|
+
vic_level_gauges = get_vic_level_gauges()
|
|
378
|
+
|
|
379
|
+
multi_gauges = get_multi_gauges('gauges')
|
|
380
|
+
multi_gauges = list(multi_gauges.values())
|
|
381
|
+
if category == 'all gauges':
|
|
382
|
+
return set(EWR_table['Gauge'].to_list() + menindee_gauges + wp_gauges + multi_gauges)
|
|
383
|
+
elif category == 'flow gauges':
|
|
384
|
+
return set(EWR_table['Gauge'].to_list() + multi_gauges + flow_barrage_gauges + qld_flow_gauges)
|
|
385
|
+
elif category == 'level gauges':
|
|
386
|
+
level_gauges = EWR_table[EWR_table['FlowLevelVolume']=='L']['Gauge'].to_list()
|
|
387
|
+
return set(menindee_gauges + wp_gauges + level_barrage_gauges + qld_level_gauges + level_gauges)
|
|
388
|
+
else:
|
|
389
|
+
raise ValueError('''No gauge category sent to the "get_gauges" function''')
|
|
390
|
+
|
|
391
|
+
def get_scenario_gauges(gauge_results: dict) -> list:
|
|
392
|
+
"""return a list of gauges process for the scenatios(s)
|
|
393
|
+
|
|
394
|
+
Args:
|
|
395
|
+
gauge_results (dict): the dictionary of gauge results either for
|
|
396
|
+
observed or scenarios handlers
|
|
397
|
+
|
|
398
|
+
Returns:
|
|
399
|
+
list: list of gauges process for the scenatios(s)
|
|
400
|
+
"""
|
|
401
|
+
scenario_gauges = []
|
|
402
|
+
for scenario in gauge_results.values():
|
|
403
|
+
for gauge in scenario.keys():
|
|
404
|
+
scenario_gauges.append(gauge)
|
|
405
|
+
return list(set(scenario_gauges))
|