Skip to content

Commit

Permalink
fix: limit duration steps based on series frequency and skip paramete…
Browse files Browse the repository at this point in the history
…r calculation for durations ranges lower than series frequency.
  • Loading branch information
MarkusPic committed Aug 12, 2024
1 parent 0fe8471 commit 22e9a19
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions idf_analysis/idf_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ def _set_default_durations(self, extended_durations=False):

def filter_durations(self, freq_minutes):
self.limit_duration(lowest=freq_minutes)
self.limit_durations_from_freq(freq_minutes)

def limit_duration(self, lowest=None, highest=None):
bool_array = self.durations == False
# bool_array = self.durations == False
bool_array = np.array([False]*self.durations.size)
if lowest is not None:
bool_array |= self.durations >= lowest
if highest is not None:
Expand All @@ -109,6 +111,12 @@ def limit_duration(self, lowest=None, highest=None):
if param in self.parameters_series:
self.parameters_series[param] = self.parameters_series[param][bool_array]

def limit_durations_from_freq(self, freq_minutes):
# only multiple of freq
# Aus DWA-M 531 Abschnitt 2:
# > Da Niederschlagsmesser Tageswerte liefern, sind hier nur Auswertungen für Regendauern möglich, die ein Vielfaches von 24 h betragen.
self.durations = self.durations[(self.durations % freq_minutes) == 0]

def set_parameter_approaches_from_worksheet(self, worksheet):
"""
Set approaches depending on the duration and the parameter.
Expand Down Expand Up @@ -151,7 +159,7 @@ def _calc_params(self, params_mean=None, duration_mean=None):
for dur_lower_bound, dur_upper_bound in self._iter_params():
param_part = (self.durations >= dur_lower_bound) & (self.durations <= dur_upper_bound)

if param_part.sum() == 1:
if param_part.sum() <= 1:
del self.parameters_final[dur_lower_bound]
# Only one duration step in this duration range.
# Only one value available in the series for this regression.
Expand Down

0 comments on commit 22e9a19

Please sign in to comment.