Skip to content

Commit 13f2e3a

Browse files
committed
chore: improve fuction and coefficient documentation
1 parent 1509a29 commit 13f2e3a

File tree

1 file changed

+49
-21
lines changed

1 file changed

+49
-21
lines changed

physics/rainfall_intensity.py

+49-21
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,61 @@
33
==================
44
This module contains functions to calculate the intensity of
55
a rainfall event for a given duration and return period.
6+
7+
This function uses the Sherman intensity-duration-frequency curve.
8+
9+
References
10+
----------
11+
- Aparicio, F. (1997): Fundamentos de Hidrología de Superficie.
12+
Balderas, México, Limusa. 303 p.
13+
- https://en.wikipedia.org/wiki/Intensity-duration-frequency_curve
614
"""
715

816

917
def rainfall_intensity(
10-
k: float, a: float, b: float, c: float, tr: float, t: float
18+
coefficient_k: float,
19+
coefficient_a: float,
20+
coefficient_b: float,
21+
coefficient_c: float,
22+
return_period: float,
23+
duration: float,
1124
) -> float:
1225
"""
1326
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.
27+
It's based on the Sherman intensity-duration-frequency curve:
28+
29+
I = K * T^a / (D + b)^c
30+
31+
where:
32+
I = Intensity of the rainfall event [mm/h]
33+
k, a, b, c = Coefficients obtained through statistical distribution adjust
34+
T = Return period in years
35+
D = Rainfall event duration in minutes
1636
1737
Parameters
1838
----------
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
39+
coefficient_k : float
40+
Coefficient obtained through statistical distribution adjust.
41+
coefficient_a : float
42+
Coefficient obtained through statistical distribution adjust.
43+
coefficient_b : float
44+
Coefficient obtained through statistical distribution adjust.
45+
coefficient_c : float
46+
Coefficient obtained through statistical distribution adjust.
47+
return_period : float
2848
Return period in years.
29-
t : float
49+
duration : float
3050
Rainfall event duration in minutes.
3151
3252
Returns
3353
-------
3454
intensity : float
3555
Intensity of the rainfall event in mm/h.
3656
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
57+
Raises
58+
------
59+
ValueError
60+
If any of the parameters are not positive.
4261
4362
Examples
4463
--------
@@ -103,9 +122,18 @@ def rainfall_intensity(
103122
ValueError: Please ensure that all parameters are positive.
104123
105124
"""
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)
125+
if (
126+
coefficient_k <= 0
127+
or coefficient_a <= 0
128+
or coefficient_b <= 0
129+
or coefficient_c <= 0
130+
or return_period <= 0
131+
or duration <= 0
132+
):
133+
raise ValueError("All parameters must be positive.")
134+
intensity = (coefficient_k * (return_period**coefficient_a)) / (
135+
(duration + coefficient_b) ** coefficient_c
136+
)
109137
return intensity
110138

111139

0 commit comments

Comments
 (0)