duration_above_threshold function

Duration above/below threshold or within threshold range