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
length(output) != length(input), to correct this: return y[(window_len/2-1):-(window_len/2)] instead of just y.
Copied from: http://scipy-cookbook.readthedocs.io/items/SignalSmooth.html
- Raises:
ValueError – When the input values are not entirely valid