A simple example of using the PyRQP library¶
Add the library to the path and import rqp
In [7]:
import sys
sys.path.append('../src/PyRQP/') # Path to the library code if not installed
import rqp
Prepare the data for the river and discharge flow and quality
In [8]:
# Set up data (Clifton STW)
rqp_data = {
"riv_flow_mean": 100,
"riv_flow_95pc": 20,
"dis_flow_mean": 20,
"dis_flow_sd": 8,
"riv_wq_mean": 2,
"riv_wq_sd": 1,
"dis_wq_mean": 15,
"dis_wq_sd": 7,
"corr_riv_dis_flow": 0.6,
"corr_riv_flow_wq": -0.3,
"corr_dis_flow_wq": -0.2,
"target_value": 6,
"target_pc": 0.9
}
Create a case study and run it as shown below
In [9]:
%%time
case = rqp.RiverQualityPlanner()
case.set_random_params(size=100000) # Optional
case.add_rqp_data(rqp_data)
case.calculate_downstream_concentration()
case.calculate_discharge_permit() # Only if a target has been set
case.get_stats()
# case.export_results(r"results.xlsx") # Export to excel file if desired
CPU times: total: 297 ms Wall time: 297 ms
Out[9]:
mean | std | 90pc | 95pc | 99pc | 99.5pc | cov | |
---|---|---|---|---|---|---|---|
riv_flow | 99.951257 | 93.495176 | 200.593719 | 267.428607 | 463.378501 | 574.784732 | 0.935408 |
dis_flow | 19.955546 | 7.955544 | 30.349277 | 34.917133 | 45.342075 | 50.012260 | 0.398663 |
riv_qual | 1.996556 | 1.000006 | 3.279178 | 3.889167 | 5.345516 | 6.023642 | 0.500866 |
dis_qual | 15.009708 | 6.998242 | 24.068877 | 28.207937 | 37.950630 | 42.489107 | 0.466248 |
ds_flow | 119.906803 | 98.056450 | 226.845576 | 295.633356 | 498.468296 | 612.834816 | 0.817772 |
ds_qual | 4.737805 | 2.268376 | 7.610431 | 8.961600 | 12.380569 | 14.069518 | 0.478782 |
ds_qual_target | 3.815179 | 1.704521 | 5.999879 | 6.990539 | 9.400879 | 10.590069 | 0.446773 |
dis_qual_target | 10.705074 | 4.991216 | 17.166164 | 20.118182 | 27.066768 | 30.303655 | 0.466248 |