|
| 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 | +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 |
| 14 | +""" |
| 15 | + |
| 16 | + |
| 17 | +def rainfall_intensity( |
| 18 | + coefficient_k: float, |
| 19 | + coefficient_a: float, |
| 20 | + coefficient_b: float, |
| 21 | + coefficient_c: float, |
| 22 | + return_period: float, |
| 23 | + duration: float, |
| 24 | +) -> float: |
| 25 | + """ |
| 26 | + Calculate the intensity of a rainfall event for a given duration and return period. |
| 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 |
| 36 | +
|
| 37 | + Parameters |
| 38 | + ---------- |
| 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 |
| 48 | + Return period in years. |
| 49 | + duration : float |
| 50 | + Rainfall event duration in minutes. |
| 51 | +
|
| 52 | + Returns |
| 53 | + ------- |
| 54 | + intensity : float |
| 55 | + Intensity of the rainfall event in mm/h. |
| 56 | +
|
| 57 | + Raises |
| 58 | + ------ |
| 59 | + ValueError |
| 60 | + If any of the parameters are not positive. |
| 61 | +
|
| 62 | + Examples |
| 63 | + -------- |
| 64 | +
|
| 65 | + >>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 10, 60) |
| 66 | + 49.83339231138578 |
| 67 | +
|
| 68 | + >>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 10, 30) |
| 69 | + 77.36319588106228 |
| 70 | +
|
| 71 | + >>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 5, 60) |
| 72 | + 43.382487747633625 |
| 73 | +
|
| 74 | + >>> rainfall_intensity(0, 0.2, 11.6, 0.81, 10, 60) |
| 75 | + Traceback (most recent call last): |
| 76 | + ... |
| 77 | + ValueError: All parameters must be positive. |
| 78 | +
|
| 79 | + >>> rainfall_intensity(1000, -0.2, 11.6, 0.81, 10, 60) |
| 80 | + Traceback (most recent call last): |
| 81 | + ... |
| 82 | + ValueError: All parameters must be positive. |
| 83 | +
|
| 84 | + >>> rainfall_intensity(1000, 0.2, -11.6, 0.81, 10, 60) |
| 85 | + Traceback (most recent call last): |
| 86 | + ... |
| 87 | + ValueError: All parameters must be positive. |
| 88 | +
|
| 89 | + >>> rainfall_intensity(1000, 0.2, 11.6, -0.81, 10, 60) |
| 90 | + Traceback (most recent call last): |
| 91 | + ... |
| 92 | + ValueError: All parameters must be positive. |
| 93 | +
|
| 94 | + >>> rainfall_intensity(1000, 0, 11.6, 0.81, 10, 60) |
| 95 | + Traceback (most recent call last): |
| 96 | + ... |
| 97 | + ValueError: All parameters must be positive. |
| 98 | +
|
| 99 | + >>> rainfall_intensity(1000, 0.2, 0, 0.81, 10, 60) |
| 100 | + Traceback (most recent call last): |
| 101 | + ... |
| 102 | + ValueError: All parameters must be positive. |
| 103 | +
|
| 104 | + >>> rainfall_intensity(1000, 0.2, 11.6, 0, 10, 60) |
| 105 | + Traceback (most recent call last): |
| 106 | + ... |
| 107 | + ValueError: All parameters must be positive. |
| 108 | +
|
| 109 | + >>> rainfall_intensity(0, 0.2, 11.6, 0.81, 10, 60) |
| 110 | + Traceback (most recent call last): |
| 111 | + ... |
| 112 | + ValueError: All parameters must be positive. |
| 113 | +
|
| 114 | + >>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 0, 60) |
| 115 | + Traceback (most recent call last): |
| 116 | + ... |
| 117 | + ValueError: All parameters must be positive. |
| 118 | +
|
| 119 | + >>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 10, 0) |
| 120 | + Traceback (most recent call last): |
| 121 | + ... |
| 122 | + ValueError: All parameters must be positive. |
| 123 | +
|
| 124 | + """ |
| 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 | + ) |
| 137 | + return intensity |
| 138 | + |
| 139 | + |
| 140 | +if __name__ == "__main__": |
| 141 | + import doctest |
| 142 | + |
| 143 | + doctest.testmod() |
0 commit comments