py-ewr 2.3.3__py3-none-any.whl → 2.3.5__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/evaluate_EWRs.py +10 -7
- py_ewr/model_metadata/SiteID_MDBA.csv +3 -2
- py_ewr/parameter_metadata/ewr2obj.csv +43095 -36563
- py_ewr/parameter_metadata/ewr_calc_config.json +76 -50
- py_ewr/parameter_metadata/parameter_sheet.csv +151 -159
- py_ewr/scenario_handling.py +272 -15
- {py_ewr-2.3.3.dist-info → py_ewr-2.3.5.dist-info}/METADATA +13 -3
- py_ewr-2.3.5.dist-info/RECORD +20 -0
- {py_ewr-2.3.3.dist-info → py_ewr-2.3.5.dist-info}/WHEEL +1 -1
- py_ewr-2.3.3.dist-info/RECORD +0 -20
- {py_ewr-2.3.3.dist-info → py_ewr-2.3.5.dist-info}/LICENSE +0 -0
- {py_ewr-2.3.3.dist-info → py_ewr-2.3.5.dist-info}/top_level.txt +0 -0
py_ewr/scenario_handling.py
CHANGED
|
@@ -326,17 +326,26 @@ def cleaner_standard_timeseries(input_df: pd.DataFrame, ewr_table_path: str = No
|
|
|
326
326
|
df_flow.index.name = 'Date'
|
|
327
327
|
df_level.index.name = 'Date'
|
|
328
328
|
|
|
329
|
+
flow_gauges = data_inputs.get_gauges('flow gauges', ewr_table_path=ewr_table_path)
|
|
330
|
+
level_gauges = data_inputs.get_gauges('level gauges', ewr_table_path=ewr_table_path)
|
|
331
|
+
|
|
332
|
+
report = pd.DataFrame(index = list(set(list(flow_gauges) + list(level_gauges))), columns = ['flow', 'level'])
|
|
333
|
+
report['flow'] = 'N'
|
|
334
|
+
report['level'] = 'N'
|
|
335
|
+
|
|
329
336
|
for gauge in cleaned_df.columns:
|
|
330
337
|
gauge_only = extract_gauge_from_string(gauge)
|
|
331
338
|
if 'flow' in gauge:
|
|
332
339
|
df_flow[gauge_only] = cleaned_df[gauge].copy(deep=True)
|
|
340
|
+
report.at[gauge_only, 'flow'] = 'Y'
|
|
333
341
|
if 'level' in gauge:
|
|
334
342
|
df_level[gauge_only] = cleaned_df[gauge].copy(deep=True)
|
|
343
|
+
report.at[gauge_only, 'level'] = 'Y'
|
|
335
344
|
if not gauge_only:
|
|
336
345
|
log.info('Could not identify gauge in column name:', gauge, ', skipping analysis of data in this column.')
|
|
337
|
-
return df_flow, df_level
|
|
346
|
+
return df_flow, df_level, report
|
|
338
347
|
|
|
339
|
-
def cleaner_netcdf_werp(input_df: pd.DataFrame, stations: dict) -> pd.DataFrame:
|
|
348
|
+
def cleaner_netcdf_werp(input_df: pd.DataFrame, stations: dict, ewr_table_path: str) -> pd.DataFrame:
|
|
340
349
|
|
|
341
350
|
'''Ingests dataframe, cleans up into a format matching IQQM csv
|
|
342
351
|
|
|
@@ -370,8 +379,8 @@ def cleaner_netcdf_werp(input_df: pd.DataFrame, stations: dict) -> pd.DataFrame:
|
|
|
370
379
|
cleaned_df.index.names = ['Date']
|
|
371
380
|
|
|
372
381
|
# Split gauges into flow and level, allocate to respective dataframe
|
|
373
|
-
flow_gauges = data_inputs.get_gauges('flow gauges')
|
|
374
|
-
level_gauges = data_inputs.get_gauges('level gauges')
|
|
382
|
+
flow_gauges = data_inputs.get_gauges('flow gauges', ewr_table_path=ewr_table_path)
|
|
383
|
+
level_gauges = data_inputs.get_gauges('level gauges', ewr_table_path=ewr_table_path)
|
|
375
384
|
df_flow = pd.DataFrame(index = cleaned_df.index)
|
|
376
385
|
df_level = pd.DataFrame(index = cleaned_df.index)
|
|
377
386
|
for gauge in cleaned_df.columns:
|
|
@@ -455,7 +464,7 @@ def match_MDBA_nodes(input_df: pd.DataFrame, model_metadata: pd.DataFrame, ewr_t
|
|
|
455
464
|
df_flow = pd.DataFrame(index = input_df.index)
|
|
456
465
|
df_level = pd.DataFrame(index = input_df.index)
|
|
457
466
|
|
|
458
|
-
unique_gauges = data_inputs.get_gauges('all gauges')
|
|
467
|
+
unique_gauges = data_inputs.get_gauges('all gauges', ewr_table_path=ewr_table_path)
|
|
459
468
|
flow_gauges = data_inputs.get_gauges('flow gauges', ewr_table_path=ewr_table_path)
|
|
460
469
|
level_gauges = data_inputs.get_gauges('level gauges', ewr_table_path=ewr_table_path)
|
|
461
470
|
|
|
@@ -486,7 +495,7 @@ def match_MDBA_nodes(input_df: pd.DataFrame, model_metadata: pd.DataFrame, ewr_t
|
|
|
486
495
|
raise ValueError('No relevant gauges and or measurands found in dataset, the EWR tool cannot evaluate this model output file')
|
|
487
496
|
|
|
488
497
|
# report.to_csv('report_v1.csv')
|
|
489
|
-
return df_flow, df_level
|
|
498
|
+
return df_flow, df_level, report
|
|
490
499
|
|
|
491
500
|
|
|
492
501
|
# def match_MDBA_nodes_old(input_df: pd.DataFrame, model_metadata: pd.DataFrame, ewr_table_path: str) -> tuple:
|
|
@@ -534,7 +543,7 @@ def match_MDBA_nodes(input_df: pd.DataFrame, model_metadata: pd.DataFrame, ewr_t
|
|
|
534
543
|
|
|
535
544
|
# return df_flow, df_level
|
|
536
545
|
|
|
537
|
-
def match_NSW_nodes(input_df: pd.DataFrame, model_metadata: pd.DataFrame) -> tuple:
|
|
546
|
+
def match_NSW_nodes(input_df: pd.DataFrame, model_metadata: pd.DataFrame, ewr_table_path: str) -> tuple:
|
|
538
547
|
'''Checks if the source file columns have EWRs available, returns a flow and level dataframe with only
|
|
539
548
|
the columns with EWRs available. Renames columns to gauges
|
|
540
549
|
|
|
@@ -546,8 +555,8 @@ def match_NSW_nodes(input_df: pd.DataFrame, model_metadata: pd.DataFrame) -> tup
|
|
|
546
555
|
tuple[pd.DataFrame, pd.DataFrame]: flow dataframe, water level dataframe
|
|
547
556
|
|
|
548
557
|
'''
|
|
549
|
-
flow_gauges = data_inputs.get_gauges('flow gauges')
|
|
550
|
-
level_gauges = data_inputs.get_gauges('level gauges')
|
|
558
|
+
flow_gauges = data_inputs.get_gauges('flow gauges', ewr_table_path=ewr_table_path)
|
|
559
|
+
level_gauges = data_inputs.get_gauges('level gauges', ewr_table_path=ewr_table_path)
|
|
551
560
|
df_flow = pd.DataFrame(index = input_df.index)
|
|
552
561
|
df_level = pd.DataFrame(index = input_df.index)
|
|
553
562
|
for col in input_df.columns:
|
|
@@ -597,7 +606,10 @@ class ScenarioHandler:
|
|
|
597
606
|
|
|
598
607
|
def process_scenarios(self):
|
|
599
608
|
|
|
600
|
-
|
|
609
|
+
if self.model_format != 'All Bigmod':
|
|
610
|
+
scenarios = self._get_file_names(self.scenario_file)
|
|
611
|
+
else:
|
|
612
|
+
scenarios = [self.scenario_file]
|
|
601
613
|
|
|
602
614
|
# Analyse all scenarios for EWRs
|
|
603
615
|
detailed_results = {}
|
|
@@ -608,11 +620,12 @@ class ScenarioHandler:
|
|
|
608
620
|
data, header = unpack_model_file(scenarios[scenario], 'Dy', 'Field')
|
|
609
621
|
data = build_MDBA_columns(data, header)
|
|
610
622
|
df_clean = cleaner_MDBA(data)
|
|
611
|
-
|
|
623
|
+
self.df_clean = df_clean
|
|
624
|
+
df_F, df_L, self.report = match_MDBA_nodes(df_clean, data_inputs.get_MDBA_codes(), self.parameter_sheet)
|
|
612
625
|
|
|
613
626
|
elif self.model_format == 'Standard time-series':
|
|
614
627
|
df = pd.read_csv(scenarios[scenario], index_col = 'Date')
|
|
615
|
-
df_F, df_L = cleaner_standard_timeseries(df, self.parameter_sheet)
|
|
628
|
+
df_F, df_L, self.report = cleaner_standard_timeseries(df, self.parameter_sheet)
|
|
616
629
|
|
|
617
630
|
elif self.model_format == 'Source - NSW (res.csv)':
|
|
618
631
|
data, header = unpack_model_file(scenarios[scenario], 'Date', 'Field')
|
|
@@ -622,12 +635,29 @@ class ScenarioHandler:
|
|
|
622
635
|
|
|
623
636
|
elif self.model_format == 'IQQM - netcdf':
|
|
624
637
|
df_unpacked = unpack_netcdf_as_dataframe(scenarios[scenario])
|
|
625
|
-
df_F, df_L = cleaner_netcdf_werp(df_unpacked, data_inputs.get_iqqm_codes())
|
|
638
|
+
df_F, df_L = cleaner_netcdf_werp(df_unpacked, data_inputs.get_iqqm_codes(),self.parameter_sheet)
|
|
626
639
|
|
|
627
640
|
elif self.model_format == 'ten thousand year':
|
|
628
641
|
df = pd.read_csv(scenarios[scenario], index_col = 'Date')
|
|
629
642
|
df_F, df_L = cleaner_ten_thousand_year(df, self.parameter_sheet)
|
|
630
|
-
|
|
643
|
+
|
|
644
|
+
elif self.model_format == 'All Bigmod':
|
|
645
|
+
|
|
646
|
+
all_data = []
|
|
647
|
+
for scenario_file in scenario:
|
|
648
|
+
print(scenario_file)
|
|
649
|
+
data, header = unpack_model_file(scenario_file, 'Dy', 'Field')
|
|
650
|
+
data = build_MDBA_columns(data, header)
|
|
651
|
+
all_data.append(data)
|
|
652
|
+
|
|
653
|
+
merged_data = all_data[0]
|
|
654
|
+
for i in range(1, len(all_data)):
|
|
655
|
+
merged_data = merged_data.merge(all_data[i], on=['Dy','Mn','Year'])
|
|
656
|
+
|
|
657
|
+
df_clean = cleaner_MDBA(merged_data)
|
|
658
|
+
self.df_clean = df_clean
|
|
659
|
+
df_F, df_L, self.report = match_MDBA_nodes(df_clean, data_inputs.get_MDBA_codes(), self.parameter_sheet)
|
|
660
|
+
|
|
631
661
|
gauge_results = {}
|
|
632
662
|
gauge_events = {}
|
|
633
663
|
|
|
@@ -637,6 +667,10 @@ class ScenarioHandler:
|
|
|
637
667
|
for gauge in all_locations:
|
|
638
668
|
gauge_results[gauge], gauge_events[gauge] = evaluate_EWRs.calc_sorter(df_F, df_L, gauge,
|
|
639
669
|
EWR_table, calc_config)
|
|
670
|
+
|
|
671
|
+
if self.model_format == 'All Bigmod':
|
|
672
|
+
scenario = scenario_file[-10:-4]
|
|
673
|
+
|
|
640
674
|
detailed_results[scenario] = gauge_results
|
|
641
675
|
detailed_events[scenario] = gauge_events
|
|
642
676
|
self.pu_ewr_statistics = detailed_results
|
|
@@ -808,4 +842,227 @@ class ScenarioHandler:
|
|
|
808
842
|
if not self.pu_ewr_statistics:
|
|
809
843
|
self.process_scenarios()
|
|
810
844
|
|
|
811
|
-
|
|
845
|
+
self.ewr_results = summarise_results.summarise(self.pu_ewr_statistics , self.yearly_events, parameter_sheet_path=self.parameter_sheet)
|
|
846
|
+
|
|
847
|
+
return self.ewr_results
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
def log_analysed_results(self):
|
|
851
|
+
'''
|
|
852
|
+
For each unique ewr/pu/gauge - examines the ewr_results dataframe and if it exists here, then it is set to True in the logging_sheet dataframe.
|
|
853
|
+
Create corresponding column in logging_sheet to log info.
|
|
854
|
+
'''
|
|
855
|
+
results = self.ewr_results[["PlanningUnit", "Gauge", "EwrCode"]].copy()
|
|
856
|
+
results["Analysed?"] = True
|
|
857
|
+
self.logging_sheet = self.logging_sheet.merge(right = results, left_on=["PlanningUnitName", "Primary Gauge", "Code"], right_on=["PlanningUnit", "Gauge", "EwrCode"], how="left")
|
|
858
|
+
self.logging_sheet["Analysed?"] = ~self.logging_sheet["Analysed?"].isna()
|
|
859
|
+
self.logging_sheet["Gauge"] = self.logging_sheet["Gauge_x"].copy()
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
def log_if_node_in_siteID(self):
|
|
863
|
+
'''
|
|
864
|
+
For each node, checks if the node is in the siteid file. Note, this is a preliminary check, as it doesn't reveal if a match in the SITEID was made with model data.
|
|
865
|
+
Create corresponding column in logging_sheet to log info.
|
|
866
|
+
TODO: make work with non 'Bigmod - MDBA' siteid's
|
|
867
|
+
'''
|
|
868
|
+
|
|
869
|
+
if self.model_format == 'Bigmod - MDBA':
|
|
870
|
+
self.site_id_df = data_inputs.get_MDBA_codes()[["AWRC", "SITEID"]]
|
|
871
|
+
elif self.model_format == 'All Bigmod':
|
|
872
|
+
self.site_id_df = data_inputs.get_MDBA_codes()[["AWRC", "SITEID"]]
|
|
873
|
+
elif self.model_format == 'Source - NSW (res.csv)':
|
|
874
|
+
pass
|
|
875
|
+
elif self.model_format == 'Standard time-series':
|
|
876
|
+
self.site_id_df = data_inputs.get_MDBA_codes()[["AWRC", "SITEID"]]
|
|
877
|
+
elif self.model_format == 'IQQM - netcdf':
|
|
878
|
+
pass
|
|
879
|
+
elif self.model_format == 'ten thousand year':
|
|
880
|
+
pass
|
|
881
|
+
|
|
882
|
+
self.logging_sheet["node_in_siteID?"] = self.logging_sheet["Gauge"].isin(self.site_id_df["AWRC"].unique())
|
|
883
|
+
|
|
884
|
+
def log_if_gauge_in_model_file(self):
|
|
885
|
+
'''
|
|
886
|
+
For each gauge, check if is in the list of all gauges corresponding to siteID's in the model file.
|
|
887
|
+
Create corresponding column in logging_sheet to log info.
|
|
888
|
+
'''
|
|
889
|
+
site_id_in_model_file = [n for name in self.df_clean.columns for n in name.split("-")]
|
|
890
|
+
self.site_id_df["IN_MODELFILE"] = self.site_id_df["SITEID"].isin(site_id_in_model_file)
|
|
891
|
+
self.gauges_in_model_file = self.site_id_df[self.site_id_df.IN_MODELFILE]["AWRC"]
|
|
892
|
+
self.logging_sheet["gauge_in_model_file?"] = self.logging_sheet["Gauge"].isin(self.gauges_in_model_file)
|
|
893
|
+
|
|
894
|
+
def log_measurand_info(self):
|
|
895
|
+
'''
|
|
896
|
+
Log if the flow and level data has been read in for each gauge.
|
|
897
|
+
Create corresponding column in logging_sheet to log info.
|
|
898
|
+
'''
|
|
899
|
+
self.logging_sheet.loc[:, "gaugeANDmeasurand_in_model_file? (Yes/No)"] = False
|
|
900
|
+
|
|
901
|
+
for idx, row in self.logging_sheet[["Gauge", "GaugeType"]].drop_duplicates().iterrows():
|
|
902
|
+
|
|
903
|
+
gauge = row["Gauge"]
|
|
904
|
+
gauge_type = row["GaugeType"]
|
|
905
|
+
|
|
906
|
+
if gauge_type == 'F':
|
|
907
|
+
full_gauge_type = 'flow'
|
|
908
|
+
else:
|
|
909
|
+
full_gauge_type = 'level'
|
|
910
|
+
|
|
911
|
+
if gauge in set(self.report.index):
|
|
912
|
+
self.logging_sheet.loc[(self.logging_sheet.Gauge == gauge) & (self.logging_sheet.GaugeType == gauge_type), "gaugeANDmeasurand_in_model_file? (Yes/No)"] = self.report.loc[gauge, full_gauge_type] == 'Y'
|
|
913
|
+
|
|
914
|
+
return self.logging_sheet
|
|
915
|
+
|
|
916
|
+
def log_calc_config_info(self):
|
|
917
|
+
'''
|
|
918
|
+
See if a calc config matches for each gauge/pu/ewr combination.
|
|
919
|
+
TODO: make calc config a function with the option to just return the already calculated values
|
|
920
|
+
'''
|
|
921
|
+
calc_config = data_inputs.get_ewr_calc_config(self.calc_config_path)
|
|
922
|
+
|
|
923
|
+
invalid_calc_configs = []
|
|
924
|
+
ewr_keys_in_parameter_sheet = []
|
|
925
|
+
self.logging_sheet["EWR_key"] = None
|
|
926
|
+
|
|
927
|
+
for gauge in self.logging_sheet['Primary Gauge'].unique():
|
|
928
|
+
|
|
929
|
+
PU_items = self.logging_sheet.groupby(['PlanningUnitID', 'PlanningUnitName']).size().reset_index().drop([0], axis=1)
|
|
930
|
+
gauge_table = self.logging_sheet[self.logging_sheet['Primary Gauge'] == gauge]
|
|
931
|
+
|
|
932
|
+
for PU in set(gauge_table['PlanningUnitID']):
|
|
933
|
+
|
|
934
|
+
PU_table = gauge_table[gauge_table['PlanningUnitID'] == PU]
|
|
935
|
+
EWR_categories = PU_table['FlowLevelVolume'].values
|
|
936
|
+
EWR_codes = PU_table['Code']
|
|
937
|
+
|
|
938
|
+
for cat, EWR in zip(EWR_categories, EWR_codes):
|
|
939
|
+
|
|
940
|
+
## CUSTOM MULTIGAUGE CHECK
|
|
941
|
+
item = self.logging_sheet[(self.logging_sheet['Primary Gauge']==gauge) & (self.logging_sheet['Code']==EWR) & (self.logging_sheet['PlanningUnitID']==PU)]
|
|
942
|
+
item = item.replace({np.nan: None})
|
|
943
|
+
mg = item['Multigauge'].to_list()
|
|
944
|
+
|
|
945
|
+
if not mg[0]:
|
|
946
|
+
gauge_calc_type = 'single'
|
|
947
|
+
elif mg[0] == '':
|
|
948
|
+
gauge_calc_type = 'single'
|
|
949
|
+
else:
|
|
950
|
+
gauge_calc_type = 'multigauge'
|
|
951
|
+
####
|
|
952
|
+
|
|
953
|
+
ewr_key = f'{EWR}-{gauge_calc_type}-{cat}'
|
|
954
|
+
self.logging_sheet.loc[((self.logging_sheet['Primary Gauge']==gauge) & (self.logging_sheet['Code']==EWR) & (self.logging_sheet['PlanningUnitID']==PU)), "EWR_key"] = ewr_key
|
|
955
|
+
function_name = evaluate_EWRs.find_function(ewr_key, calc_config)
|
|
956
|
+
ewr_keys_in_parameter_sheet.append(ewr_key)
|
|
957
|
+
|
|
958
|
+
if function_name == 'unknown':
|
|
959
|
+
invalid_calc_configs.append(ewr_key)
|
|
960
|
+
continue
|
|
961
|
+
handle_function = evaluate_EWRs.get_handle_function(function_name)
|
|
962
|
+
if not handle_function:
|
|
963
|
+
invalid_calc_configs.append(ewr_key)
|
|
964
|
+
continue
|
|
965
|
+
|
|
966
|
+
self.logging_sheet["is_in_calc_config?"] = ~self.logging_sheet["EWR_key"].isin(invalid_calc_configs)
|
|
967
|
+
|
|
968
|
+
def log_siteID_info(self):
|
|
969
|
+
"""
|
|
970
|
+
Add the siteID info to the logging_sheet. Add the siteID of that gauge it matched with, as well as a list of all siteIDs for that gauge that it didn't match with. (i.e. the "spares" not in the model file.)
|
|
971
|
+
"""
|
|
972
|
+
## add the matching siteID info
|
|
973
|
+
spare_siteID_df = self.site_id_df[self.site_id_df.AWRC.isin(self.gauges_in_model_file) & ~self.site_id_df.IN_MODELFILE].astype(str)
|
|
974
|
+
spare_siteID_df = spare_siteID_df.groupby("AWRC").agg({'SITEID': 'sum'})
|
|
975
|
+
# spare_siteID_df = spare_siteID_df.groupby("AWRC").agg({'SITEID': lambda x: list(x)})
|
|
976
|
+
spare_siteID_df = spare_siteID_df.rename(columns={"SITEID": "spare_SITEID"})
|
|
977
|
+
|
|
978
|
+
self.logging_sheet = self.logging_sheet.merge(right = spare_siteID_df, left_on=["Gauge"], right_index=True, how="left")
|
|
979
|
+
|
|
980
|
+
### section to add the used SITEID
|
|
981
|
+
used_siteID_df = self.site_id_df[self.site_id_df.IN_MODELFILE][["AWRC", "SITEID"]]
|
|
982
|
+
used_siteID_df = used_siteID_df.rename(columns={"SITEID": "matched_SITEID"})
|
|
983
|
+
used_siteID_df = used_siteID_df.set_index("AWRC")
|
|
984
|
+
|
|
985
|
+
self.logging_sheet = self.logging_sheet.merge(right = used_siteID_df, left_on=["Gauge"], right_index=True, how="left")
|
|
986
|
+
|
|
987
|
+
# mark spare_SITEID column of those that dont have more than one SITEID to match with as EXACT MATCHES
|
|
988
|
+
self.logging_sheet.loc[~self.logging_sheet.matched_SITEID.isna() & self.logging_sheet.spare_SITEID.isna(), "spare_SITEID"] = "EXACT_MATCH"
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
def create_multi_index(self, logging_sheet):
|
|
992
|
+
|
|
993
|
+
logging_sheet.insert(loc=4, column='Primary Gauge', value=logging_sheet.Gauge.values)
|
|
994
|
+
|
|
995
|
+
## Multigauge
|
|
996
|
+
|
|
997
|
+
rows_to_duplicate = logging_sheet.loc[(~logging_sheet["Multigauge"].isna()),:]
|
|
998
|
+
|
|
999
|
+
for counter, (idx, row) in enumerate(rows_to_duplicate.iterrows()):
|
|
1000
|
+
updated_idx = counter + idx # update idx to account for all inserted rows
|
|
1001
|
+
duplicate_row = logging_sheet.loc[updated_idx, :].copy()
|
|
1002
|
+
duplicate_row["Gauge"] = logging_sheet.loc[updated_idx, "Multigauge"]
|
|
1003
|
+
logging_sheet = pd.DataFrame(np.insert(logging_sheet.values, updated_idx+1, values=duplicate_row.values, axis=0), columns=logging_sheet.columns)
|
|
1004
|
+
|
|
1005
|
+
## Weirpool
|
|
1006
|
+
|
|
1007
|
+
rows_to_duplicate = logging_sheet.loc[(~logging_sheet["WeirpoolGauge"].isna()),:]
|
|
1008
|
+
|
|
1009
|
+
for counter, (idx, row) in enumerate(rows_to_duplicate.iterrows()):
|
|
1010
|
+
updated_idx = counter + idx # update idx to account for all inserted rows
|
|
1011
|
+
duplicate_row = logging_sheet.loc[updated_idx, :].copy()
|
|
1012
|
+
duplicate_row["Gauge"] = logging_sheet.loc[updated_idx, "WeirpoolGauge"]
|
|
1013
|
+
duplicate_row["GaugeType"] = "L"
|
|
1014
|
+
logging_sheet = pd.DataFrame(np.insert(logging_sheet.values, updated_idx+1, values=duplicate_row.values, axis=0), columns=logging_sheet.columns)
|
|
1015
|
+
|
|
1016
|
+
## Barrage Gauges
|
|
1017
|
+
|
|
1018
|
+
barrage_flow_gauges = data_inputs.get_barrage_flow_gauges()
|
|
1019
|
+
barrage_level_gauges = data_inputs.get_barrage_level_gauges()
|
|
1020
|
+
|
|
1021
|
+
## Because all barrage flow gauges have GaugeType flow, and all barrage level gauges have GaugeType level, the logic of the code to copy the GaugeType and modify the gauge name means they can be done at the same time.
|
|
1022
|
+
|
|
1023
|
+
dict_gauges = {**barrage_flow_gauges, **barrage_level_gauges}
|
|
1024
|
+
|
|
1025
|
+
for gauge, gauge_list in dict_gauges.items():
|
|
1026
|
+
|
|
1027
|
+
counter = 0
|
|
1028
|
+
rows_to_duplicate = logging_sheet.loc[(logging_sheet["Primary Gauge"] == gauge),:]
|
|
1029
|
+
|
|
1030
|
+
for idx, row in rows_to_duplicate.iterrows():
|
|
1031
|
+
|
|
1032
|
+
updated_idx = idx + counter # update idx to account for all inserted rows
|
|
1033
|
+
duplicate_row = logging_sheet.loc[updated_idx, :].copy()
|
|
1034
|
+
|
|
1035
|
+
rows_to_insert = pd.DataFrame([duplicate_row] * len(gauge_list))
|
|
1036
|
+
rows_to_insert["Gauge"] = gauge_list
|
|
1037
|
+
|
|
1038
|
+
logging_sheet.drop(index=updated_idx, axis=0, inplace=True)
|
|
1039
|
+
|
|
1040
|
+
logging_sheet = pd.DataFrame(np.insert(logging_sheet.values, updated_idx, values=rows_to_insert.values, axis=0), columns=logging_sheet.columns)
|
|
1041
|
+
|
|
1042
|
+
counter += len(gauge_list) - 1
|
|
1043
|
+
|
|
1044
|
+
return logging_sheet
|
|
1045
|
+
|
|
1046
|
+
def get_logs(self) -> pd.DataFrame:
|
|
1047
|
+
"""
|
|
1048
|
+
Create the logging sheet
|
|
1049
|
+
TODO: ensure that self.get_ewr_results() has been run and if not make it run.
|
|
1050
|
+
"""
|
|
1051
|
+
parameter_sheet = pd.read_csv(self.parameter_sheet)
|
|
1052
|
+
|
|
1053
|
+
self.logging_sheet = parameter_sheet.copy()[["PlanningUnitName", "Code", "Gauge", "GaugeType", 'PlanningUnitID', 'FlowLevelVolume', "Multigauge", "WeirpoolGauge"]]
|
|
1054
|
+
|
|
1055
|
+
self.logging_sheet = self.create_multi_index(self.logging_sheet)
|
|
1056
|
+
|
|
1057
|
+
self.log_analysed_results()
|
|
1058
|
+
self.log_if_node_in_siteID()
|
|
1059
|
+
self.log_if_gauge_in_model_file()
|
|
1060
|
+
self.log_measurand_info()
|
|
1061
|
+
self.log_calc_config_info()
|
|
1062
|
+
self.log_siteID_info()
|
|
1063
|
+
|
|
1064
|
+
self.logging_sheet = self.logging_sheet[["PlanningUnitName", "Code", "Primary Gauge", "Gauge", "GaugeType", "is_in_calc_config?", "node_in_siteID?", "gauge_in_model_file?", "gaugeANDmeasurand_in_model_file? (Yes/No)", "matched_SITEID", "spare_SITEID", "Analysed?"]]
|
|
1065
|
+
|
|
1066
|
+
return self.logging_sheet
|
|
1067
|
+
|
|
1068
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: py_ewr
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.5
|
|
4
4
|
Summary: Environmental Water Requirement calculator
|
|
5
5
|
Home-page: https://github.com/MDBAuth/EWR_tool
|
|
6
6
|
Author: Martin Job
|
|
@@ -28,15 +28,25 @@ Requires-Dist: xarray
|
|
|
28
28
|
Requires-Dist: h5py
|
|
29
29
|
Requires-Dist: netCDF4
|
|
30
30
|
Requires-Dist: numpy<2
|
|
31
|
+
Dynamic: author
|
|
32
|
+
Dynamic: author-email
|
|
33
|
+
Dynamic: classifier
|
|
34
|
+
Dynamic: description
|
|
35
|
+
Dynamic: description-content-type
|
|
36
|
+
Dynamic: home-page
|
|
37
|
+
Dynamic: project-url
|
|
38
|
+
Dynamic: requires-dist
|
|
39
|
+
Dynamic: summary
|
|
31
40
|
|
|
32
41
|
[]()
|
|
33
42
|
[](https://pypi.org/project/py-ewr/)
|
|
34
43
|
[](https://pypi.org/project/py-ewr/)
|
|
35
44
|
[](https://zenodo.org/badge/latestdoi/342122359)
|
|
36
45
|
|
|
37
|
-
### **EWR tool version 2.3.
|
|
46
|
+
### **EWR tool version 2.3.5 README**
|
|
38
47
|
|
|
39
48
|
### **Notes on recent version updates**
|
|
49
|
+
- Including metadata report (this is still being ironed out and tested)
|
|
40
50
|
- CLLMM_c and CLLMM_d ewrs are now able to be calculated without all barrage level gauges being present in the model file.
|
|
41
51
|
- 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
|
|
42
52
|
- Including an example parallel processing script for running the EWR tool
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
py_ewr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
py_ewr/data_inputs.py,sha256=oUiEiLY_CmbvqF5GlV-3Yfz_JZ1qZNvta-VEYCzAcso,20124
|
|
3
|
+
py_ewr/evaluate_EWRs.py,sha256=NC6FYWT5jEAEpV3bp5T1CuYUJjnz1bqiamRoKTptpqE,231607
|
|
4
|
+
py_ewr/io.py,sha256=Is0xPAzLx6-ylpTFyYJxMimkNVxxoTxUcknTk6bQbgs,840
|
|
5
|
+
py_ewr/observed_handling.py,sha256=JTSK_2obhqNWJ2QknykywevNMN0fsvGXSejFwUSpMoA,18112
|
|
6
|
+
py_ewr/scenario_handling.py,sha256=i_0MRHXSCZdjhea7C5prI99r0ADZTANaKPhXWeL7cOg,48741
|
|
7
|
+
py_ewr/summarise_results.py,sha256=rFaAUVR4jIsjeRl4ocPFE2RUoJJBZgZ2wPEBh-dfEsc,31761
|
|
8
|
+
py_ewr/model_metadata/SiteID_MDBA.csv,sha256=orbh3QIRbOkUjCB2hcdpeUvhepnY_3ywldu22s45d5Y,168771
|
|
9
|
+
py_ewr/model_metadata/SiteID_NSW.csv,sha256=UVBxN43Z5KWCvWhQ5Rh6TNEn35q4_sjPxKyHg8wPFws,6805
|
|
10
|
+
py_ewr/model_metadata/iqqm_stations.csv,sha256=vl4CPtPslG5VplSzf_yLZulTrmab-mEBHOfzFtS1kf4,110
|
|
11
|
+
py_ewr/parameter_metadata/ewr2obj.csv,sha256=qvD-skiQiiMq3YABPUte8OdYGQD5Nesr0UvQMAsXnXU,4509292
|
|
12
|
+
py_ewr/parameter_metadata/ewr_calc_config.json,sha256=XfaJnFrAkGGBY4MRcsO5CH9SJ_K0989C4NAZYIVr_b0,18369
|
|
13
|
+
py_ewr/parameter_metadata/obj2target.csv,sha256=f6kLVyBhXUpGR4b0dzLbBvZbfpn3OxOhaB4aouO6Bvw,1593877
|
|
14
|
+
py_ewr/parameter_metadata/obj2yrtarget.csv,sha256=G8XgdCrOpB0xhp6n7DIS4Vcq69Kpgb1Pum7Ay3a_YPU,54882
|
|
15
|
+
py_ewr/parameter_metadata/parameter_sheet.csv,sha256=-wYjN-5vkYlUCzmsBLIZ1w3BI1RHO1iXMxZAg1inguA,766656
|
|
16
|
+
py_ewr-2.3.5.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
|
|
17
|
+
py_ewr-2.3.5.dist-info/METADATA,sha256=Y7KHZrrecKUjzZPGWJWi16-uMOZZP8zDDCb-xabeUhw,12974
|
|
18
|
+
py_ewr-2.3.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
19
|
+
py_ewr-2.3.5.dist-info/top_level.txt,sha256=n3725d-64Cjyb-YMUMV64UAuIflzUh2_UZSxiIbrur4,7
|
|
20
|
+
py_ewr-2.3.5.dist-info/RECORD,,
|
py_ewr-2.3.3.dist-info/RECORD
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
py_ewr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
py_ewr/data_inputs.py,sha256=oUiEiLY_CmbvqF5GlV-3Yfz_JZ1qZNvta-VEYCzAcso,20124
|
|
3
|
-
py_ewr/evaluate_EWRs.py,sha256=pCIqWysUuM-HbYn6U9bQnrHMhTl2CVhjWanpGJ6l0pc,231584
|
|
4
|
-
py_ewr/io.py,sha256=Is0xPAzLx6-ylpTFyYJxMimkNVxxoTxUcknTk6bQbgs,840
|
|
5
|
-
py_ewr/observed_handling.py,sha256=JTSK_2obhqNWJ2QknykywevNMN0fsvGXSejFwUSpMoA,18112
|
|
6
|
-
py_ewr/scenario_handling.py,sha256=veaiQ6vfQX40laUk3eEUFWqO3wceP76Wh92HhJFsl8A,35762
|
|
7
|
-
py_ewr/summarise_results.py,sha256=rFaAUVR4jIsjeRl4ocPFE2RUoJJBZgZ2wPEBh-dfEsc,31761
|
|
8
|
-
py_ewr/model_metadata/SiteID_MDBA.csv,sha256=1g1PtqDNXl-8B-BGBd6BhUZfD2ZobftEjq97E5PNwkQ,168728
|
|
9
|
-
py_ewr/model_metadata/SiteID_NSW.csv,sha256=UVBxN43Z5KWCvWhQ5Rh6TNEn35q4_sjPxKyHg8wPFws,6805
|
|
10
|
-
py_ewr/model_metadata/iqqm_stations.csv,sha256=vl4CPtPslG5VplSzf_yLZulTrmab-mEBHOfzFtS1kf4,110
|
|
11
|
-
py_ewr/parameter_metadata/ewr2obj.csv,sha256=r2uXzhZ-Rd1u3RLhNXmJnPYcHwouHBehEPnvednfz-I,3948677
|
|
12
|
-
py_ewr/parameter_metadata/ewr_calc_config.json,sha256=l1AgIRlf7UUmk3BNQ4r3kutU48pYHHVKmLELjoB-8rQ,17664
|
|
13
|
-
py_ewr/parameter_metadata/obj2target.csv,sha256=f6kLVyBhXUpGR4b0dzLbBvZbfpn3OxOhaB4aouO6Bvw,1593877
|
|
14
|
-
py_ewr/parameter_metadata/obj2yrtarget.csv,sha256=G8XgdCrOpB0xhp6n7DIS4Vcq69Kpgb1Pum7Ay3a_YPU,54882
|
|
15
|
-
py_ewr/parameter_metadata/parameter_sheet.csv,sha256=MxKE-649bIC6HGqh87MT_fR3Lmew8n10Oi6OsAF1N0Q,768524
|
|
16
|
-
py_ewr-2.3.3.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
|
|
17
|
-
py_ewr-2.3.3.dist-info/METADATA,sha256=S6B3jls9O5zaR0E8__GRzvcTToKrpqeSh6QgKSCWop0,12709
|
|
18
|
-
py_ewr-2.3.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
19
|
-
py_ewr-2.3.3.dist-info/top_level.txt,sha256=n3725d-64Cjyb-YMUMV64UAuIflzUh2_UZSxiIbrur4,7
|
|
20
|
-
py_ewr-2.3.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|