Description: Excess rainfall is calculated using updated randomized curve numbers and the original precipitation events calculated in EventsTable.ipynb
. The events are then combined using the groups determined from the convolution steps in EventsTable.ipynb
.
Input:
Output:
import sys
sys.path.append('../../core')
import hydromet_distal
from hydromet import*
## Filenames and paths:
Project_Area = 'Test' # Project area name
Pluvial_Model = 'P01' # Pluvial model name
mainBCN = 'D30' # Domain/boundary condition name
pluvial_params = '{0}_{1}_Pluvial_Parameters.xlsx'.format(Project_Area, Pluvial_Model)
rate_column = 'SW Rate (in/30min)'
capacity_column = 'SW Capacity (in)'
efficiency_column = 'SW Efficiency'
root_dir = pl.Path(os.getcwd())
inputs_dir = root_dir/'Inputs'
outputs_dir = root_dir/'Outputs'
notebook_dir = root_dir/'Notebooks'
pluvial_params_dir = inputs_dir/pluvial_params
datarepository_dir = root_dir.parent.parent/'DataRepository'
## Options:
display_plots = True # Option to display plots
display_print = True # Option to display print statements
## Filenames and paths:
CN_Distribution = 'NEH630_Table_10_1.json'
## Options:
adjust_CN_less24 = False # Set to True to adjust the curve number when the storm duration is less than 24 hours
remove_intermediates = True
run_dur_dic = {'6': 1, '12': 1, '24': 2, '96': 5} # Run durations in days
pad_forcing = True # Specify whether to pad the forcing time series
uniform_pad = True # Uniform padding of length pad_num if True. If False, the number of zeros padded is determined by the run duration
pad_num = 2 # Number of zeros to pad to the forcing time series
start_time = time.time()
with open(outputs_dir/'{0}_{1}_{2}.json'.format(Project_Area, Pluvial_Model, mainBCN)) as f:
main = json.load(f)
durations = list(main.keys())
print('Durations:', durations)
Durations: ['H06', 'H12', 'H24', 'H96']
time_idx_ordinate = main[durations[0]]['time_idx_ordinate']
print('Time index ordinate:', time_idx_ordinate)
Time index ordinate: Hours
pluvial_BC_units = main[durations[0]]['pluvial_BC_units']
print('Pluvial boundary condition units:', pluvial_BC_units)
Pluvial boundary condition units: inch/ts
with open(outputs_dir/'{0}_{1}_{2}_Metadata.json'.format(Project_Area, Pluvial_Model, mainBCN)) as f:
md = json.load(f)
with open(outputs_dir/'{0}_{1}_{2}_Weights.json'.format(Project_Area, Pluvial_Model, mainBCN)) as f:
weights_dic = json.load(f)
pp = pd.read_excel(pluvial_params_dir, sheet_name = 'Pluvial_Domain')
pp.head(2)
Pluvial Domain | Shapefile | Curve Number | SW Infrastructure (YES or NO) | SW Rate (in/30min) | SW Capacity (in) | SW Efficiency | Comments | |
---|---|---|---|---|---|---|---|---|
0 | D23 | PluvialDomain_V5.shp | 69.457613 | NO | NaN | NaN | NaN | NaN |
1 | D24 | PluvialDomain_V5.shp | 85.285521 | YES | 0.57 | 4.25 | 0.75 | NaN |
distalBCNs = list(pp['Pluvial Domain'])
distalBCNs.remove(mainBCN)
print('All distal domains/boundary condition names:', distalBCNs)
All distal domains/boundary condition names: ['D23', 'D24', 'D25', 'D26', 'D27', 'D28', 'D29', 'D31', 'D32', 'D33', 'D34', 'D35']
count = 1
d_plots = False
for distalBCN in distalBCNs:
if (count/5).is_integer() or count == 1:
d_print = display_print
else:
d_print = False
if count == len(distalBCNs):
d_plots = display_plots
else:
d_plots = False
CN = get_CN(pluvial_params_dir, distalBCN, d_print)
arc_data = get_CN_distribution(datarepository_dir, CN_Distribution, CN, d_print)
hydromet_distal.main(md, weights_dic, durations, mainBCN, CN, arc_data, Project_Area, Pluvial_Model, distalBCN, outputs_dir,
time_idx_ordinate, run_dur_dic, pluvial_BC_units, adjust_CN_less24, remove_intermediates, d_print, d_plots,
pad_forcing, uniform_pad, pad_num)
count+=1
Pluvial Domain | Shapefile | Curve Number | SW Infrastructure (YES or NO) | SW Rate (in/30min) | SW Capacity (in) | SW Efficiency | Comments | |
---|---|---|---|---|---|---|---|---|
0 | D23 | PluvialDomain_V5.shp | 69.457613 | NO | NaN | NaN | NaN | NaN |
None {'Dry': 50, 'Wet': 84} Calculating excess rainfall and grouping the 6 hour duration for D23 Calculating excess rainfall and grouping the 12 hour duration for D23 Calculating excess rainfall and grouping the 24 hour duration for D23 Calculating excess rainfall and grouping the 96 hour duration for D23
Pluvial Domain | Shapefile | Curve Number | SW Infrastructure (YES or NO) | SW Rate (in/30min) | SW Capacity (in) | SW Efficiency | Comments | |
---|---|---|---|---|---|---|---|---|
4 | D27 | PluvialDomain_V5.shp | 83.27845 | NO | NaN | NaN | NaN | NaN |
None {'Dry': 67, 'Wet': 93} Calculating excess rainfall and grouping the 6 hour duration for D27 Calculating excess rainfall and grouping the 12 hour duration for D27 Calculating excess rainfall and grouping the 24 hour duration for D27 Calculating excess rainfall and grouping the 96 hour duration for D27
Pluvial Domain | Shapefile | Curve Number | SW Infrastructure (YES or NO) | SW Rate (in/30min) | SW Capacity (in) | SW Efficiency | Comments | |
---|---|---|---|---|---|---|---|---|
10 | D33 | PluvialDomain_V5.shp | 80.130711 | NO | NaN | NaN | NaN | NaN |
None {'Dry': 63, 'Wet': 91} Calculating excess rainfall and grouping the 6 hour duration for D33 Calculating excess rainfall and grouping the 12 hour duration for D33 Calculating excess rainfall and grouping the 24 hour duration for D33 Calculating excess rainfall and grouping the 96 hour duration for D33
count = 1
for distalBCN in distalBCNs:
if (count/5).is_integer() or count == 1:
d_print = display_print
else:
d_print = False
if count == len(distalBCNs):
d_plots = display_plots
else:
d_plots = False
run_reduced = checkif_SWinfra(pluvial_params_dir, distalBCN, d_print)
if run_reduced == 'YES':
reEventsTable = str(notebook_dir/'reEventsTable_{0}_{1}_{2}.ipynb'.format(Project_Area, Pluvial_Model, distalBCN))
nb_parameters = {'Project_Area': Project_Area, 'Pluvial_Model': Pluvial_Model, 'BCN': distalBCN, 'pluvial_params_dir': str(pluvial_params_dir),
'rate_column': rate_column, 'capacity_column': capacity_column, 'efficiency_column': efficiency_column,
'outputs_dir': str(outputs_dir), 'display_plots': display_plots, 'display_print': display_print}
pm.execute_notebook('reEventsTable.ipynb', reEventsTable, parameters = nb_parameters);
! jupyter nbconvert $reEventsTable --log-level WARN
count+=1
Is there stormwater infrastructure? -> NO
HBox(children=(IntProgress(value=0, max=35), HTML(value='')))
HBox(children=(IntProgress(value=0, max=35), HTML(value='')))
Is there stormwater infrastructure? -> NO
HBox(children=(IntProgress(value=0, max=35), HTML(value='')))
Is there stormwater infrastructure? -> NO
orig_nb = 'distalEventsTable'
new_nb = '{0}_{1}_{2}_{3}.ipynb'.format(orig_nb, Project_Area, Pluvial_Model, mainBCN)
new_nb_path = str(notebook_dir/new_nb)
shutil.copy(pl.Path(os.getcwd())/'{0}.ipynb'.format(orig_nb), new_nb_path)
! jupyter nbconvert $new_nb_path --log-level WARN
if display_print: print('Runtime: {} Minutes'.format(round(time.time()-start_time)/60, 3))
Runtime: 33.45 Minutes