简体   繁体   English

为什么 scipy.signal.filtfilt 规范化结果?

[英]why scipy.signal.filtfilt normalize the result?

I try to filter my time-series data using filtfilt.我尝试使用 filtfilt 过滤我的时间序列数据。 My original sample ranged from 80 to about 130. The filtered sample ranged from -20 to 30. It seems like the filtfilt function filter the data and normalize it.我的原始样本范围从 80 到大约 130。过滤后的样本范围从 -20 到 30。似乎 filtfilt 函数过滤数据并将其归一化。 How could I filter the data but not normalize it?我如何过滤数据但不对其进行规范化?

Orignal sample Filtered sample原始样本过滤样本

The upper image is the original sample, and the lower image is the filtered sample.上图是原始样本,下图是过滤后的样本。

I tried this code for filtering.我试过这段代码进行过滤。

    def butter_bandpass(lowcut, highcut, fs, order=5):
        nyq = 0.5 * fs
        low = lowcut / nyq
        high = highcut / nyq
        b, a = butter(order, [low, high], btype='band')
        return b, a
    def butter_bandpass_filter(data, lowcut, highcut, fs, order=5):
        b, a = butter_bandpass(lowcut, highcut, fs, order=order)
        y = filtfilt(b, a, data)
        return y

I set band pass from 0.5 to 32.我将带通设置为 0.5 到 32。

    trial = butter_bandpass_filter(trial, 0.5, 32, 256, 5)

I am new to signal processing.我是信号处理的新手。 Thanks in advance for your help!在此先感谢您的帮助!

You've designed a bandpass filter.您设计了一个带通滤波器。 As a result, frequencies less than 0.5 are filtered out.结果,小于 0.5 的频率被过滤掉。 This includes the DC component of the input signal.这包括输入信号的直流分量。 Hence, the output signal, having the bulk of the DC removed, will be centered around 0.因此,去除了大部分 DC 的输出信号将以 0 为中心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM