lin_smooth#

PySeismoSoil.helper_signal_processing.lin_smooth(x: ndarray, window_len: int = 15, window: Literal['flat', 'hanning', 'hamming', 'bartlett', 'blackman'] = 'hanning') → ndarray[source]#

Smooth the data using a window with requested size.

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 begining and end part of the output signal.

Parameters:
  • x (np.ndarray) – The input signal. Should be a 1D numpy array

  • window_len (int, default=15) – The dimension of the smoothing window; should be an odd integer

  • window (WindowName, default='hanning') – The type of window. One of ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’. A ‘flat’ window will produce a moving average smoothing.

Returns:

The smoothed signal (same dimension as x)

Return type:

np.ndarray

Raises:

ValueError – When the input values are not entirely valid

See also

numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve, scipy.signal.lfilter

Notes

Examples

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