Skip to content

Commit 1509a29

Browse files
committed
Add rainfall intensity calculation function
1 parent 5827aac commit 1509a29

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

physics/rainfall_intensity.py

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
"""
2+
Rainfall Intensity
3+
==================
4+
This module contains functions to calculate the intensity of
5+
a rainfall event for a given duration and return period.
6+
"""
7+
8+
9+
def rainfall_intensity(
10+
k: float, a: float, b: float, c: float, tr: float, t: float
11+
) -> float:
12+
"""
13+
Calculate the intensity of a rainfall event for a given duration and return period.
14+
The coefficients K, a, b, and c are obtained from the Sherman
15+
intensity-duration-frequency curve for a specific location.
16+
17+
Parameters
18+
----------
19+
k : float
20+
Coefficient [adm].
21+
a : float
22+
Coefficient [adm].
23+
b : float
24+
Coefficient [adm].
25+
c : float
26+
Coefficient [adm].
27+
tr : float
28+
Return period in years.
29+
t : float
30+
Rainfall event duration in minutes.
31+
32+
Returns
33+
-------
34+
intensity : float
35+
Intensity of the rainfall event in mm/h.
36+
37+
References
38+
----------
39+
- Aparicio, F. (1997): Fundamentos de Hidrología de Superficie.
40+
Balderas, México, Limusa. 303 p.
41+
- https://en.wikipedia.org/wiki/Intensity-duration-frequency_curve
42+
43+
Examples
44+
--------
45+
46+
>>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 10, 60)
47+
49.83339231138578
48+
49+
>>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 10, 30)
50+
77.36319588106228
51+
52+
>>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 5, 60)
53+
43.382487747633625
54+
55+
>>> rainfall_intensity(0, 0.2, 11.6, 0.81, 10, 60)
56+
Traceback (most recent call last):
57+
...
58+
ValueError: Please ensure that all parameters are positive.
59+
60+
>>> rainfall_intensity(1000, -0.2, 11.6, 0.81, 10, 60)
61+
Traceback (most recent call last):
62+
...
63+
ValueError: Please ensure that all parameters are positive.
64+
65+
>>> rainfall_intensity(1000, 0.2, -11.6, 0.81, 10, 60)
66+
Traceback (most recent call last):
67+
...
68+
ValueError: Please ensure that all parameters are positive.
69+
70+
>>> rainfall_intensity(1000, 0.2, 11.6, -0.81, 10, 60)
71+
Traceback (most recent call last):
72+
...
73+
ValueError: Please ensure that all parameters are positive.
74+
75+
>>> rainfall_intensity(1000, 0, 11.6, 0.81, 10, 60)
76+
Traceback (most recent call last):
77+
...
78+
ValueError: Please ensure that all parameters are positive.
79+
80+
>>> rainfall_intensity(1000, 0.2, 0, 0.81, 10, 60)
81+
Traceback (most recent call last):
82+
...
83+
ValueError: Please ensure that all parameters are positive.
84+
85+
>>> rainfall_intensity(1000, 0.2, 11.6, 0, 10, 60)
86+
Traceback (most recent call last):
87+
...
88+
ValueError: Please ensure that all parameters are positive.
89+
90+
>>> rainfall_intensity(0, 0.2, 11.6, 0.81, 10, 60)
91+
Traceback (most recent call last):
92+
...
93+
ValueError: Please ensure that all parameters are positive.
94+
95+
>>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 0, 60)
96+
Traceback (most recent call last):
97+
...
98+
ValueError: Please ensure that all parameters are positive.
99+
100+
>>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 10, 0)
101+
Traceback (most recent call last):
102+
...
103+
ValueError: Please ensure that all parameters are positive.
104+
105+
"""
106+
if k <= 0 or a <= 0 or b <= 0 or c <= 0 or tr <= 0 or t <= 0:
107+
raise ValueError("Please ensure that all parameters are positive.")
108+
intensity = (k * (tr**a)) / ((t + b) ** c)
109+
return intensity
110+
111+
112+
if __name__ == "__main__":
113+
import doctest
114+
115+
doctest.testmod()

0 commit comments

Comments
 (0)