skrf.util.smooth

skrf.util.smooth(x, window_len=11, window='flat')[source]

Smooth the data using a window with requested size.

Based on the function from the scipy cookbook [1]

This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the beginning and end part of the output signal.

Parameters:
  • x (numpy.array) – the input signal

  • window_len (int, optional) – the dimension of the smoothing window; should be an odd integer. Default is 11.

  • window (str, optional) – the type of window from ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’ flat window will produce a moving average smoothing. Default is ‘flat’

Returns:

y – The smoothed signal

Return type:

numpy.array

Examples

>>> t = linspace(-2, 2, 0.1)
>>> x = sin(t) + randn(len(t))*0.1
>>> y = smooth(x)

Note

length(output) != length(input). To correct this: return y[(window_len/2-1):-(window_len/2)] instead of just y.

References