简体   繁体   English

如何在树莓派上的pyqtgraph中绘制以12KHz读取的数据?

[英]How to plot data being read at 12KHz in pyqtgraph on raspberry pi?

My python script runs on a raspberry pi and reads voltage data at 12000 samples per second in chunks of 1200 samples from a LabJack U3. 我的python脚本在树莓派上运行,并从LabJack U3读取1200个样本中的每秒12000个样本的电压数据。 These data are stored in a list, and a time list with values corresponding to each voltage point is created artificially by referring to the voltage data read rate. 这些数据被存储在列表中,并且通过参考电压数据读取速率来人为地创建具有与每个电压点相对应的值的时间列表。 What is the best way to plot this data (voltage vs. time) in pyqtgraph? 在pyqtgraph中绘制此数据(电压与时间)的最佳方法是什么? I can already plot each data chunk (1200 samples) as they come in, but I need a way to plot many of these chunks in succession in the same plot window as they come in to get a better idea of how the voltage changes over time. 我已经可以绘制每个数据块(1200个样本),但是我需要一种方法,在它们进入的同一绘制窗口中连续绘制许多这些块,以更好地了解电压随时间的变化。

I've been using the scrolling plot examples from the pyqtgraph documentation as a guide but have been having problems plotting the data because of how it comes in as chunks instead of as single points. 我一直在使用pyqtgraph文档中的滚动绘图示例作为指南,但是由于数据如何以块而不是单个点的形式出现,因此在绘制数据时遇到了问题。 I don't need to plot at the full 12KHz because of the pixel density of the monitor as well as its refresh rate but have gotten stuck at this point. 由于监视器的像素密度及其刷新率,我不需要在完整的12KHz处进行绘图,但是此时此刻已经卡住了。 Can anyone suggest a good way to proceed? 谁能建议一个很好的方法吗?

Thanks for your help. 谢谢你的帮助。

If, as you say, you don't need to plot the full 12000 samples, you can down sample them. 如您所说,如果不需要绘制完整的12000个样本,则可以对它们进行下采样。 The PlotItem.setDownSampling method does exactly that. PlotItem.setDownSampling方法正是这样做的。 Or you can do it yourself with Numpy. 或者,您也可以使用Numpy自己做。

There have been some SO post on this topic before, so I would search a bit. 之前有一些关于此主题的帖子,所以我会进行搜索。 For instance this one , which suggests to store the data in a circular buffer (a collections.deque ). 例如这一个 ,这表明为存储在环形缓冲器中(一个数据collections.deque )。 This may be useful if you want a scrolling plot. 如果要滚动图,这可能很有用。

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

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