wonambi.trans.filter module

Module to filter the data.

wonambi.trans.filter.convolve(data, window, axis='time', length=1)[source]

Design taper and convolve it with the signal.

Parameters:
  • data (instance of Data) – the data to filter.

  • window (str) – one of the windows in scipy, using get_window

  • length (float, optional) – length of the window

  • axis (str, optional) – axis to apply the filter on.

Returns:

instance of DataRaw – data after convolution

Notes

Most of the code is identical to fftconvolve(axis=data.index_of(axis)) but unfortunately fftconvolve in scipy 0.13 doesn’t take that argument so we need to redefine it here. It’s pretty slow too.

Taper is normalized such that the integral of the function remains the same even after convolution.

See also

scipy.signal.get_window

function used to create windows

wonambi.trans.filter.filter_(data, axis='time', low_cut=None, high_cut=None, order=4, ftype='butter', Rs=None, notchfreq=50, notchquality=25)[source]

Design filter and apply it.

Parameters:
  • ftype (str) – ‘butter’, ‘cheby1’, ‘cheby2’, ‘ellip’, ‘bessel’, ‘diff’, or ‘notch’

  • axis (str, optional) – axis to apply the filter on.

  • low_cut (float, optional) – (not for notch) low cutoff for high-pass filter

  • high_cut (float, optional) – (not for notch) high cutoff for low-pass filter

  • order (int, optional) – (not for notch) filter order

  • data (instance of Data) – (not for notch) the data to filter.

  • notchfreq (float) – (only for notch) frequency to apply notch filter to (+ harmonics)

  • notchquality (int) – (only for notch) Quality factor (see scipy.signal.iirnotch)

Returns:

filtered_data (instance of DataRaw) – filtered data

Notes

You can specify any filter type as defined by iirfilter.

If you specify low_cut only, it generates a high-pass filter. If you specify high_cut only, it generates a low-pass filter. If you specify both, it generates a band-pass filter.

low_cut and high_cut should be given as ratio of the Nyquist. But if you specify s_freq, then the ratio will be computed automatically.

Raises:

ValueError – if the cutoff frequency is larger than the Nyquist frequency.