dupin.preprocessing.signal

Overview

high_frequency_smoothing

Smooth out the highest frequencies of a signal.

moving_average

Smooth an array via a moving average.

Details

Functions for smoothing a signal.

scipy.signal provides many additional methods for signal processing that can be used to transform data in numerous ways.

dupin.preprocessing.signal.high_frequency_smoothing(y, max_frequency, **kwargs)[source]

Smooth out the highest frequencies of a signal.

The code by defaults performs an 8th order Butterworth filter with a passband roughly from 0 to max_frequency. We treat the signal as having a sampling frequency of 1Hz, so the max_frequency cannot be greater than 1.0.

Parameters:
  • y (\((N, M)\) numpy.ndarray of float) – The signal to remove low contributing frequencies from. The FFT is performed on the first dimension.

  • max_frequency (float) – The first frequency to where the gain dips below -0.01 (unless another number is specified for rp in the key word arguments).

  • **kwargs – Key word arguments to pass to scipy.signal.ellip. This may invalidate some documentation assumptions above.

dupin.preprocessing.signal.moving_average(y, span=1)[source]

Smooth an array via a moving average.

For multidimensional arrays, the smoothing is done on the first axis. This is consistent when columns represent multiple variables or features and rows represent different instances.

Parameters:
  • y (numpy.ndarray) – input array to smooth.

  • span (int, optional) – The window size to compute the moving mean over. Defaults to 1 which does nothing.

Returns:

smoothed_array

Return type:

numpy.ndarray