Package: py-ewr
EWR tool version 2.1.0 READMENotes on recent updatesAbility to pass a climte categorisation file has been removed. No EWRs require climate categorisation anymore so this feature was redundant.Ability to pass an allowance on some parts of the parameter sheet. This feature was not transparent and resulted in some counter-intuitive results in many cases so the feature has been removed during this update. If users are interested in assessing partial success through an allowance feature we recommend downloading the parameter sheet, making the required modifications (e.g. multiplying the duration column by a factor of 0.9 to simulate a 10% allowance), and running the EWR tool with this.Ability to pass multiple model scenarios to the package has been removed. It is recommended to use an alternative method if you want to send multiple scenarios to the package. An example has been provided below by calling the EWR tool package in a loop. This has been implemented because some scenarios may have multiple different files and this was the cleanest way to account for this.InstallationNote - requires Python 3.8 or newerStep 1.
Upgrade pippython-mpipinstall–-upgradepipStep 2.pipinstallpy-ewrOption 1: Running the observed mode of the toolThe EWR tool will use a second program called gauge getter to first download the river data at the locations and dates selected and then run this through the EWR toolfromdatetimeimportdatetime#USER INPUT REQUIRED>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>dates={'start_date':datetime(YYYY,7,1),'end_date':datetime(YYYY,6,30)}gauges=['Gauge1','Gauge2']# END USER INPUT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<frompy_ewr.observed_handlingimportObservedHandler# Running the EWR tool:ewr_oh=ObservedHandler(gauges=gauges,dates=dates)# Generating tables:# Table 1: Summarised EWR results for the entire timeseriesewr_results=ewr_oh.get_ewr_results()# Table 2: Summarised EWR results, aggregated to water years:yearly_ewr_results=ewr_oh.get_yearly_ewr_results()# Table 3: All events details regardless of durationall_events=ewr_oh.get_all_events()# Table 4: Inverse of Table 3 showing the interevent periodsall_interEvents=ewr_oh.get_all_interEvents()# Table 5: All events details that also meet the duration requirement:all_successfulEvents=ewr_oh.get_all_successful_events()# Table 6: Inverse of Table 5 showing the interevent periods:all_successful_interEvents=ewr_oh.get_all_successful_interEvents()Option 2: Running model scenarios through the EWR toolTell the tool where the model files are (can either be local or in a remote location)Tell the tool what format the model files are in (Current model format options: 'Bigmod - MDBA', 'Source - NSW (res.csv)', 'IQQM - NSW 10,000 years' - see manual for formatting requirements)#USER INPUT REQUIRED>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>># Minimum 1 scenario and 1 related file requiredscenarios={'Scenario1':['file/location/1','file/location/2','file/location/3'],'Scenario2':['file/location/1','file/location/2','file/location/3']}model_format='Bigmod - MDBA'# END USER INPUT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<frompy_ewr.scenario_handlingimportScenarioHandlerimportpandasaspdewr_results_dict={}yearly_results_dict={}all_events_dict={}all_interEvents_dict={}all_successful_Events_dict={}all_successful_interEvents_dict={}forscenario_name,scenario_listinscenarios.items():ewr_results=pd.DataFrame()yearly_ewr_results=pd.DataFrame()all_events=pd.DataFrame()all_interEvents=pd.DataFrame()all_successful_Events=pd.DataFrame()all_successful_interEvents=pd.DataFrame()forfileinscenarios[scenario_name]:# Running the EWR tool:ewr_sh=ScenarioHandler(scenario_file=file,model_format=model_format)# Return each table and stitch the different files of the same scenario together:# Table 1: Summarised EWR results for the entire timeseriestemp_ewr_results=ewr_sh.get_ewr_results()ewr_results=pd.concat([ewr_results,temp_ewr_results],axis=0)# Table 2: Summarised EWR results, aggregated to water years:temp_yearly_ewr_results=ewr_sh.get_yearly_ewr_results()yearly_ewr_results=pd.concat([yearly_ewr_results,temp_yearly_ewr_results],axis=0)# Table 3: All events details regardless of durationtemp_all_events=ewr_sh.get_all_events()all_events=pd.concat([all_events,temp_all_events],axis=0)# Table 4: Inverse of Table 3 showing the interevent periodstemp_all_interEvents=ewr_sh.get_all_interEvents()all_interEvents=pd.concat([all_interEvents,temp_all_interEvents],axis=0)# Table 5: All events details that also meet the duration requirement:temp_all_successfulEvents=ewr_sh.get_all_successful_events()all_successful_Events=pd.concat([all_successful_Events,temp_all_successfulEvents],axis=0)# Table 6: Inverse of Table 5 showing the interevent periods:temp_all_successful_interEvents=ewr_sh.get_all_successful_interEvents()all_successful_interEvents=pd.concat([all_successful_interEvents,temp_all_successful_interEvents],axis=0)# Optional code to output results to csv files:ewr_results.to_csv(scenario_name+'all_results.csv')yearly_ewr_results.to_csv(scenario_name+'yearly_ewr_results.csv')all_events.to_csv(scenario_name+'all_events.csv')all_interEvents.to_csv(scenario_name+'all_interevents.csv')all_successful_Events.to_csv(scenario_name+'all_successful_Events.csv')all_successful_interEvents.to_csv(scenario_name+'all_successful_interEvents.csv')# Save the final tables to the dictionaries:ewr_results_dict[scenario_name]=ewr_resultsyearly_results_dict[scenario_name]=yearly_ewr_resultsall_events_dict[scenario_name]=all_events_dictall_interEvents_dict[scenario_name]=all_interEventsall_successful_Events_dict[scenario_name]=all_successful_Eventsall_successful_interEvents_dict[scenario_name]=all_successful_interEventsPurposeThis tool has two purposes:Operational: Tracking EWR success at gauges of interest in real time - option 1 above.Planning: Comparing EWR success between scenarios (i.e. model runs) - option 2 above.SupportFor issues relating to the script, a tutorial, or feedback please contact Lara Palmer atlara.palmer@mdba.gov.au, Martin Job atmartin.job@mdba.gov.au, or Joel Bailey atjoel.bailey@mdba.gov.auDisclaimerEvery effort has been taken to ensure the EWR database represents the original EWRs from state long term water plans as best as possible, and that the code within this tool has been developed to interpret and analyse these EWRs in an accurate way. However, there may still be unresolved bugs in the EWR parameter sheet and/or EWR tool. Please report any bugs to the issues tab under the GitHub project so we can investigate further.Notes on development of the dataset of EWRsThe MDBA has worked with Basin state representatives to ensure scientific integrity of EWRs has been maintained when translating from raw EWRs in the Basin state Long Term Water Plans (LTWPs) to the machine readable format found in the parameter sheet within this tool.CompatibilityNSW:All Queensland catchmentsAll New South Wales catchmentsAll South Australian catchmentsAll EWRs from river based Environmental Water Management Plans (EWMPs) in Victoria**Currently the wetland EWMPS and mixed wetland-river EWMPs in Victoria contain EWRs that cannot be evaluated by an automated EWR tool so the EWRs from these plans have been left out for now. The MDBA will work with our Victorian colleagues to ensure any updated EWRs in these plans are integrated into the tool where possible.Input dataGauge data from the relevant Basin state websites and the Bureau of Meteorology websiteScenario data input by the userModel metadata for location association between gauge ID's and model nodesEWR parameter sheetRunning the toolConsult the user manual for instructions on how to run the tool. Please email the above email addresses for a copy of the user manual.