Algorithm for detecting the time where the signal is above a threshold I need to detect the time window where a 1D-signal is above a certain threshold. If it dips below the threshold briefly I'd like to merge the two windows, if it dips below for a longer time, split them. The data are received digitally as array $S[t]$ with equally-spaced $t$ intervals and represent precipitation forecasts from a weather model.

I want to find $t_{on}$ / $t_{off}$ in signals like the following:




I know this isn't terribly hard and I can probably come up with an algorithm myself, but I thought this is a problem that smarter people than me have already thought about.

The algorithm will be implemented in software and run on general-purpose datacenter servers (no specialised hardware). It doesn't have to be crazy fast, "reasonable" is good enough (we have a few 100k time series to process at once every now and then; each series has probably less then 1000 points).

I'd welcome algorithm suggestions, Google keywords, book/article recommendations. I'm rather new to data processing, in case it isn't blatantly obvious.

Edit:
Thanks everyone for the great comments and answers. This question really couldn't have turned out much better. What I'm worrying about the most is how to handle pathological cases, like "oscillations" around the threshold.




My own idea was having separate on/off-thresholds, with $ thresh_{off} = f * thresh_{on} $ (with $f$ in the range of [0.5, 0.99]). I also really like Marten's idea of temporarily modifying the threshold value after the signal crosses the threshold in a hysteresis-like manner.

Are there other strategies to handle this issue that I should know about?

Are there other potential issues that I need to know about?
There is a book by Basseville and Nikiforov called "Detection of Abrupt Changes : Theory and Application" that they released to the public as a PDF several years ago (it's out of print, now, I believe).

That book looks at the basic CUSUM (cumulative sum) algorithm and how to choose appropriate thresholds for it.