py-ewr 2.3.0__py3-none-any.whl → 2.3.2__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 +2 -2
- py_ewr/evaluate_EWRs.py +23 -19
- py_ewr/model_metadata/SiteID_MDBA.csv +3 -0
- py_ewr/observed_handling.py +12 -12
- py_ewr/parameter_metadata/ewr2obj.csv +36799 -39096
- py_ewr/parameter_metadata/obj2target.csv +7941 -7973
- py_ewr/parameter_metadata/obj2yrtarget.csv +106 -106
- py_ewr/parameter_metadata/parameter_sheet.csv +2295 -2301
- py_ewr/scenario_handling.py +12 -12
- py_ewr/summarise_results.py +7 -5
- {py_ewr-2.3.0.dist-info → py_ewr-2.3.2.dist-info}/METADATA +4 -2
- py_ewr-2.3.2.dist-info/RECORD +20 -0
- py_ewr-2.3.0.dist-info/RECORD +0 -20
- {py_ewr-2.3.0.dist-info → py_ewr-2.3.2.dist-info}/LICENSE +0 -0
- {py_ewr-2.3.0.dist-info → py_ewr-2.3.2.dist-info}/WHEEL +0 -0
- {py_ewr-2.3.0.dist-info → py_ewr-2.3.2.dist-info}/top_level.txt +0 -0
py_ewr/data_inputs.py
CHANGED
|
@@ -50,7 +50,7 @@ def get_EWR_table(file_path:str = None) -> dict:
|
|
|
50
50
|
|
|
51
51
|
if file_path:
|
|
52
52
|
df = pd.read_csv(file_path,
|
|
53
|
-
usecols=['PlanningUnitID', 'PlanningUnitName', 'LTWPShortName', 'CompliancePoint/Node', 'Gauge', 'Code', 'StartMonth',
|
|
53
|
+
usecols=['PlanningUnitID', 'PlanningUnitName', 'LTWPShortName', 'SWSDLName', 'State', 'CompliancePoint/Node', 'Gauge', 'Code', 'StartMonth',
|
|
54
54
|
'EndMonth', 'TargetFrequency', 'TargetFrequencyMin', 'TargetFrequencyMax', 'EventsPerYear', 'Duration', 'MinSpell',
|
|
55
55
|
'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event', 'WithinEventGapTolerance', 'WeirpoolGauge', 'FlowLevelVolume',
|
|
56
56
|
'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'MaxLevelRise','AccumulationPeriod',
|
|
@@ -66,7 +66,7 @@ def get_EWR_table(file_path:str = None) -> dict:
|
|
|
66
66
|
my_url = os.path.join(BASE_PATH, "parameter_metadata/parameter_sheet.csv")
|
|
67
67
|
proxies={} # Populate with your proxy settings
|
|
68
68
|
df = pd.read_csv(my_url,
|
|
69
|
-
usecols=['PlanningUnitID', 'PlanningUnitName', 'LTWPShortName', 'CompliancePoint/Node', 'Gauge', 'Code', 'StartMonth',
|
|
69
|
+
usecols=['PlanningUnitID', 'PlanningUnitName', 'LTWPShortName', 'SWSDLName', 'State', 'CompliancePoint/Node', 'Gauge', 'Code', 'StartMonth',
|
|
70
70
|
'EndMonth', 'TargetFrequency', 'TargetFrequencyMin', 'TargetFrequencyMax', 'EventsPerYear', 'Duration', 'MinSpell',
|
|
71
71
|
'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event', 'WithinEventGapTolerance', 'WeirpoolGauge', 'FlowLevelVolume',
|
|
72
72
|
'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'MaxLevelRise', 'AccumulationPeriod',
|
py_ewr/evaluate_EWRs.py
CHANGED
|
@@ -1148,33 +1148,37 @@ def barrage_level_handle(PU: str, gauge: str, EWR: str, EWR_table: pd.DataFrame,
|
|
|
1148
1148
|
Returns:
|
|
1149
1149
|
tuple[pd.DataFrame, tuple[dict]]: EWR results for the current planning unit iteration (updated); dictionary of EWR event information
|
|
1150
1150
|
"""
|
|
1151
|
+
print(df_L.head())
|
|
1151
1152
|
barrage_level_gauges = data_inputs.get_barrage_level_gauges()
|
|
1152
1153
|
all_required_gauges = barrage_level_gauges.get(gauge)
|
|
1154
|
+
# if all_required_gauges:
|
|
1155
|
+
# all_required_gauges_in_df_L = all(gauge in df_L.columns for gauge in all_required_gauges)
|
|
1153
1156
|
if all_required_gauges:
|
|
1154
|
-
all_required_gauges_in_df_L =
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1157
|
+
all_required_gauges_in_df_L = [gauge for gauge in all_required_gauges if gauge in df_L.columns]
|
|
1158
|
+
#NOTE as all_required_gauges_in_df_L is boolean, the indexing is stil including all gauges in all_required_gauges.
|
|
1159
|
+
# directly subset and use all_required_gauges_in_df_L as the new list.
|
|
1160
|
+
if all_required_gauges_in_df_L:
|
|
1161
|
+
pull = data_inputs.get_EWR_components('barrage-level')
|
|
1162
|
+
EWR_info = get_EWRs(PU, gauge, EWR, EWR_table, pull)
|
|
1163
|
+
masked_dates = mask_dates(EWR_info, df_L)
|
|
1164
|
+
# Extract a daily timeseries for water years:
|
|
1165
|
+
water_years = wateryear_daily(df_L, EWR_info)
|
|
1166
|
+
# If there is no level data loaded in, let user know and skip the analysis
|
|
1167
|
+
df = df_L.copy(deep=True)
|
|
1168
|
+
# calculate 5 day moving average and average of all required gauges
|
|
1169
|
+
df_5_day_averages = calculate_n_day_moving_average(df,5)
|
|
1170
|
+
df_5_day_averages['mean'] = df[all_required_gauges_in_df_L].mean(axis=1)
|
|
1171
|
+
cllmm_type = what_cllmm_type(EWR_info)
|
|
1172
|
+
if cllmm_type == 'c':
|
|
1173
|
+
E, D = lower_lakes_level_calc(EWR_info, df_5_day_averages['mean'], water_years, df_L.index, masked_dates)
|
|
1174
|
+
if cllmm_type == 'd':
|
|
1175
|
+
E, D = coorong_level_calc(EWR_info, df_5_day_averages['mean'], water_years, df_L.index, masked_dates)
|
|
1172
1176
|
|
|
1173
1177
|
PU_df = event_stats(df_L, PU_df, gauge, EWR, EWR_info, E, D, water_years)
|
|
1174
1178
|
return PU_df, tuple([E])
|
|
1175
1179
|
|
|
1176
1180
|
else:
|
|
1177
|
-
print(f'skipping calculation because gauge {" ".join(all_required_gauges)} is not the main barrage level gauge ')
|
|
1181
|
+
print(f'skipping calculation because gauge {" ".join(all_required_gauges)} is not the main barrage level gauge ') #TODO: improve error message
|
|
1178
1182
|
return PU_df, None
|
|
1179
1183
|
|
|
1180
1184
|
def rise_and_fall_handle(PU: str, gauge: str, EWR: str, EWR_table: pd.DataFrame, df_F: pd.DataFrame, df_L: pd.DataFrame, PU_df: pd.DataFrame) -> tuple:
|
|
@@ -1347,6 +1347,7 @@ LOCK7US,River Murray U/S Lock 7,,426508,5
|
|
|
1347
1347
|
LOCK7US,River Murray U/S Lock 7,,A4260508,5
|
|
1348
1348
|
LOCK8DS,River Murray D/S Lock 8,,4260507,5
|
|
1349
1349
|
LOCK8US,River Murray U/S Lock 8,,426506,5
|
|
1350
|
+
LOCK8US,River Murray U/S Lock 8,,A426506,5
|
|
1350
1351
|
LOCK9DS,River Murray D/S Lock 9,,4260505,5
|
|
1351
1352
|
LOCK 9 ,River Murray U/S Lock 9,SAMPLE AT GAUGING STATION,A4260501,5
|
|
1352
1353
|
LOCK9US,River Murray U/S Lock 9,SAMPLE AT GAUGING STATION,A4260501,5
|
|
@@ -2689,6 +2690,7 @@ FLOWSA ,A4261001,Flow at South Australia border,A4261001,5
|
|
|
2689
2690
|
BARRAGE,A4261002,Barrages near the Murray Mouth,A4261002,5
|
|
2690
2691
|
Bills Pipe,Bills Pipe,North Redbank,Bills Pipe,2
|
|
2691
2692
|
"Eulimbah, Nimmie Creek","Eulimbah, Nimmie Creek","Gayini/ Nimmie-Caira, combined Eulimbah and Nimmie Creek regulators","Eulimbah, Nimmie Creek",2
|
|
2693
|
+
Eulimbah_Nimmie Creek,"Eulimbah, Nimmie Creek","Gayini/ Nimmie-Caira, combined Eulimbah and Nimmie Creek regulators","Eulimbah, Nimmie Creek",2
|
|
2692
2694
|
Glen Dee,Glen Dee,"Western Lakes, Glenn Dee",Glen Dee,2
|
|
2693
2695
|
Pattos Pipe,Pattos Pipe,North Redbank,Pattos Pipe,2
|
|
2694
2696
|
Pump direct from river,Pump direct from river,"North Redbank, pumped direct from river",Pump direct from river,2
|
|
@@ -2698,3 +2700,4 @@ Pumped from Yanga Lake,Pumped from Yanga Lake,Yanga (South Redbank),Pumped from
|
|
|
2698
2700
|
410700,Cotter River at Kiosk,ACT - Icon Water Limited,410700,3
|
|
2699
2701
|
410747,Cotter River below Bendora Dam,ACT - Icon Water Limited,410747,3
|
|
2700
2702
|
410752,Cotter River below Corin Dam,ACT - Icon Water Limited,410752,3
|
|
2703
|
+
8MAREBON,Marebone Break @ d/s Marebone Regulator,Marebone Break @ d/s Marebone Regulator,421088,2
|
py_ewr/observed_handling.py
CHANGED
|
@@ -226,10 +226,10 @@ class ObservedHandler:
|
|
|
226
226
|
events_to_process = summarise_results.get_events_to_process(self.yearly_events)
|
|
227
227
|
all_events = summarise_results.process_all_events_results(events_to_process)
|
|
228
228
|
|
|
229
|
-
all_events = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge'],
|
|
229
|
+
all_events = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge', 'State', 'SWSDLName'],
|
|
230
230
|
left_table=all_events,
|
|
231
231
|
left_on=['gauge','pu','ewr'],
|
|
232
|
-
selected_columns= ['scenario', 'gauge', 'pu', 'ewr', 'waterYear', 'startDate', 'endDate',
|
|
232
|
+
selected_columns= ['scenario', 'gauge', 'pu', 'State', 'SWSDLName', 'ewr', 'waterYear', 'startDate', 'endDate',
|
|
233
233
|
'eventDuration', 'eventLength',
|
|
234
234
|
'Multigauge'],
|
|
235
235
|
parameter_sheet_path=self.parameter_sheet)
|
|
@@ -246,10 +246,10 @@ class ObservedHandler:
|
|
|
246
246
|
events_to_process = summarise_results.get_events_to_process(self.yearly_events)
|
|
247
247
|
all_events_temp = summarise_results.process_all_events_results(events_to_process)
|
|
248
248
|
|
|
249
|
-
all_events_temp = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge'],
|
|
249
|
+
all_events_temp = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge', 'State', 'SWSDLName'],
|
|
250
250
|
left_table=all_events_temp,
|
|
251
251
|
left_on=['gauge','pu','ewr'],
|
|
252
|
-
selected_columns= ['scenario', 'gauge', 'pu', 'ewr', 'waterYear', 'startDate', 'endDate',
|
|
252
|
+
selected_columns= ['scenario', 'gauge', 'pu', 'State', 'SWSDLName', 'ewr', 'waterYear', 'startDate', 'endDate',
|
|
253
253
|
'eventDuration', 'eventLength',
|
|
254
254
|
'Multigauge'],
|
|
255
255
|
parameter_sheet_path=self.parameter_sheet)
|
|
@@ -274,10 +274,10 @@ class ObservedHandler:
|
|
|
274
274
|
events_to_process = summarise_results.get_events_to_process(self.yearly_events)
|
|
275
275
|
all_events_temp1 = summarise_results.process_all_events_results(events_to_process)
|
|
276
276
|
|
|
277
|
-
all_events_temp1 = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge'],
|
|
277
|
+
all_events_temp1 = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge', 'State', 'SWSDLName'],
|
|
278
278
|
left_table=all_events_temp1,
|
|
279
279
|
left_on=['gauge','pu','ewr'],
|
|
280
|
-
selected_columns= ['scenario', 'gauge', 'pu', 'ewr', 'waterYear', 'startDate', 'endDate',
|
|
280
|
+
selected_columns= ['scenario', 'gauge', 'pu', 'State', 'SWSDLName', 'ewr', 'waterYear', 'startDate', 'endDate',
|
|
281
281
|
'eventDuration', 'eventLength',
|
|
282
282
|
'Multigauge'],
|
|
283
283
|
parameter_sheet_path=self.parameter_sheet)
|
|
@@ -296,10 +296,10 @@ class ObservedHandler:
|
|
|
296
296
|
events_to_process = summarise_results.get_events_to_process(self.yearly_events)
|
|
297
297
|
all_events_temp2 = summarise_results.process_all_events_results(events_to_process)
|
|
298
298
|
|
|
299
|
-
all_events_temp2 = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge'],
|
|
299
|
+
all_events_temp2 = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge', 'State', 'SWSDLName'],
|
|
300
300
|
left_table=all_events_temp2,
|
|
301
301
|
left_on=['gauge','pu','ewr'],
|
|
302
|
-
selected_columns= ['scenario', 'gauge', 'pu', 'ewr', 'waterYear', 'startDate', 'endDate',
|
|
302
|
+
selected_columns= ['scenario', 'gauge', 'pu', 'State', 'SWSDLName', 'ewr', 'waterYear', 'startDate', 'endDate',
|
|
303
303
|
'eventDuration', 'eventLength',
|
|
304
304
|
'Multigauge'],
|
|
305
305
|
parameter_sheet_path=self.parameter_sheet)
|
|
@@ -329,24 +329,24 @@ class ObservedHandler:
|
|
|
329
329
|
to_process = summarise_results.pu_dfs_to_process(self.pu_ewr_statistics)
|
|
330
330
|
yearly_ewr_results = summarise_results.process_df_results(to_process)
|
|
331
331
|
|
|
332
|
-
yearly_ewr_results = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge'],
|
|
332
|
+
yearly_ewr_results = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge', 'State', 'SWSDLName'],
|
|
333
333
|
left_table=yearly_ewr_results,
|
|
334
334
|
left_on=['gauge','pu','ewrCode'],
|
|
335
335
|
selected_columns= ['Year', 'eventYears', 'numAchieved', 'numEvents', 'numEventsAll',
|
|
336
336
|
'eventLength', 'eventLengthAchieved', 'totalEventDays', 'totalEventDaysAchieved',
|
|
337
337
|
'maxEventDays', 'maxRollingEvents', 'maxRollingAchievement',
|
|
338
338
|
'missingDays', 'totalPossibleDays', 'ewrCode',
|
|
339
|
-
'scenario', 'gauge', 'pu', 'Multigauge'],
|
|
339
|
+
'scenario', 'gauge', 'pu', 'State', 'SWSDLName', 'Multigauge'],
|
|
340
340
|
parameter_sheet_path=self.parameter_sheet)
|
|
341
341
|
|
|
342
342
|
# Setting up the dictionary of yearly rolling maximum interevent periods:
|
|
343
343
|
events_to_process = summarise_results.get_events_to_process(self.yearly_events)
|
|
344
344
|
all_events_temp = summarise_results.process_all_events_results(events_to_process)
|
|
345
345
|
|
|
346
|
-
all_events_temp = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge'],
|
|
346
|
+
all_events_temp = summarise_results.join_ewr_parameters(cols_to_add=['Multigauge', 'State', 'SWSDLName'],
|
|
347
347
|
left_table=all_events_temp,
|
|
348
348
|
left_on=['gauge', 'pu', 'ewr'],
|
|
349
|
-
selected_columns=['scenario', 'gauge', 'pu', 'ewr',
|
|
349
|
+
selected_columns=['scenario', 'gauge', 'pu', 'State', 'SWSDLName', 'ewr',
|
|
350
350
|
'waterYear', 'startDate', 'endDate',
|
|
351
351
|
'eventDuration', 'eventLength',
|
|
352
352
|
'Multigauge'],
|