Base Functions¶
Calculation Methods¶
Functions to analyse the precipitations series based on the core method.
- idf_analysis.event_series_analysis.annual_series(rolling_sum_values, year_index)[source]¶
Create an annual series of the maximum overlapping sum per year and calculate the “u” and “w” parameters.
acc. to DWA-A 531 chap. 5.1.5
Gumbel distribution | https://en.wikipedia.org/wiki/Gumbel_distribution
- Parameters:
rolling_sum_values (numpy.ndarray) – Array with maximum rolling sum per event per year.
year_index (numpy.ndarray) – Array with year of the event.
- Returns:
Parameter u and w from the annual series for a specific duration step as a tuple.
- Return type:
- idf_analysis.event_series_analysis.calculate_u_w(file_input, duration_steps, series_kind)[source]¶
Statistical analysis for each duration step.
acc. to DWA-A 531 chap. 5.1
Save the parameters of the distribution function as interim results.
acc. to DWA-A 531 chap. 4.4: use the annual series only for measurement periods over 20 years
- Parameters:
file_input (pandas.Series) – precipitation data
duration_steps (list[int] | numpy.ndarray) – in minutes
series_kind (str) – ‘annual’ or ‘partial’
- Returns:
with key=durations and values=dict(u, w)
- Return type:
- idf_analysis.event_series_analysis.iter_event_series(file_input, duration_steps)[source]¶
Statistical analysis for each duration step.
acc. to DWA-A 531 chap. 5.1
Save the parameters of the distribution function as interim results.
- Parameters:
file_input (pandas.Series) – precipitation data
duration_steps (list[int] | numpy.ndarray) – in minutes
- Yields:
series – max rainfall intensity per event for each duration step
- idf_analysis.event_series_analysis.partial_series(rolling_sum_values, measurement_period)[source]¶
Create a partial series of the largest overlapping sums and calculate the “u” and “w” parameters.
acc. to DWA-A 531 chap. 5.1.4
Exponential distribution | https://en.wikipedia.org/wiki/Exponential_distribution
- Parameters:
rolling_sum_values (numpy.ndarray) – Array with maximum rolling sum per event.
measurement_period (float) – Measurement period in years.
- Returns:
parameter u and w from the partial series for a specific duration step as a tuple
- Return type:
- idf_analysis.parameter_formulations.folded_log_formulation(duration, param, case, param_mean=None, duration_mean=None)[source]¶
- Parameters:
duration
param
case
param_mean
duration_mean
Returns:
- idf_analysis.parameter_formulations.hyperbolic_formulation(duration: array, param: array, a_start=20.0, b_start=15.0, param_mean=None, duration_mean=None)[source]¶
Computes the hyperbolic formulation using the given parameters.
- Parameters:
duration (np.array) – Array of durations.
param (np.array) – Array of parameters.
a_start (float) – Initial value for ‘a’ parameter.
b_start (float) – Initial value for ‘b’ parameter.
param_mean (float, optional) – Mean value of parameters. Defaults to None.
duration_mean (float, optional) – Mean value of durations. Defaults to None.
- Returns:
Computed value of ‘a’ and ‘b’.
- Return type:
- class idf_analysis.idf_backend.IdfParameters(series_kind='partial', worksheet='KOSTRA', extended_durations=False)[source]¶
- classmethod from_interim_results_file(interim_results_fn, worksheet='KOSTRA')[source]¶
DEPRECIATED: for compatibility reasons. To use the old file and convert it to the new parameters file
- get_array_param(p, duration)[source]¶
- Parameters:
p (str) – name of the parameter ‘u’ or ‘w’
duration (numpy.ndarray) – in minutes
- Returns:
u, w
- Return type:
- measured_points(return_periods, max_duration=None)[source]¶
get the calculation results of the rainfall with u and w without the estimation of the formulation
Input and Output¶
Function for reading and writing files.
SWW Utils¶
Functions to help analyse data in a general way. Most of this function have been developed on the institute of urban water management at the university of technology Graz.
- idf_analysis.sww_utils.agg_events(events, series, agg='sum')[source]¶
- Parameters:
events (pandas.DataFrame) – table of events
series (pandas.Series) – time-series data
agg (str | function) – aggregation of time-series
- Returns:
result of function of every event
- Return type:
- idf_analysis.sww_utils.event_duration(events)[source]¶
calculate the event duration
- Parameters:
events (pandas.DataFrame) – table of events with COL.START and COL.END times
- Returns:
duration of each event
- Return type:
- idf_analysis.sww_utils.event_number_to_series(events, index)[source]¶
make a time-series where the value of the event number is paste to the <index>
- Parameters:
events (pandas.DataFrame)
index (pandas.DatetimeIndex)
- Return type:
- idf_analysis.sww_utils.guess_freq(date_time_index, default=Timedelta('0 days 00:01:00'))[source]¶
guess the frequency by evaluating the most often frequency
- Parameters:
date_time_index (pandas.DatetimeIndex) – index of a time-series
default (pandas.Timedelta)
- Returns:
frequency of the date-time-index
- Return type:
pandas.DateOffset
- idf_analysis.sww_utils.rain_bar_plot(rain, ax=None, color='#1E88E5', reverse=False, step='post', joinstyle='miter', capstyle='butt')[source]¶
Make a standard precipitation/rain plot.
- Parameters:
rain (pandas.Series)
ax (matplotlib.axes.Axes)
color (str)
reverse (bool)
step (str) – ‘mid’ ‘post’ pre’
- Returns:
rain plot
- Return type:
matplotlib.axes.Axes
- idf_analysis.sww_utils.rain_events(series, ignore_rain_below=0.01, min_gap=Timedelta('0 days 04:00:00'))[source]¶
get rain events as a table with start and end times
- Parameters:
series (pandas.Series) – rain series
ignore_rain_below (float) – where it is considered as rain
min_gap (pandas.Timedelta) – 4 hours of no rain between events
- Returns:
table of the rain events
- Return type:
- idf_analysis.sww_utils.resample_rain_series(series)[source]¶
- Parameters:
series (pandas.Series)
- Returns:
the resampled series AND the final frequency in minutes
- Return type:
Converter helper functions¶
Functions to help convert things and units.
- idf_analysis.little_helpers.delta2min(time_delta)[source]¶
convert timedelta to float in minutes
- Parameters:
time_delta (pandas.Timedelta, pandas.DateOffset)
- Returns:
the timedelta in minutes
- Return type:
- idf_analysis.little_helpers.duration_steps_readable(durations)[source]¶
convert the durations to a more readable form
- idf_analysis.little_helpers.height2rate(height_of_rainfall, duration)[source]¶
calculate the specific rain flow rate in [l/(s*ha)] if 2 array-like parameters are give, a element-wise calculation will be made. So the length of the array must be the same.
- idf_analysis.little_helpers.minutes_readable(minutes)[source]¶
convert the duration in minutes to a more readable form
- idf_analysis.little_helpers.rate2height(rain_flow_rate, duration)[source]¶
convert the rain flow rate to the height of rainfall in [mm] if 2 array-like parameters are give, a element-wise calculation will be made. So the length of the array must be the same.
Plotting helper functions¶
Functions to add or manipulate plotting figures.
- idf_analysis.plot_helpers.idf_bar_axes(ax, idf_table, return_period_colors={1: '#00ffff', 2: '#add8e6', 5: '#0000ff', 10: '#ffff00', 20: '#ffa500', 50: '#ff0000', 100: '#ff00ff'})[source]¶
create
- Parameters:
ax (matplotlib.pyplot.Axes)
idf_table (pandas.DataFrame)
return_period_colors (dict) – color of each return period {return period: color}
- Return type:
matplotlib.pyplot.Axes