find_edges

typhoon.test.signals.find_edges(signal, value, rising=False, falling=False, during=None)

Find edges around a given value in a signal.

Parameters:
  • signal (pandas.Series) – Signal to be tested for.

  • value (float) – Defines the value around which the edge crossings are detected. For example, if rising edge from 0 to 1 needs to be detected, valid argument for value is in range (0, 1].

  • rising (bool) – Detect rising edges in this signal.

  • falling (bool) – Detect falling edges in this signal.

  • during (tuple) – Time period (as a range) to be considered for analysis.

Returns:

result – Instants corresponding to the found edges in the signal.

Return type:

list of Timedelta

Notes

At least one option considering falling or rising should be defined as True.

Examples

Finding zero-crossings in a sine wave:

>>> from typhoon.test.signals import pandas_sine, find_edges
>>> sig = pandas_sine(amplitude=10, frequency=50, duration=0.030)  # 30 ms = 1 and a half cycle
>>> zero_crossings = find_edges(sig, value=0, rising=True, falling=True)
>>> zero_crossings[0]
10 ms
>>> zero_crossings[1]
20 ms