# Estimate Arrival Time of a Signal

I'm looking for a Python package or method to accurately estimate the arrival time of time signals.

A single time signal is stored inside a 1-dimensional numpy array, so every component of the array represents the value of the signal at a given timestep.

Here is an example of the signals shape:

Setting a threeshold is not always efficient, it depends on the signal behaviour and amplitude.

I would like to find a gradient based method to identify the starting timestep. Do you have any relevant experience or suggestion?

• Does this have to be done in real-time? If not, there are many more options available.
– Peter K.
Jan 29, 2017 at 22:20
• No they are data from a tsunami simulation database. Each Recording represents water elevation associated with a specific geographical point (x,y). To compare different mareograms (signals) collected in different locations, hence with different arrival times, I need to estimate their arrival time as accurately as possible. Jan 30, 2017 at 12:33
• Cool! Sounds like a fun project. I'll try to write an answer later (probably tomorrow), but look up CUSUM, particularly this answer. You may have to apply it to the high-pass signal (gradient signal) or you may want to look at an "energy" measure.
– Peter K.
Jan 30, 2017 at 12:39
• I'll look at it! Seems pretty useful Jan 30, 2017 at 17:32

## 3 Answers

A gradient-based method is essentially a high-pass filter, if you think about it. ("gradient" being "derivative" for 1D signals, and the derivative being small for non-changing signals, and very high for high-frequency signals). And that's exactly how I implement it:

• Signal in
• high-pass filter
• abs()
• find first above threshold
• subtract delay of filter¹

You can do so by designing a high-pass filter using scipy.signal.fir_filter_design and apply it using scipy.signal.filter.

Another popular method, which is mainly interesting if you want to do this on a live stream of samples, is doing the same within GNU Radio, where you can take the filter taps from the filter design, and put them into a readily available FIR filter. I kind of covered that in a blog post once, and you might want to read the first chapters of the GNU Radio Guided Tutorials, too.

¹: this requires your filter to have constant group delay, i.e. be linear-phase.

As mentioned before, a high pass filter can add delays to your detector. If your filter is not linear-phase, the delay depends on the frequency of your signal. Another approach is the called Onset Detection, or a detection of a sudden burst of energy. A great paper about this is here.

I think Marcus' technique is a good approach. However, if you want to avoid the phase-delay introduced by the high-pass filter, you could filter the signal twice. See Zero-phase Filtering. Granted you are filtering a given signal twice, but there is no added phase delay and, again, this is off-line data.

• You can always save your data to memory and filter it twice. So this works even in online setups, as long as your filtering operations can be done under schedule. Oct 26, 2017 at 18:22