Timing
Definition
Steps
"""Append each column with 30 more days from next column, except the last column""" if column_number != len(matrix[0])-1: flow_data = list(matrix[:,column_number]) + list(matrix[:100,column_number+1]) else: flow_data = matrix[:, column_number]flow_data = replace_nan(flow_data) smooth_data = gaussian_filter1d(flow_data, sigma) spl = ip.UnivariateSpline(x_axis, smooth_data, k=3, s=3) spl_first = spl.derivative(1)"""Find the major peaks of the filtered data""" mean_flow = np.nanmean(flow_data) maxarray, minarray = peakdet(smooth_data, mean_flow * peak_sensitivity) """Set search range after last smoothed peak flow""" for flow_index in reversed(maxarray): if int(flow_index[0]) < max_peak_flow_date: max_flow_index = int(flow_index[0]) break"""Set a magnitude threshold below which start of summer can begin""" min_flow_data = min(smooth_data[max_flow_index:366]) threshold = min_flow_data + (smooth_data[max_flow_index] - min_flow_data) * min_summer_flow_percent"""Search criteria: derivative is under rate of change threshold, date is after last major peak, and flow is less than specified percent of smoothed max flow""" if abs(spl_first(index)) < max_flow_data * current_sensitivity and index > max_flow_index and data < threshold: start_dates[-1] = index break
Last updated