I think it would be much cleaner if you had a list of image items, so
self.imageItems = [self.img, self.img1, ...]. Then you can set all your
labels, scale, etc in one loop rather than repeating the code. You can pass
the complete 'y' from read into your update method. Your img_array isn't
indexed by channel but needs to be. Every ImageItem is being passed the
same img_array so the plots will be the same.
def read(self):
self.stream.start_stream()
data = self.stream.read(CHUNKSZ)
y = np.fromstring(data, dtype=np.int16)
self.signal.emit(y)
...
def update(self, all_chunk):
# normalized, windowed frequencies in data chunk
for i in len(self.imageItems):
chunk = all_chunk[i::8] # Channel i
spec = np.fft.rfft(chunk*self.win2) / CHUNKSZ # Compute discrete FT
for real input
#print(spec)
# get magnitude
psd = abs(spec)
# convert to dB scale
psd = 20 * np.log10(psd)
#### img_array needs to be indexed by channel. Right now it will
just repeat the same data across all plots
# roll down one and replace leading edge with new data
self.img_array = np.roll(self.img_array, -1, 0)
self.img_array[-1:] = psd
self.imageItems[i].setImage(self.img_array_by_channel,
autoLevels=False)
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/29c5eb9b-9b3d-446b-bd49-a88477068419%40googlegroups.com.