period_above_threshold function

Length of longest continuous period above/below threshold