def calc_fall_flush_durations(flow_data, wet_filter_data, date):
    duration_left = None
    duration_right = None
    duration = None
    if date:
        date = int(date)
        for (index_left, flow_left) in enumerate(reversed(flow_data[:date])):
            if (flow_left < wet_filter_data[(date - index_left)]):
                duration_left = index_left
                break
        for (index_right, flow_right) in enumerate(flow_data[date:]):
            if (flow_right < wet_filter_data[(date + index_right)]):
                duration_right = index_right
                break
        if (duration_left and duration_right):
            duration = (duration_left + duration_right)
        else:
            duration = None
    return duration
def calc_fall_flush_durations(flow_data, wet_filter_data, date):
    duration_left = None
    duration_right = None
    duration = None
    if date:
        date = int(date)
        for (index_left, flow_left) in enumerate(reversed(flow_data[:date])):
            if (flow_left < wet_filter_data[(date - index_left)]):
                duration_left = index_left
                break
        for (index_right, flow_right) in enumerate(flow_data[date:]):
            if (flow_right < wet_filter_data[(date + index_right)]):
                duration_right = index_right
                break
        if (duration_left and duration_right):
            duration = (duration_left + duration_right)
        else:
            duration = None
    return duration