py-ewr 2.3.0__tar.gz → 2.3.2__tar.gz

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.
Files changed (33) hide show
  1. {py_ewr-2.3.0 → py_ewr-2.3.2}/PKG-INFO +4 -2
  2. {py_ewr-2.3.0 → py_ewr-2.3.2}/README.md +3 -1
  3. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/data_inputs.py +2 -2
  4. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/evaluate_EWRs.py +23 -19
  5. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/model_metadata/SiteID_MDBA.csv +3 -0
  6. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/observed_handling.py +12 -12
  7. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/parameter_metadata/ewr2obj.csv +36799 -39096
  8. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/parameter_metadata/obj2target.csv +7941 -7973
  9. py_ewr-2.3.2/py_ewr/parameter_metadata/obj2yrtarget.csv +106 -0
  10. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/parameter_metadata/parameter_sheet.csv +2295 -2301
  11. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/scenario_handling.py +12 -12
  12. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/summarise_results.py +7 -5
  13. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr.egg-info/PKG-INFO +4 -2
  14. {py_ewr-2.3.0 → py_ewr-2.3.2}/setup.py +1 -1
  15. {py_ewr-2.3.0 → py_ewr-2.3.2}/tests/test_observed_handling.py +6 -6
  16. {py_ewr-2.3.0 → py_ewr-2.3.2}/tests/test_scenario_handling.py +13 -13
  17. {py_ewr-2.3.0 → py_ewr-2.3.2}/tests/test_summarise_results.py +2 -0
  18. py_ewr-2.3.0/py_ewr/parameter_metadata/obj2yrtarget.csv +0 -106
  19. {py_ewr-2.3.0 → py_ewr-2.3.2}/LICENSE +0 -0
  20. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/__init__.py +0 -0
  21. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/io.py +0 -0
  22. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/model_metadata/SiteID_NSW.csv +0 -0
  23. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/model_metadata/iqqm_stations.csv +0 -0
  24. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr/parameter_metadata/ewr_calc_config.json +0 -0
  25. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr.egg-info/SOURCES.txt +0 -0
  26. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr.egg-info/dependency_links.txt +0 -0
  27. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr.egg-info/requires.txt +0 -0
  28. {py_ewr-2.3.0 → py_ewr-2.3.2}/py_ewr.egg-info/top_level.txt +0 -0
  29. {py_ewr-2.3.0 → py_ewr-2.3.2}/pyproject.toml +0 -0
  30. {py_ewr-2.3.0 → py_ewr-2.3.2}/setup.cfg +0 -0
  31. {py_ewr-2.3.0 → py_ewr-2.3.2}/tests/test_data_inputs.py +0 -0
  32. {py_ewr-2.3.0 → py_ewr-2.3.2}/tests/test_evaluate_ewr_rest.py +0 -0
  33. {py_ewr-2.3.0 → py_ewr-2.3.2}/tests/test_evaluate_ewrs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py_ewr
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: Environmental Water Requirement calculator
5
5
  Home-page: https://github.com/MDBAuth/EWR_tool
6
6
  Author: Martin Job
@@ -34,9 +34,10 @@ Requires-Dist: numpy<2
34
34
  [![PyPI](https://img.shields.io/pypi/v/py-ewr)](https://pypi.org/project/py-ewr/)
35
35
  [![DOI](https://zenodo.org/badge/342122359.svg)](https://zenodo.org/badge/latestdoi/342122359)
36
36
 
37
- ### **EWR tool version 2.3.0 README**
37
+ ### **EWR tool version 2.3.2 README**
38
38
 
39
39
  ### **Notes on recent version updates**
40
+ - CLLMM_c and CLLMM_d ewrs are now able to be calculated without all barrage level gauges being present in the model file.
40
41
  - Including draft objective mapping files in the package (see below sub heading **Objective mapping** for more information). Objective mapping has been therefore pulled out of the parameter sheet
41
42
  - Including an example parallel processing script for running the EWR tool
42
43
  - Adding handling for cases where there are single MDBA bigmod site IDs mapping to multiple different gauges
@@ -48,6 +49,7 @@ Requires-Dist: numpy<2
48
49
  - Standard time-series handling added - each column needs a gauge, followed by and underscore, followed by either flow or level (e.g. 409025_flow). This handling also has missing date filling - so any missing dates will be filled with NaN values in all columns.
49
50
  - bug fixes: spells of length equal to the minimum required spell length were getting filtered out of the successful events table and successful interevents table, fixed misclassification of some gauges to flow, level, and lake level categories
50
51
  - New EWRs: New Qld EWRs - SF_FD and BF_FD used to look into the FD EWRs in closer detail.
52
+ - Adding state and Surface Water SDL (SWSDL) to py-ewr output tables
51
53
 
52
54
  ### **Installation**
53
55
 
@@ -3,9 +3,10 @@
3
3
  [![PyPI](https://img.shields.io/pypi/v/py-ewr)](https://pypi.org/project/py-ewr/)
4
4
  [![DOI](https://zenodo.org/badge/342122359.svg)](https://zenodo.org/badge/latestdoi/342122359)
5
5
 
6
- ### **EWR tool version 2.3.0 README**
6
+ ### **EWR tool version 2.3.2 README**
7
7
 
8
8
  ### **Notes on recent version updates**
9
+ - CLLMM_c and CLLMM_d ewrs are now able to be calculated without all barrage level gauges being present in the model file.
9
10
  - Including draft objective mapping files in the package (see below sub heading **Objective mapping** for more information). Objective mapping has been therefore pulled out of the parameter sheet
10
11
  - Including an example parallel processing script for running the EWR tool
11
12
  - Adding handling for cases where there are single MDBA bigmod site IDs mapping to multiple different gauges
@@ -17,6 +18,7 @@
17
18
  - Standard time-series handling added - each column needs a gauge, followed by and underscore, followed by either flow or level (e.g. 409025_flow). This handling also has missing date filling - so any missing dates will be filled with NaN values in all columns.
18
19
  - bug fixes: spells of length equal to the minimum required spell length were getting filtered out of the successful events table and successful interevents table, fixed misclassification of some gauges to flow, level, and lake level categories
19
20
  - New EWRs: New Qld EWRs - SF_FD and BF_FD used to look into the FD EWRs in closer detail.
21
+ - Adding state and Surface Water SDL (SWSDL) to py-ewr output tables
20
22
 
21
23
  ### **Installation**
22
24
 
@@ -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',
@@ -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 = all(gauge in df_L.columns for gauge in all_required_gauges)
1155
- # check if current gauge is the main barrage gauge
1156
- if all_required_gauges_in_df_L:
1157
- pull = data_inputs.get_EWR_components('barrage-level')
1158
- EWR_info = get_EWRs(PU, gauge, EWR, EWR_table, pull)
1159
- masked_dates = mask_dates(EWR_info, df_L)
1160
- # Extract a daily timeseries for water years:
1161
- water_years = wateryear_daily(df_L, EWR_info)
1162
- # If there is no level data loaded in, let user know and skip the analysis
1163
- df = df_L.copy(deep=True)
1164
- # calculate 5 day moving average and average of all required gauges
1165
- df_5_day_averages = calculate_n_day_moving_average(df,5)
1166
- df_5_day_averages['mean'] = df[all_required_gauges].mean(axis=1)
1167
- cllmm_type = what_cllmm_type(EWR_info)
1168
- if cllmm_type == 'c':
1169
- E, D = lower_lakes_level_calc(EWR_info, df_5_day_averages['mean'], water_years, df_L.index, masked_dates)
1170
- if cllmm_type == 'd':
1171
- E, D = coorong_level_calc(EWR_info, df_5_day_averages['mean'], water_years, df_L.index, masked_dates)
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
@@ -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'],