简体   繁体   English

使用BeagleBone Black上的numpy(不是scipy!)编程一个butterworth过滤器

[英]Program a butterworth filter using numpy (not scipy!) on a BeagleBone Black

I am a new user of Python and an amateur programmer in general - I am hoping to be able to filter a signal using just the numpy library. 我是Python的新用户和一般的业余程序员 - 我希望能够使用numpy库过滤信号。 It will be programmed onto a BeagleBone Black and the OS is Angstrom Linux, so the furthest numpy library it will update to is 1.4 and due to either rumored data limitations (I am not actually sure how to check) or just the version of numpy being too early, scipy will not work on the board. 它将被编程到BeagleBone Black上,操作系统是Angstrom Linux,因此它将更新到最远的numpy库是1.4并且由于传闻数据限制(我实际上不确定如何检查)或者仅仅是numpy版本太早,scipy将不会在董事会上工作。

So the first solution is to get a new operating system but I would not know where to start; 所以第一个解决方案是获得一个新的操作系统,但我不知道从哪里开始; I am more comfortable in the realm of putting equations into a program. 在将方程式放入程序中我更为舒适。

I was hoping to use the filtfilt function but maybe it would be best to start with lfilter. 我希望使用filtfilt函数,但也许最好从lfilter开始。 This site seemed helpful for implementing it but it is a bit beyond me: http://docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.signal.lfilter.html 这个网站似乎对实现它很有帮助,但它有点超出我的想法http//docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.signal.lfilter.html
I am capable of getting the filter coefficients in MATLAB then transferring them to the BeagleBone. 我能够在MATLAB中获取滤波器系数,然后将它们传输到BeagleBone。 The x is just the array that is my signal which I can upload. x只是我可以上传的信号数组。

The second section is a bit of a jump - so is there a way to perform a z-transform in just numpy, not scipy? 第二部分有点跳跃 - 所以有没有办法在numpy中执行z变换,而不是scipy? Also, based on all of the secrecy of the filter algorithm in MATLAB, I do not have faith in working that out, but is there some sort of mathematical algorithm description, or better yet code, describing how I may accomplish this? 另外,基于MATLAB中滤波器算法的所有保密性,我没有信心解决这个问题,但是有没有某种数学算法描述,或者更好的代码,描述我如何实现这一点?

Thanks for your patience in reading through this and the response. 感谢您耐心阅读本文和回复。 Please do not use complicated language in the response! 请不要在回复中使用复杂的语言!

-Rob -抢

For the filter design functions, you can copy the code from sicpy.signal.filter_design.py, they are almost pure python code. 对于过滤器设计函数,您可以从sicpy.signal.filter_design.py复制代码,它们几乎是纯Python代码。

But to do lfilter for IIR filters, you need a for loop for every sample in the data array. 但要为IIR滤波器执行lfilter ,您需要为数据数组中的每个样本提供一个for循环。 Since for loop in Python is slow, I think you need to implement it in C, and call it throught ctypes. 因为Python中的循环很慢,我认为你需要在C中实现它,并通过ctypes调用它。 Do you have ac compile in the target machine? 你在目标机器上有ac编译吗?

If you can design your filter as a FIR filter, then you can use numpy.convolve(b, x) . 如果您可以将滤波器设计为FIR滤波器,则可以使用numpy.convolve(b, x)

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

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