py-ewr 2.2.5__py3-none-any.whl → 2.2.7__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 +18 -4
- py_ewr/evaluate_EWRs.py +38 -18
- py_ewr/model_metadata/SiteID_MDBA.csv +2695 -2686
- py_ewr/parameter_metadata/parameter_sheet.csv +3459 -3447
- py_ewr/scenario_handling.py +82 -61
- {py_ewr-2.2.5.dist-info → py_ewr-2.2.7.dist-info}/METADATA +47 -23
- {py_ewr-2.2.5.dist-info → py_ewr-2.2.7.dist-info}/RECORD +10 -10
- {py_ewr-2.2.5.dist-info → py_ewr-2.2.7.dist-info}/WHEEL +1 -1
- {py_ewr-2.2.5.dist-info → py_ewr-2.2.7.dist-info}/LICENSE +0 -0
- {py_ewr-2.2.5.dist-info → py_ewr-2.2.7.dist-info}/top_level.txt +0 -0
py_ewr/data_inputs.py
CHANGED
|
@@ -121,7 +121,7 @@ def get_MDBA_codes() -> pd.DataFrame:
|
|
|
121
121
|
pd.DataFrame: dataframe for linking MDBA model nodes to gauges
|
|
122
122
|
|
|
123
123
|
'''
|
|
124
|
-
metadata = pd.read_csv( BASE_PATH / 'model_metadata/SiteID_MDBA.csv', engine = 'python', dtype=str
|
|
124
|
+
metadata = pd.read_csv( BASE_PATH / 'model_metadata/SiteID_MDBA.csv', engine = 'python', dtype=str)#, encoding='windows-1252')
|
|
125
125
|
|
|
126
126
|
return metadata
|
|
127
127
|
|
|
@@ -392,12 +392,12 @@ def get_gauges(category: str, ewr_table_path: str = None) -> set:
|
|
|
392
392
|
multi_gauges = get_multi_gauges('gauges')
|
|
393
393
|
multi_gauges = list(multi_gauges.values())
|
|
394
394
|
if category == 'all gauges':
|
|
395
|
-
return set(EWR_table['Gauge'].to_list()
|
|
395
|
+
return set(EWR_table['Gauge'].to_list()+menindee_gauges+wp_gauges+multi_gauges+flow_barrage_gauges+level_barrage_gauges+qld_flow_gauges+qld_level_gauges+vic_level_gauges)
|
|
396
396
|
elif category == 'flow gauges':
|
|
397
397
|
return set(EWR_table['Gauge'].to_list() + multi_gauges + flow_barrage_gauges + qld_flow_gauges)
|
|
398
398
|
elif category == 'level gauges':
|
|
399
399
|
level_gauges = EWR_table[EWR_table['FlowLevelVolume']=='L']['Gauge'].to_list()
|
|
400
|
-
return set(menindee_gauges + wp_gauges + level_barrage_gauges + qld_level_gauges + level_gauges)
|
|
400
|
+
return set(menindee_gauges + wp_gauges + level_barrage_gauges + qld_level_gauges + level_gauges + vic_level_gauges)
|
|
401
401
|
else:
|
|
402
402
|
raise ValueError('''No gauge category sent to the "get_gauges" function''')
|
|
403
403
|
|
|
@@ -439,4 +439,18 @@ def gauge_groups(parameter_sheet: pd.DataFrame) -> dict:
|
|
|
439
439
|
|
|
440
440
|
return flow_gauges, level_gauges, lake_level_gauges
|
|
441
441
|
|
|
442
|
-
# def gauges_to_measurand()
|
|
442
|
+
# def gauges_to_measurand()
|
|
443
|
+
|
|
444
|
+
def get_causal_ewr() -> dict:
|
|
445
|
+
|
|
446
|
+
ewr2obj_path = os.path.join(BASE_PATH, "parameter_metadata/ewr2obj.csv")
|
|
447
|
+
obj2target_path = os.path.join(BASE_PATH, "parameter_metadata/obj2target.csv")
|
|
448
|
+
obj2yrtarget_path = os.path.join(BASE_PATH, "parameter_metadata/obj2yrtarget.csv")
|
|
449
|
+
|
|
450
|
+
causal_ewr = {
|
|
451
|
+
"ewr2obj": pd.read_csv(ewr2obj_path),
|
|
452
|
+
"obj2target": pd.read_csv(obj2target_path),
|
|
453
|
+
"obj2yrtarget":pd.read_csv(obj2yrtarget_path)
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
return causal_ewr
|
py_ewr/evaluate_EWRs.py
CHANGED
|
@@ -4859,7 +4859,7 @@ def event_stats(df:pd.DataFrame, PU_df:pd.DataFrame, gauge:str, EWR:str, EWR_inf
|
|
|
4859
4859
|
years_with_events = get_event_years_volume_achieved(events, unique_water_years)
|
|
4860
4860
|
|
|
4861
4861
|
YWE = pd.Series(name = str(EWR + '_eventYears'), data = years_with_events, index = unique_water_years)
|
|
4862
|
-
PU_df = pd.concat([PU_df, YWE], axis = 1)
|
|
4862
|
+
# PU_df = pd.concat([PU_df, YWE], axis = 1)
|
|
4863
4863
|
# Number of event achievements:
|
|
4864
4864
|
num_event_achievements = get_achievements(EWR_info, events, unique_water_years, durations)
|
|
4865
4865
|
|
|
@@ -4867,64 +4867,84 @@ def event_stats(df:pd.DataFrame, PU_df:pd.DataFrame, gauge:str, EWR:str, EWR_inf
|
|
|
4867
4867
|
num_event_achievements = get_achievements_connecting_events(events, unique_water_years)
|
|
4868
4868
|
|
|
4869
4869
|
NEA = pd.Series(name = str(EWR + '_numAchieved'), data= num_event_achievements, index = unique_water_years)
|
|
4870
|
-
PU_df = pd.concat([PU_df, NEA], axis = 1)
|
|
4870
|
+
# PU_df = pd.concat([PU_df, NEA], axis = 1)
|
|
4871
4871
|
# Total number of events THIS ONE IS ONLY ACHIEVED due to Filter Applied
|
|
4872
4872
|
num_events = get_number_events(EWR_info, events, unique_water_years, durations)
|
|
4873
4873
|
NE = pd.Series(name = str(EWR + '_numEvents'), data= num_events, index = unique_water_years)
|
|
4874
|
-
PU_df = pd.concat([PU_df, NE], axis = 1)
|
|
4874
|
+
# PU_df = pd.concat([PU_df, NE], axis = 1)
|
|
4875
4875
|
# Total number of events THIS ONE IS ALL EVENTS
|
|
4876
4876
|
num_events_all = get_all_events(events)
|
|
4877
4877
|
NEALL = pd.Series(name = str(EWR + '_numEventsAll'), data= num_events_all, index = unique_water_years)
|
|
4878
|
-
PU_df = pd.concat([PU_df, NEALL], axis = 1)
|
|
4878
|
+
# PU_df = pd.concat([PU_df, NEALL], axis = 1)
|
|
4879
4879
|
# Max inter event period
|
|
4880
4880
|
max_inter_period = get_max_inter_event_days(no_events, unique_water_years)
|
|
4881
4881
|
MIP = pd.Series(name = str(EWR + '_maxInterEventDays'), data= max_inter_period, index = unique_water_years)
|
|
4882
|
-
PU_df = pd.concat([PU_df, MIP], axis = 1)
|
|
4882
|
+
# PU_df = pd.concat([PU_df, MIP], axis = 1)
|
|
4883
4883
|
# Max inter event period achieved
|
|
4884
4884
|
max_inter_period_achieved = get_event_max_inter_event_achieved(EWR_info, no_events, unique_water_years)
|
|
4885
4885
|
MIPA = pd.Series(name = str(EWR + '_maxInterEventDaysAchieved'), data= max_inter_period_achieved, index = unique_water_years)
|
|
4886
|
-
PU_df = pd.concat([PU_df, MIPA], axis = 1)
|
|
4886
|
+
# PU_df = pd.concat([PU_df, MIPA], axis = 1)
|
|
4887
4887
|
# Average length of events
|
|
4888
4888
|
av_length = get_average_event_length(events, unique_water_years)
|
|
4889
4889
|
AL = pd.Series(name = str(EWR + '_eventLength'), data = av_length, index = unique_water_years)
|
|
4890
|
-
PU_df = pd.concat([PU_df, AL], axis = 1)
|
|
4890
|
+
# PU_df = pd.concat([PU_df, AL], axis = 1)
|
|
4891
4891
|
# Average length of events ONLY the ACHIEVED
|
|
4892
4892
|
av_length_achieved = get_average_event_length_achieved(EWR_info, events)
|
|
4893
4893
|
ALA = pd.Series(name = str(EWR + '_eventLengthAchieved' ), data = av_length_achieved, index = unique_water_years)
|
|
4894
|
-
PU_df = pd.concat([PU_df, ALA], axis = 1)
|
|
4894
|
+
# PU_df = pd.concat([PU_df, ALA], axis = 1)
|
|
4895
4895
|
# Total event days
|
|
4896
4896
|
total_days = get_total_days(events, unique_water_years)
|
|
4897
|
-
|
|
4898
|
-
PU_df = pd.concat([PU_df, TD], axis = 1)
|
|
4897
|
+
TD_A = pd.Series(name = str(EWR + '_totalEventDays'), data = total_days, index = unique_water_years)
|
|
4898
|
+
# PU_df = pd.concat([PU_df, TD], axis = 1)
|
|
4899
4899
|
# Total event days ACHIEVED
|
|
4900
4900
|
total_days_achieved = get_achieved_event_days(EWR_info, events)
|
|
4901
4901
|
TDA = pd.Series(name = str(EWR + '_totalEventDaysAchieved'), data = total_days_achieved, index = unique_water_years)
|
|
4902
|
-
PU_df = pd.concat([PU_df, TDA], axis = 1)
|
|
4902
|
+
# PU_df = pd.concat([PU_df, TDA], axis = 1)
|
|
4903
4903
|
# Max event days
|
|
4904
4904
|
max_days = get_max_event_days(events, unique_water_years)
|
|
4905
4905
|
MD = pd.Series(name = str(EWR + '_maxEventDays'), data = max_days, index = unique_water_years)
|
|
4906
|
-
PU_df = pd.concat([PU_df, MD], axis = 1)
|
|
4906
|
+
# PU_df = pd.concat([PU_df, MD], axis = 1)
|
|
4907
4907
|
# Max rolling consecutive event days
|
|
4908
4908
|
try:
|
|
4909
4909
|
max_consecutive_days = get_max_consecutive_event_days(events, unique_water_years)
|
|
4910
4910
|
MR = pd.Series(name = str(EWR + '_maxRollingEvents'), data = max_consecutive_days, index = unique_water_years)
|
|
4911
|
-
PU_df = pd.concat([PU_df, MR], axis = 1)
|
|
4911
|
+
# PU_df = pd.concat([PU_df, MR], axis = 1)
|
|
4912
4912
|
except Exception as e:
|
|
4913
4913
|
max_consecutive_days = [0]*len(unique_water_years)
|
|
4914
4914
|
MR = pd.Series(name = str(EWR + '_maxRollingEvents'), data = max_consecutive_days, index = unique_water_years)
|
|
4915
|
-
PU_df = pd.concat([PU_df, MR], axis = 1)
|
|
4915
|
+
# PU_df = pd.concat([PU_df, MR], axis = 1)
|
|
4916
4916
|
log.error(e)
|
|
4917
4917
|
# Max rolling duration achieved
|
|
4918
4918
|
achieved_max_rolling_duration = get_max_rolling_duration_achievement(durations, max_consecutive_days)
|
|
4919
4919
|
MRA = pd.Series(name = str(EWR + '_maxRollingAchievement'), data = achieved_max_rolling_duration, index = unique_water_years)
|
|
4920
|
-
PU_df = pd.concat([PU_df, MRA], axis = 1)
|
|
4920
|
+
# PU_df = pd.concat([PU_df, MRA], axis = 1)
|
|
4921
4921
|
# Append information around available and missing data:
|
|
4922
4922
|
yearly_gap = get_data_gap(df, water_years, gauge)
|
|
4923
4923
|
total_days = get_total_series_days(water_years)
|
|
4924
4924
|
YG = pd.Series(name = str(EWR + '_missingDays'), data = yearly_gap, index = unique_water_years)
|
|
4925
|
-
|
|
4926
|
-
PU_df = pd.concat([PU_df, YG], axis = 1)
|
|
4927
|
-
PU_df = pd.concat([PU_df, TD], axis = 1)
|
|
4925
|
+
TD_B = pd.Series(name = str(EWR + '_totalPossibleDays'), data = total_days, index = unique_water_years)
|
|
4926
|
+
# PU_df = pd.concat([PU_df, YG], axis = 1)
|
|
4927
|
+
# PU_df = pd.concat([PU_df, TD], axis = 1)
|
|
4928
|
+
PU_df = pd.concat(
|
|
4929
|
+
[PU_df,
|
|
4930
|
+
YWE,
|
|
4931
|
+
NEA,
|
|
4932
|
+
NE,
|
|
4933
|
+
NEALL,
|
|
4934
|
+
MIP,
|
|
4935
|
+
MIPA,
|
|
4936
|
+
AL,
|
|
4937
|
+
ALA,
|
|
4938
|
+
TD_A,
|
|
4939
|
+
TDA,
|
|
4940
|
+
MD,
|
|
4941
|
+
MR,
|
|
4942
|
+
MRA,
|
|
4943
|
+
YG,
|
|
4944
|
+
TD_B
|
|
4945
|
+
],
|
|
4946
|
+
axis=1
|
|
4947
|
+
)
|
|
4928
4948
|
|
|
4929
4949
|
return PU_df
|
|
4930
4950
|
|