def nonnegative_bandpass_filter(data,fa=None,fb=None,
Fs=1000.,order=4,zerophase=True,bandstop=False,
offset=1.0):
'''
For filtering data that must remain non-negative. Due to ringing
conventional fitering can create values less than zero for non-
negative real inputs. This may be unrealistic for some data.
To compensate, this performs the filtering on the natural
logarithm of the input data. For small numbers, this can lead to
numeric underflow, so an offset parameter (default 1) is added
to the data for stability.
Parameters
----------
data (ndarray):
data, filtering performed over last dimension
fa (number):
low-freq cutoff Hz. If none, lowpass at fb
fb (number):
high-freq cutoff Hz. If none, highpass at fa
Fs (int):
Sample rate in Hz
order (1..6):
butterworth filter order. Default 4
zerophase (boolean):
Use forward-backward filtering? (true)
bandstop (boolean):
Do band-stop rather than band-pass
offset (positive number):
Offset data to avoid underflow (1)
Returns
-------
filtered :
Filtered signal
'''
offset -= 1.0
data = np.log1p(data+offset)
filtered = bandpass_filter(data,
fa=fa, fb=fb, Fs=Fs,
order=order,
zerophase=zerophase,
bandstop=bandstop)
return np.expm1(filtered)
评论列表
文章目录