Duration
Definition
Steps
for column_number, _ in enumerate(matrix[0]): flow_data = matrix[:, column_number] peak_flows.append(np.nanmax(flow_data)) for percentile in peak_percentiles: peak_exceedance_values.append(np.nanpercentile(peak_flows, 100 - percentile))"""Init current flow object""" for percent in exceedance_percent: exceedance_object[percent] = [] exceedance_duration[percent] = [] current_flow_object[percent] = None """Loop through each flow value for the year to check if they pass exceedance threshold""" for row_number, flow_row in enumerate(matrix[:, column_number]): for percent in exceedance_percent: if bool(flow_row < exceedance_value[percent] and current_flow_object[percent]) or bool(row_number == len(matrix[:, column_number]) - 1 and current_flow_object[percent]): """End of an object if it falls below threshold, or end of column""" current_flow_object[percent].end_date = row_number + 1 current_flow_object[percent].get_max_magnitude() exceedance_duration[percent].append(current_flow_object[percent].duration) current_flow_object[percent] = Noneclass FlowExceedance: def __init__(self, start_date, end_date, duration, exceedance): self.start_date = start_date self.end_date = end_date self.duration = duration self.flow = [] self.exceedance = exceedance def add_flow(self, flow_data): self.flow.append(flow_data)
Last updated