2
$\begingroup$

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:

enter image description

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?

$\endgroup$
  • $\begingroup$ Does this have to be done in real-time? If not, there are many more options available. $\endgroup$ – Peter K. Jan 29 '17 at 22:20
  • 1
    $\begingroup$ 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. $\endgroup$ – Matteo Scarponi Jan 30 '17 at 12:33
  • 1
    $\begingroup$ 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. $\endgroup$ – Peter K. Jan 30 '17 at 12:39
  • $\begingroup$ I'll look at it! Seems pretty useful $\endgroup$ – Matteo Scarponi Jan 30 '17 at 17:32
2
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – The Dude Oct 26 '17 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.