def apply_bandpass_filter(data, f_low, f_high, filter_bw=0.08):
if f_low > f_high:
f_low, f_high = f_high, f_low
f_low = util.clip(f_low, -0.5, 0.5)
f_high = util.clip(f_high, -0.5, 0.5)
h = Filter.design_windowed_sinc_bandpass(f_low, f_high, filter_bw)
# Choose normal or FFT convolution based on heuristic described in
# https://softwareengineering.stackexchange.com/questions/171757/computational-complexity-of-correlation-in-time-vs-multiplication-in-frequency-s/
if len(h) < 8 * math.log(math.sqrt(len(data))):
logger.debug("Use normal convolve")
return np.convolve(data, h, 'same')
else:
logger.debug("Use FFT convolve")
return Filter.fft_convolve_1d(data, h)
评论列表
文章目录