简体   繁体   English

如何使用python指定我的截止频率为0.1 Hz来设计Butterworth滤波器?

[英]How can I design a Butterworth filter with python specifying that my cutoff frequency is 0.1 Hz?

Here I am trying to create a highpass butterworth digital filter with a cutoff frequency at 0.1 Hz. 在这里,我试图创建一个截止频率为0.1 Hz的高通巴特沃斯数字滤波器。 I had implemented the following code and I am not sure if it is true 我已经实现了以下代码,但不确定是否正确

#%% creating the filter 
# filter parameters 
order=6
btype='highpass'
cutoff_frequency=0.1*2*np.pi
analog=False

b, a= signal.butter(order,cutoff_frequency,btype, analog)
w, h = signal.freqs(b, a)

plt.figure() 
plt.plot(w, 20 * np.log10(abs(h)))
plt.xscale('log')
plt.title('Butterworth filter frequency response')
plt.xlabel('Frequency [radians / second]')
plt.ylabel('Amplitude [dB]')
plt.margins(0, 0.1)
plt.grid(which='both', axis='both')
plt.axvline(0.1*2*np.pi, color='green') # cutoff frequency
plt.show()

My confusion is about the cutoff frequency here I multiplied it by 2*pi because as I understood the cutoff_frequency of scipy.signal.butter corresponds to an angular frequency in rad/s. 我的困惑是关于截止频率,在这里我将其乘以2 * pi,因为据我所知,scipy.signal.butter的cutoff_frequency对应于以rad / s为单位的角频率。

Knowing that my sampling frequency is 1Hz I have performed the following steps to design the highpass 6th order Butterworth digital filter with a cutoff frequency at 0.1 Hz: 知道采样频率为1Hz之后,我执行了以下步骤来设计截止频率为0.1Hz的高通6阶Butterworth数字滤波器:

order=6 # order of the filter
btype='highpass' # type
F_sampling=1.0   # my sampling freq
Nyqvist_freq=F_sampling/2 # Nyqvist frequency in function of my sampling frequency
cut_off_Hz=0.1 # my cutoff frequency in Hz
cutoff_frequency=cut_off_Hz/Nyqvist_freq    # normalized cut_off frequency
analog=False #digital filter
b, a= signal.butter(order,cutoff_frequency,btype, analog)
w, h = signal.freqs(b, a)
Detrend_carrierPhase=signal.filtfilt(b, a, Carrier_phase) # filtering my high rate carrier phase

I am using the scipy library where the cut_off frequency is a fraction of the Nyqvist frequency and it is a non-dimensional value that's why I need to transform my sampling frequency expressed in Hz to the Nyqvist freq through dividing it by 2, so it is equal to 1Hz/2 =0.5 Hz it is the Nyqvist frequency of my system. 我正在使用scipy库,其中cut_off频率是Nyqvist频率的一小部分,并且它是一个无量纲的值,这就是为什么我需要通过将其除以2来将以Hz表示的采样频率转换为Nyqvist频率的原因,因此等于1Hz / 2 = 0.5 Hz,它是系统的Nyqvist频率。 The normalized Nyqvist cut_off freq given to the butter filter is 0.1 (Cut_off frequency in Hz) divided by 0.5 (Nyqvist frequency of my system). 提供给黄油过滤器的归一化Nyqvist截止频率是0.1(以Hz为单位的Cut_off频率)除以0.5(本系统的Nyqvist频率)。

I used the signal.filtfilt to filter my carrier phase (signal) 我使用signal.filtfilt过滤了我的载波相位(信号)

Hope this will be helpful! 希望这会有所帮助!

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

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