signal_frequency_zc

typhoon.test.harmonic.signal_frequency_zc(signal, during=None, mode='half-cycle')

Calculates frequency of the signal.

Measures time between neighboring zero-crossing moments. This method is suitable for sine, square or triangle signals. Returns pandas Series with the same length as signal. Frequency in the non-zero crossing moments is obtained by zero-order hold.

Parameters:
  • signal (Series) – A Pandas Series containing signal which frequency need to be calculated

  • during (2-element tuple of float/int or Timedelta) – Period of signal to consider for the calculation.

  • mode (string) – String that activates one of two possible modes: for “half-cycle” every zero-crossing is detected, while for “full-cycle” every second zero-crossing is detected

Returns:

result – Returns a pandas Series with calculated frequency at the same length as the input signal.

Return type:

pandas.Series

Examples

>>> import typhoon.test.signals as signals
>>> import typhoon.test.harmonic as harmonic
>>> # sine signal which lasts for one second, sampled 10000 times
>>> series = signals.pandas_sine(amplitude=10, frequency=50, Ts=1e-4, duration=1)
>>> frequency = harmonic.signal_frequency_zc(serie)
returns the Series of the measured frequency(50). The length of the Series is 10000.