def _update(self):
if not self._sink:
return False
# Read and format data.
data, timestamps = self._sink.retrieveData(length=self._frameSize)
if not data:
return
sri = self._sink.sri
data = self._formatData(data, sri)
# If xdelta changes, update the X and Y ranges.
if self._sink.sriChanged():
# Update the X and Y ranges
x_min, x_max = self._getXRange(sri)
y_min, y_max = self._getYRange(sri)
self._image.set_extent((x_min, x_max, y_max, y_min))
# Preserve the aspect ratio based on the image size.
x_range = x_max - x_min
y_range = y_max - y_min
self._plot.set_aspect(x_range/y_range*self._aspect)
self._xdelta = sri.xdelta
# Resample data from frame size to image size.
height, width = self._imageData.shape
indices_out = numpy.linspace(0, len(data)-1, width)
indices_in = numpy.arange(len(data))
data = numpy.interp(indices_out, indices_in, data)
# Store the new row and update the image data.
self._imageData[self._row] = data
self._image.set_array(self._imageData)
# Advance row pointer
self._row = (self._row + 1) % height
return True
评论列表
文章目录