log_smooth#
- PySeismoSoil.helper_signal_processing.log_smooth(signal: ndarray, win_len: int = 15, window: Literal['flat', 'hanning', 'hamming', 'bartlett', 'blackman'] = 'hanning', lin_space: bool = True, fmin: float | None = None, fmax: float | None = None, n_pts: int = None, fix_ends: bool = True, beta1: float = 0.9, beta2: float = 0.9) ndarray [source]#
Smooth a frequency spectrum with constant window size in logarithmic space.
- Parameters:
signal (np.ndarray) – The signal to be smoothed. Must be a 1D numpy array.
win_len (int) – The length of the convolution window.
window (Literal['flat', 'hanning', 'hamming', 'bartlett', 'blackman']) – The name of the window.
lin_space (bool) – Whether the points of the signal is uniformly spaced linearly. If
False
, the signal is treated as uniformaly spaced logarithmically.fmin (float | None) – Minimum frequency (in Hz) that the signal is spaced within. Only effective when
lin_space
isTrue
.fmax (float | None) – Maximum frequency (in Hz) that the signal is spaced within. Only effective when
lin_space
isTrue
.n_pts (int) – The number of points of the logarithmically interpolated the signal. Only effective when
lin_space
isTrue
.fix_ends (bool) – Whether to fix the two ends of the smoothed signal, so that the “boundary effect” from convolution can be corrected. If
True
, the first and last n points will be adjusted using the exponentially weighted averaging method. (n is half ofwin_len
.)beta1 (float) – The “strength” of exponentially weighted averaging. For the head and the tail ends, respectively. Values should be within [0, 1].
beta2 (float) – The “strength” of exponentially weighted averaging. For the head and the tail ends, respectively. Values should be within [0, 1].
- Returns:
smoothed_signal – The smoothed signal which has the same dimension as the original signal.
- Return type:
np.ndarray
- Raises:
ValueError – When the input values are not entirely valid