Sequent Peak Algorithm for the design and simulation of water reservoirs
Project description
sequent-peak-algorithm
Python implementation of the Sequent Peak Algorithm for the design and simulation of water reservoirs in hydrology.
Installation with requirements
pip install numpy==1.26.2
pip install matplotlib==3.8.2
pip install sequent-peak-algorithm==0.0.2
Usage example
import pandas as pd
import matplotlib.pyplot as plt
import sequent_peak_algorithm.sequent_peak_algorithm as spa
# 1. Read raw data and extract data to lists
df = pd.read_csv('examples/example_1_raw_data.csv')
df = df.iloc[:150]
months = df["month"].tolist()
q_in = df["Q_in_hm3"].tolist()
q_out = df["Q_out_hm3"].tolist()
# 2. Run sequent peak algorithm
res_cap = spa.spa(q_in=q_in, q_out=q_out)
# 3. Plot results from sequent peak algorithm
fig_cap = spa.spa_plot(res_cap)
plt.savefig("examples/example_1_spa.png", dpi=300)
# 4. Simulate reservoir
res_sim = spa.sim(
q_in=q_in,
q_out=q_out,
initial_storage=0.0,
capacity=res_cap.capacity
)
# 5. Plot results from simulation
fig_sim = spa.sim_plot(res_sim)
plt.savefig("examples/example_1_sim.png", dpi=300)
For further explanations see the examples/example_1.ipynb folder.
Sequent Peak Algorithm Visualization
Simulation Visualization
Documentation
spa
Parameters
q_in: list[float]
: discharge input valuesq_out: list[float]
: discharge output values
Returns
Result: collections.namedtuple
: Result of the sequent peak algorithm with the following attributes:q_in: list[float]
: discharge input valuesq_out: list[float]
: discharge output valuesstorage: list[float]
: storage values, calculated with_storage
cumulative_storage: list[float]
: cumulative storage values, calculated with_cumulative_storage
max_vals: list[float]
: discharge values of the maxima, calculated with_maxima
max_indices: list[int]
: indices of the maxima, calculated with_maxima
min_vals: list[float]
: discharge values of the minima, calculated with_minima
min_indices: list[int]
: indices of the minima, calculated with_minima
capacity: list[float]
: capacity, calculated with_capacity
capacity_indices: list[int]
: indices of the capacity (multiple positions possible), calculated with_capacity
capacity_max_vals: list[float]
: preceeding maxima of the capacity, calculated with_capacity
capacity_max_indices: list[int]
: indices of the preceeding maxima of the capacity, calculated with_capacity
capacity_min_vals: list[float]
: succeeding minima of the capacity, calculated with_capacity
capacity_min_indices: list[int]
: indices of the succeeding minima of the capacity, calculated with_capacity
sim
Parameters
q_in: list[float]
: discharge input valuesq_out: list[float]
: discharge output valuesinitial_storage: float
: initial storage value, chosen by the usercapacity: float
: capacity values, calculated withspa
or chosen by the user
Returns
Result: collections.namedtuple
: Result of the sequent peak algorithm with the following attributes:q_in: list[float]
: discharge input valuesq_out: list[float]
: discharge output valuesinitial_storage: float
: initial storage value, chosen by the usercapacity: list[float]
: capacity values, calculated withspa
or chosen by the userq_out_real: list[float]
: real discharge output accounting for the capacity (deficit and overflow situations)storage: list[float]
: storage valuesdeficit: list[float]
: deficit valuesoverflow: list[float]
: overflow values
spa_plot
Parameters
Result: collections.namedtuple
: Result of the sequent peak algorithm
Returns
fig: matplotlib.figure.Figure
: Figure object of the plot
sim_plot
Parameters
Result: collections.namedtuple
: Result of the storage simulation
Returns
fig: matplotlib.figure.Figure
: Figure object of the plot
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for sequent_peak_algorithm-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 632af4cb66624324604466d67cf05f92572b2260bce65d2f4cdd04f69dd4d261 |
|
MD5 | fc08753eb441f5531ef01618ad1008db |
|
BLAKE2b-256 | 593fa6f67f1b99f696fcc582811c04dff2b09c045c7928de242ca6f5b514146b |
Close
Hashes for sequent_peak_algorithm-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0e71e2d954bf1a47ef9a97748af72c0d10d8aade6acc0b264411a8ae5823be5 |
|
MD5 | f06280e37e73fac87bc7f1d94473acb0 |
|
BLAKE2b-256 | 0a0f62e6c5f3c9e91cd70a8936e68ade3928d5d27fd9efcc8e8ffe79f6e459c0 |