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) – The dimension of the smoothing window; should be an odd integer

  • window (Literal['flat', 'hanning', 'hamming', 'bartlett', 'blackman']) – The type of window. A ‘flat’ window will produce a moving average smoothing.

Returns:

smoothed – The smoothed signal (same dimension as x)

Return type:

np.ndarray

Example

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

See also

numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve, scipy.signal.lfilter, TO-DO, -----, The

Notes

Raises:

ValueError – When the input values are not entirely valid