pywrdrb.ModelBuilder#
- class pywrdrb.ModelBuilder(inflow_type, start_date, end_date, options={}, input_dir=None, model_data_dir=None)#
- __init__(inflow_type, start_date, end_date, options={}, input_dir=None, model_data_dir=None)#
ModelBuilder class to construct a pywr model for the Delaware River Basin. Essentially, this class creates model dictionary to hold all model nodes, edges, params, etc, following Pywr protocol. The model dictionary will be saved to a JSON file.
- Parameters:
inflow_type (str) – Type of inflow data to use. Options are ‘nhmv10_withObsScaled’, ‘nwmv21_withObsScaled’, ‘nhmv10’, and ‘nwmv21’.
start_date (str) – Start date of the model simulation.
end_date (str) – End date of the model simulation.
options (dict, optional) – Dictionary of options to pass to the model builder. Options include: inflow_ensemble_indices (list of int): List of indices to use for inflow ensemble scenarios. use_hist_NycNjDeliveries (bool): If True, we use historical NYC/NJ deliveries as demand, else we use predicted demand. Otherwise, assume demand is equal to max allotment under FFMP. predict_temperature (bool): If True, we use LSTM model to predict temperature at Lordville. temperature_torch_seed (int): Seed for torch random number generator for temperature LSTM model. predict_salinity (bool): If True, we use LSTM model to predict salinity at Trenton. salinity_torch_seed (int): Seed for torch random number generator for salinity LSTM model. run_starfit_sensitivity_analysis (bool): If True, we run STARFIT sensitivity analysis. sensitivity_analysis_scenarios (list of str): List of scenarios to use for STARFIT sensitivity analysis. initial_volume_frac (float): Initial reservoir storage as a fraction of capacity. Default is 0.8.
input_dir (str, optional) – Directory where input data is stored. Default is None.
model_data_dir (str, optional) – Directory where model data is stored. Default is None.
Methods
__init__
(inflow_type, start_date, end_date)ModelBuilder class to construct a pywr model for the Delaware River Basin.
add_ensemble_inflow_scenarios
(...)add_node_final_basin_outlet
()add_node_major_reservoir
(reservoir_name, ...)Add a major reservoir node to the model.
add_node_major_river
(name, downstream_lag, ...)add_node_nyc_aggregated_storage_and_link
()add_node_nyc_and_nj_deliveries
()add_parameter_couple_salinity_lstm
()add_parameter_couple_temp_lstm
()add_parameter_montague_trenton_flow_targets
()add_parameter_nyc_and_nj_delivery_constraints
()add_parameter_nyc_and_nj_demands
()Add nyc and nj demands to model parameters.
add_parameter_nyc_reservoirs_aggregated_info
()add_parameter_nyc_reservoirs_balancing_methods
()add_parameter_nyc_reservoirs_current_volume
()add_parameter_nyc_reservoirs_flood_control
()add_parameter_nyc_reservoirs_min_require_flow
()add_parameter_nyc_reservoirs_operational_regimes
()add_parameter_nyc_reservoirs_variable_cost_based_on_fractional_storage
()add_parameter_predicted_lagged_non_nyc_inflows_to_Montague_and_Trenton_and_lagged_nj_demands
()detach_data
()Detach data from the model builder to release memory.
make_model
()reset_model_dict
()write_model
(model_filename)Write the model to a JSON file.