python中的带通滤波器 [英] Bandpass filter in python

查看:129
本文介绍了python中的带通滤波器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 python 中获得一个带 128 点汉明窗口的带通滤波器,截止频率为 0.7-4Hz.我从图像中获取我的信号样本.(1 个样本 = 1 个图像).fps 经常变化.

这如何在python中完成?我读到这个:http://mpastell.com/2010/01/18/fir-with-scipy/ 但我觉得 firwin 相当混乱.如何用这个变量 fps 做到这一点?

解决方案

尝试过滤采样率不一致的数据非常困难(不可能?).所以你要做的是:

  1. 创建一个具有固定采样率的新信号.固定采样率应为最大采样率或更高.通过设置一个新的网格"来表示新样本应该去哪里,并从现有数据中插入它们的值来做到这一点.存在多种插值方法,具体取决于您需要的准确度.线性插值可能不是一个糟糕的起点,但这取决于您在做什么.如果您不确定,请咨询 https://dsp.stackexchange.com/.

  2. 完成此操作后,您可以对信号应用标准信号处理方法,因为样本是均匀放置的,例如您链接的帖子中描述的那些.

  3. 如有必要,您可能需要再次插值以恢复原始样本位置.

如果您只想分析数据,您可能会对 Lomb Periodigram.您可以使用 Lomb Periodigram,而不是带通数据然后进行分析,然后只查看相关频率,或者根据需要对结果进行加权.(另请参阅数值食谱系列.第 13.8 章称为不均匀间隔数据的光谱分析",这似乎是比维基百科页面更友好的介绍)

I'm trying to get a bandpass filter with a 128-point Hamming window with cutoff frequencies 0.7-4Hz in python. I get my samples for my signal from images. (1 sample = 1 image). The fps often changes.

How can this be done in python? I read this: http://mpastell.com/2010/01/18/fir-with-scipy/ but I find firwin rather confusing. How can this be done with this variable fps?

解决方案

Trying to filter data with an inconsistent sample rate is very difficult (impossible?). So what you are going to want to do is this:

  1. Create a new signal with a fixed sample rate. The fixed sample rate should be the maximum sample rate or higher. Do this by setting up a new "grid" representing where the new samples should go, and interpolating their values from existing data. A variety of interpolation methods exist depending on how accurate you need to be. Linear interpolation is probably not a bad starting point, but it depends on what you are doing. Ask on https://dsp.stackexchange.com/ if you are unsure.

  2. Once you've done that, you can apply standard signal processing methods to your signal because the samples are evenly placed, such as those described in the post you linked.

  3. If necessary, you may need to interpolate again to get your original sample positions back.

If you are looking only to analyze your data, you might be interested in the Lomb Periodigram. Instead of band-passing your data and then analyzing, you would use the Lomb Periodigram, and then only look at the relevant frequencies, or weight the results however you wanted. (see also the numerical recipes series. Chapter 13.8 is called "Spectral analysis of unevenly spaced data", which appears to be a friendlier introduction than that wikipedia page)

这篇关于python中的带通滤波器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆