示例#1
0
    def update_plot(self, new_t, new_vals):

        if self.first_update:            
            self.first_update = False
            self.n = 0            
            self.tmin = new_t
            self.tmax = self.tmin + self.window
            self.t = np.arange(self.tmin, self.tmax, 0.1)
            for var in self.data:
                self.data[var] = np.zeros(len(self.t))            
            self.widget.setAxisScale(Qwt.QwtPlot.xBottom, self.tmin, self.tmax)        

        self.t[self.n] = new_t

        for var, val in new_vals.iteritems():
            self.data[var][self.n] = val
            self.curves[var].setData(self.t[:self.n], self.data[var][:self.n])
            #self.curves[var].setData(self.t, self.data[var])

        if self.tmax - self.t[self.n] < self.jump_threshold:
            self.tmin += self.jump
            self.tmax += self.jump             
            self.widget.setAxisScale(Qwt.QwtPlot.xBottom, self.tmin, self.tmax)
            # drop old data the will not be displayed.
            # find the index of the largest value in self.t that is less than tmin.
            cut_index = len(np.nonzero(self.t[:self.n] < self.tmin)[0])
            debug("tmin=%f tmax=%f cut=%d n=%d -> %d array_lenth=%d" % (
                self.tmin, self.tmax, cut_index, self.n, self.n - cut_index, len(self.t)))

            self.t = self.t[cut_index:]
            for var in self.data:
                self.data[var] = self.data[var][cut_index:]
            self.n -= cut_index
            assert(self.t[self.n] == new_t)
        
        self.n += 1

        if self.n >= len(self.t):
            debug("Extending arrays by %d samples" % (self.extra_samples))
            self.t = np.concatenate((self.t, np.zeros(self.extra_samples)))
            for var in self.data:
                self.data[var] = np.concatenate((self.data[var], np.zeros(self.extra_samples)))

        #self.widget.setAxisScale(Qwt.QwtPlot.xBottom, t[-1]-10, t[-1])        
        self.widget.replot()
示例#2
0
        def updateValue(self, curveId, value):
            curveId = str(curveId)
            # update data plot
            if (not self.pauseFlag) and curveId in self.curves:
                if self.oscilloscopeMode:
                    self.curves[curveId]['data'][self.oscilloscopeNextDataPosition] = float(value)
                    # only advance the oscilloscopeNextDataPosition for the first curve in the dict
                    if self.curves.keys()[0] == curveId:
                        self.oscilloscopeNextDataPosition = (self.oscilloscopeNextDataPosition + 1) % len(self.timeAxis)
                else:
                    self.curves[curveId]['data'] = concatenate((self.curves[curveId]['data'][1:], self.curves[curveId]['data'][:1]), 1)
                    self.curves[curveId]['data'][-1] = float(value)

                if not self.redrawManually:
                    if self.redrawOnEachUpdate or (self.redrawOnFullUpdate and self.curves.keys()[0] == curveId):
                        self.redraw()
示例#3
0
 def new_data(self,d):
     # shift the data to create a scrolling dataplotx
     self.y = np.concatenate( ([d], self.y[0:-1] ) )
     self.cData.setData(self.x,self.y)
     self.replot()