diff --git a/idf_analysis/idf_class.py b/idf_analysis/idf_class.py index 5d36d7e..ab91e05 100644 --- a/idf_analysis/idf_class.py +++ b/idf_analysis/idf_class.py @@ -294,14 +294,15 @@ def get_duration(self, height_of_rainfall, return_period): return newton(lambda d: self.depth_of_rainfall(d, return_period) - height_of_rainfall, x0=1) # __________________________________________________________________________________________________________________ - def result_table(self, durations=None, return_periods=None, add_names=False): + def result_table(self, durations=None, return_periods=None, add_names=False, add_unit=True): """ Get an idf-table of rainfall depth with return periods as columns and durations as rows. Args: durations (list | numpy.ndarray): list of durations in minutes for the table return_periods (list): list of return periods in years for the table - add_names (bool): weather to use expressive names as index-&column-label + add_names (bool): weather to use expressive names as index- & column-label + add_unit (bool): weather to add units to index- & column-label Returns: pandas.DataFrame: idf table @@ -319,9 +320,10 @@ def result_table(self, durations=None, return_periods=None, add_names=False): result_table = pd.DataFrame(result_table, index=durations) if add_names: - result_table.index.name = 'duration (min)' + result_table.index.name = 'duration' + (' (min)' if add_unit else '') result_table.columns = pd.MultiIndex.from_tuples([(rp, round(1 / rp, 3)) for rp in result_table.columns]) - result_table.columns.names = ['return period (a)', 'frequency (1/a)'] + result_table.columns.names = ['return period' + (' (a)' if add_unit else ''), + 'frequency' + (' (1/a)' if add_unit else '')] return result_table #################################################################################################################### @@ -649,6 +651,21 @@ def add_max_intensities_to_events(self, events): events[f'max_sum_{duration:0.0f}'] = agg_events(events, sum_frame[duration], 'max').round(2) return events + def add_max_return_periods_pre_duration_to_events(self, events): + """ + Add the maximum return periods for all duration steps to the events table. + + Args: + events (pandas.DataFrame): events table + + Returns: + pandas.DataFrame: events table including the columns with the maximum return periods + """ + return_periods_frame = self.return_periods_frame + for duration in self.duration_steps: + events[f'max_return_period_{duration:0.0f}'] = agg_events(events, return_periods_frame[duration], 'max').round(2) + return events + #################################################################################################################### def event_report(self, filename, min_event_rain_sum=25, min_return_period=0.5, durations=None): """