py-ewr 2.2.1__tar.gz → 2.2.3__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.
- {py_ewr-2.2.1 → py_ewr-2.2.3}/PKG-INFO +4 -3
- {py_ewr-2.2.1 → py_ewr-2.2.3}/README.md +3 -1
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/evaluate_EWRs.py +1 -4
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/observed_handling.py +0 -1
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/scenario_handling.py +16 -9
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr.egg-info/PKG-INFO +4 -3
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr.egg-info/requires.txt +0 -1
- {py_ewr-2.2.1 → py_ewr-2.2.3}/setup.py +1 -2
- {py_ewr-2.2.1 → py_ewr-2.2.3}/tests/test_scenario_handling.py +32 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/LICENSE +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/__init__.py +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/data_inputs.py +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/io.py +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/model_metadata/SiteID_MDBA.csv +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/model_metadata/SiteID_NSW.csv +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/model_metadata/iqqm_stations.csv +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/parameter_metadata/ewr_calc_config.json +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/parameter_metadata/parameter_sheet.csv +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr/summarise_results.py +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr.egg-info/SOURCES.txt +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr.egg-info/dependency_links.txt +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/py_ewr.egg-info/top_level.txt +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/pyproject.toml +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/setup.cfg +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/tests/test_data_inputs.py +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/tests/test_evaluate_ewr_rest.py +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/tests/test_evaluate_ewrs.py +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/tests/test_observed_handling.py +0 -0
- {py_ewr-2.2.1 → py_ewr-2.2.3}/tests/test_summarise_results.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: py_ewr
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.3
|
|
4
4
|
Summary: Environmental Water Requirement calculator
|
|
5
5
|
Home-page: https://github.com/MDBAuth/EWR_tool
|
|
6
6
|
Author: Martin Job
|
|
@@ -23,7 +23,6 @@ Requires-Dist: ipython==8.8.0
|
|
|
23
23
|
Requires-Dist: ipywidgets==7.7.0
|
|
24
24
|
Requires-Dist: pandas==2.0.3
|
|
25
25
|
Requires-Dist: requests==2.25.1
|
|
26
|
-
Requires-Dist: tqdm>=4.66.1
|
|
27
26
|
Requires-Dist: mdba-gauge-getter==0.5.1
|
|
28
27
|
Requires-Dist: cachetools==5.2.0
|
|
29
28
|
Requires-Dist: xarray==2023.01.0
|
|
@@ -35,9 +34,11 @@ Requires-Dist: numpy<2
|
|
|
35
34
|
[](https://pypi.org/project/py-ewr/)
|
|
36
35
|
[](https://zenodo.org/badge/latestdoi/342122359)
|
|
37
36
|
|
|
38
|
-
### **EWR tool version 2.2.
|
|
37
|
+
### **EWR tool version 2.2.3 README**
|
|
39
38
|
|
|
40
39
|
### **Notes on recent version update**
|
|
40
|
+
- Remove TQDM loading bars
|
|
41
|
+
- Handle duplicate sites in MDBA siteID file - where a duplicate exists, the first match is used and the rest are skipped over
|
|
41
42
|
- Adding new model format handling - 'IQQM - netcdf'
|
|
42
43
|
- 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.
|
|
43
44
|
- ten thousand year handling - This has been briefly taken offline for this version.
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
[](https://pypi.org/project/py-ewr/)
|
|
4
4
|
[](https://zenodo.org/badge/latestdoi/342122359)
|
|
5
5
|
|
|
6
|
-
### **EWR tool version 2.2.
|
|
6
|
+
### **EWR tool version 2.2.3 README**
|
|
7
7
|
|
|
8
8
|
### **Notes on recent version update**
|
|
9
|
+
- Remove TQDM loading bars
|
|
10
|
+
- Handle duplicate sites in MDBA siteID file - where a duplicate exists, the first match is used and the rest are skipped over
|
|
9
11
|
- Adding new model format handling - 'IQQM - netcdf'
|
|
10
12
|
- 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.
|
|
11
13
|
- ten thousand year handling - This has been briefly taken offline for this version.
|
|
@@ -10,7 +10,6 @@ import logging
|
|
|
10
10
|
|
|
11
11
|
import pandas as pd
|
|
12
12
|
import numpy as np
|
|
13
|
-
from tqdm import tqdm
|
|
14
13
|
|
|
15
14
|
from . import data_inputs
|
|
16
15
|
|
|
@@ -5086,9 +5085,7 @@ def calc_sorter(df_F:pd.DataFrame, df_L:pd.DataFrame, gauge:str, EWR_table:pd.Da
|
|
|
5086
5085
|
EWR_codes = PU_table['Code']
|
|
5087
5086
|
PU_df = pd.DataFrame()
|
|
5088
5087
|
PU_events = {}
|
|
5089
|
-
for i, EWR in enumerate(
|
|
5090
|
-
bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}',
|
|
5091
|
-
desc= str('Evaluating ewrs for '+ gauge))):
|
|
5088
|
+
for i, EWR in enumerate(EWR_codes):
|
|
5092
5089
|
events = {}
|
|
5093
5090
|
|
|
5094
5091
|
MULTIGAUGE = is_multigauge(EWR_table, gauge, EWR, PU)
|
|
@@ -7,7 +7,6 @@ from datetime import datetime, date
|
|
|
7
7
|
import logging
|
|
8
8
|
|
|
9
9
|
import pandas as pd
|
|
10
|
-
from tqdm import tqdm
|
|
11
10
|
import xarray as xr
|
|
12
11
|
import netCDF4
|
|
13
12
|
|
|
@@ -437,6 +436,8 @@ def extract_gauge_from_string(input_string: str) -> str:
|
|
|
437
436
|
gauge = input_string.split('_')[0]
|
|
438
437
|
return gauge
|
|
439
438
|
|
|
439
|
+
|
|
440
|
+
|
|
440
441
|
def match_MDBA_nodes(input_df: pd.DataFrame, model_metadata: pd.DataFrame, ewr_table_path: str) -> tuple:
|
|
441
442
|
'''Checks if the source file columns have EWRs available, returns a flow and level dataframe with only
|
|
442
443
|
the columns with EWRs available. Renames columns to gauges
|
|
@@ -461,11 +462,19 @@ def match_MDBA_nodes(input_df: pd.DataFrame, model_metadata: pd.DataFrame, ewr_t
|
|
|
461
462
|
measure = col_clean.split('-')[1]
|
|
462
463
|
if ((measure in measurands) and (model_metadata['SITEID'] == site).any()):
|
|
463
464
|
subset = model_metadata.query("SITEID==@site")
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
465
|
+
for iset in range(len(subset)):
|
|
466
|
+
gauge = subset["AWRC"].iloc[iset]
|
|
467
|
+
if gauge in flow_gauges and measure == '1':
|
|
468
|
+
df_flow[gauge] = input_df[col]
|
|
469
|
+
if gauge in level_gauges and measure == '35':
|
|
470
|
+
aa=input_df[[col]]
|
|
471
|
+
if (len(aa.columns)>1):
|
|
472
|
+
print('More than one site has been identified, the first site is used')
|
|
473
|
+
print('Site info: ', col)
|
|
474
|
+
df_level[gauge] = aa.iloc[:,0]
|
|
475
|
+
else:
|
|
476
|
+
df_level[gauge] = input_df[col]
|
|
477
|
+
|
|
469
478
|
if df_flow.empty:
|
|
470
479
|
raise ValueError('No relevant gauges and or measurands found in dataset, the EWR tool cannot evaluate this model output file')
|
|
471
480
|
return df_flow, df_level
|
|
@@ -538,9 +547,7 @@ class ScenarioHandler:
|
|
|
538
547
|
# Analyse all scenarios for EWRs
|
|
539
548
|
detailed_results = {}
|
|
540
549
|
detailed_events = {}
|
|
541
|
-
for scenario in
|
|
542
|
-
bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}',
|
|
543
|
-
desc= 'Evaluating scenarios'):
|
|
550
|
+
for scenario in scenarios:
|
|
544
551
|
if self.model_format == 'Bigmod - MDBA':
|
|
545
552
|
|
|
546
553
|
data, header = unpack_model_file(scenarios[scenario], 'Dy', 'Field')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: py_ewr
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.3
|
|
4
4
|
Summary: Environmental Water Requirement calculator
|
|
5
5
|
Home-page: https://github.com/MDBAuth/EWR_tool
|
|
6
6
|
Author: Martin Job
|
|
@@ -23,7 +23,6 @@ Requires-Dist: ipython==8.8.0
|
|
|
23
23
|
Requires-Dist: ipywidgets==7.7.0
|
|
24
24
|
Requires-Dist: pandas==2.0.3
|
|
25
25
|
Requires-Dist: requests==2.25.1
|
|
26
|
-
Requires-Dist: tqdm>=4.66.1
|
|
27
26
|
Requires-Dist: mdba-gauge-getter==0.5.1
|
|
28
27
|
Requires-Dist: cachetools==5.2.0
|
|
29
28
|
Requires-Dist: xarray==2023.01.0
|
|
@@ -35,9 +34,11 @@ Requires-Dist: numpy<2
|
|
|
35
34
|
[](https://pypi.org/project/py-ewr/)
|
|
36
35
|
[](https://zenodo.org/badge/latestdoi/342122359)
|
|
37
36
|
|
|
38
|
-
### **EWR tool version 2.2.
|
|
37
|
+
### **EWR tool version 2.2.3 README**
|
|
39
38
|
|
|
40
39
|
### **Notes on recent version update**
|
|
40
|
+
- Remove TQDM loading bars
|
|
41
|
+
- Handle duplicate sites in MDBA siteID file - where a duplicate exists, the first match is used and the rest are skipped over
|
|
41
42
|
- Adding new model format handling - 'IQQM - netcdf'
|
|
42
43
|
- 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.
|
|
43
44
|
- ten thousand year handling - This has been briefly taken offline for this version.
|
|
@@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="py_ewr",
|
|
9
|
-
version="2.2.
|
|
9
|
+
version="2.2.3",
|
|
10
10
|
author="Martin Job",
|
|
11
11
|
author_email="Martin.Job@mdba.gov.au",
|
|
12
12
|
description="Environmental Water Requirement calculator",
|
|
@@ -35,7 +35,6 @@ setup(
|
|
|
35
35
|
"ipywidgets==7.7.0",
|
|
36
36
|
"pandas==2.0.3",
|
|
37
37
|
"requests==2.25.1",
|
|
38
|
-
"tqdm>=4.66.1",
|
|
39
38
|
"mdba-gauge-getter==0.5.1",
|
|
40
39
|
"cachetools==5.2.0",
|
|
41
40
|
"xarray==2023.01.0",
|
|
@@ -12,7 +12,9 @@ from py_ewr import scenario_handling, data_inputs
|
|
|
12
12
|
def test_match_MDBA_nodes():
|
|
13
13
|
'''
|
|
14
14
|
1. Ensure dataframe with flows and levels is split into two dataframes (one flow and one level dataframe)
|
|
15
|
+
2. Ensure first column is used when duplicate columns are loaded
|
|
15
16
|
'''
|
|
17
|
+
# TEST 1 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
16
18
|
# Set up input data and pass to test function:
|
|
17
19
|
model_metadata = data_inputs.get_MDBA_codes()
|
|
18
20
|
data_df = {'Date': pd.date_range(start= datetime.strptime('2012-07-01', '%Y-%m-%d'), end = datetime.strptime('2016-06-30', '%Y-%m-%d')),
|
|
@@ -39,6 +41,36 @@ def test_match_MDBA_nodes():
|
|
|
39
41
|
assert_frame_equal(df_F, expected_df_F)
|
|
40
42
|
assert_frame_equal(df_L, expected_df_L)
|
|
41
43
|
|
|
44
|
+
# TEST 2 #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
45
|
+
# Set up input data and pass to test function:
|
|
46
|
+
model_metadata = data_inputs.get_MDBA_codes()
|
|
47
|
+
data_df = {'Date': pd.date_range(start= datetime.strptime('2012-07-01', '%Y-%m-%d'), end = datetime.strptime('2016-06-30', '%Y-%m-%d')),
|
|
48
|
+
'EUSTDS-1-8': [0]*1+[250]*350+[0]*9+[0]*5 + [0]*360+[0]*5 + [0]*2+[250]*345+[0]*1+[250]*17 + [0]*5+[250]*351+[250]*10, # Use
|
|
49
|
+
'EUSTDS-35-8': [0]*1+[250]*350+[0]*9+[0]*5 + [0]*360+[0]*5 + [0]*2+[250]*345+[0]*1+[250]*17 + [0]*5+[250]*351+[250]*10, # Skip
|
|
50
|
+
'EUSTUS-35-8': [0]*1+[250]*350+[0]*9+[0]*5 + [0]*360+[0]*5 + [0]*2+[250]*345+[0]*1+[250]*17 + [0]*5+[250]*351+[250]*10, # Skip
|
|
51
|
+
'EUSTUS-35-8': [0]*1+[250]*350+[0]*9+[0]*5 + [0]*360+[0]*5 + [0]*2+[250]*345+[0]*1+[250]*17 + [0]*5+[250]*351+[250]*10, # Use
|
|
52
|
+
'EUSTUS-1-8': [1]*1+[250]*350+[0]*9+[0]*5 + [0]*360+[0]*5 + [0]*2+[250]*345+[0]*1+[250]*17 + [0]*5+[250]*351+[250]*10, # Skip
|
|
53
|
+
}
|
|
54
|
+
df = pd.DataFrame(data = data_df)
|
|
55
|
+
df = df.set_index('Date')
|
|
56
|
+
|
|
57
|
+
df_F, df_L = scenario_handling.match_MDBA_nodes(df, model_metadata, 'py_ewr/parameter_metadata/parameter_sheet.csv')
|
|
58
|
+
|
|
59
|
+
# Set up expected outputs and test:
|
|
60
|
+
data_expected_df_L = {'Date': pd.date_range(start= datetime.strptime('2012-07-01', '%Y-%m-%d'), end = datetime.strptime('2016-06-30', '%Y-%m-%d')),
|
|
61
|
+
'414209': [0]*1+[250]*350+[0]*9+[0]*5 + [0]*360+[0]*5 + [0]*2+[250]*345+[0]*1+[250]*17 + [0]*5+[250]*351+[250]*10
|
|
62
|
+
}
|
|
63
|
+
expected_df_L = pd.DataFrame(data_expected_df_L)
|
|
64
|
+
expected_df_L = expected_df_L.set_index('Date')
|
|
65
|
+
data_expected_df_F = {'Date': pd.date_range(start= datetime.strptime('2012-07-01', '%Y-%m-%d'), end = datetime.strptime('2016-06-30', '%Y-%m-%d')),
|
|
66
|
+
'414203': [0]*1+[250]*350+[0]*9+[0]*5 + [0]*360+[0]*5 + [0]*2+[250]*345+[0]*1+[250]*17 + [0]*5+[250]*351+[250]*10
|
|
67
|
+
}
|
|
68
|
+
expected_df_F = pd.DataFrame(data_expected_df_F)
|
|
69
|
+
expected_df_F = expected_df_F.set_index('Date')
|
|
70
|
+
|
|
71
|
+
assert_frame_equal(df_F, expected_df_F)
|
|
72
|
+
assert_frame_equal(df_L, expected_df_L)
|
|
73
|
+
|
|
42
74
|
def test_match_NSW_nodes():
|
|
43
75
|
'''
|
|
44
76
|
1. Check NSW model nodes are mapped correctly to their gauges
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|