Пример #1
0
 def setup_image(self, i, j, win):
     p = ImagePlot(win, xlabel=self.xlabel, ylabel=self.ylabel,
                   zlabel=self.zlabel, yreverse=self.yreverse)
     self.main_widget = p
     win.add_plot(i, j, p)
     for item in self.images+self.plots:
         if item in self.images:
             item.set_color_map(self.colormap)
         p.add_item(item)
     if self.legend_position is not None:
         p.add_item(make.legend(self.legend_position))
     return p
Пример #2
0
 def setup_image(self, i, j, win):
     p = ImagePlot(win,
                   xlabel=self.xlabel,
                   ylabel=self.ylabel,
                   zlabel=self.zlabel,
                   yreverse=self.yreverse)
     self.main_widget = p
     win.add_plot(i, j, p)
     for item in self.images + self.plots:
         if item in self.images:
             item.set_color_map(self.colormap)
         p.add_item(item)
     if self.legend_position is not None:
         p.add_item(make.legend(self.legend_position))
     return p
Пример #3
0
    def test_adding_to_plot(self):
        s = ScanningParam()
        a = AxisParam()
        a.length = 5
        a.increment = 0.5
        a.start = -1.5
        a.unit = 'nm'
        s.axis1 = a
        s.axis2 = a
        data = np.random.rand(5, 5)
        m = Measurement(data, s)
        image = ThothImageItem(m)

        from guiqwt.image import ImagePlot
        plot = ImagePlot(title="Test")
        plot.add_item(image)
        plot.show()
Пример #4
0
    def test_adding_to_plot(self):
        s = ScanningParam()
        a = AxisParam()
        a.length = 5
        a.increment = 0.5
        a.start = -1.5
        a.unit = 'nm'
        s.axis1 = a
        s.axis2 = a
        data = np.random.rand(5,5)
        m = Measurement(data,s)
        image = ThothImageItem(m)

        from guiqwt.image import ImagePlot
        plot = ImagePlot(title="Test")
        plot.add_item(image)
        plot.show()
Пример #5
0
class ImageScreen(QWidget):
    """
    Hum hum hum
    """
    def __init__(self, parent, x, y, data, sizex, sizey):
        QWidget.__init__(self, parent)

        self.setMinimumSize(sizex, sizey)
        self.x = x
        self.y = y
        self.data = data
        #---guiqwt related attributes:
        self.plot = None
        self.image = None
        self.ROI = None
        self.background = None
        #---
        self.setup_widget()

    def setup_widget(self):

        self.plot = ImagePlot(self)
        self.image = make.xyimage(self.x, self.y, self.data, colormap='jet')
        self.plot.add_item(self.image)
        self.plot.set_antialiasing(True)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)

        #self.plot.adjustSize()

    def update_image(self):
        self.image.x = self.x
        self.image.y = self.y
        self.image.data = self.data

        self.plot.replot()

        pass
Пример #6
0
class ImageScreen(QWidget):
    """
    Hum hum hum
    """
    def __init__(self, parent, x, y, data):
        QWidget.__init__(self, parent)

        #self.setMinimumSize(sizex, sizey)
        self.x = x
        self.y = y
        self.data = data
        self.level_xy = [[[0, 0], [0, 0]] for i in range(8)]
        #---guiqwt related attributes:
        self.plot = None
        self.image = None
        self.ROI = None
        self.background = None
        self.levels = []
        #---
        self.setup_widget()

    def setup_widget(self):

        self.plot = ImagePlot(self)
        self.image = make.xyimage(self.x, self.y, self.data, colormap='jet')
        self.plot.add_item(self.image)
        self.plot.set_antialiasing(True)
        #--- levels ?
        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels.append(make.curve(x, y, color="w"))
            self.plot.add_item(self.levels[-1])
        #----------------------
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)
        self.plot.adjustSize()

    def update_image(self):
        self.image.x = self.x
        self.image.y = self.y
        self.image.data = self.data

        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels[i].x = x
            self.levels[i].y = y
        self.plot.replot()

        pass

    def update_contour(self):

        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels[i].set_data(x, y)
        self.plot.replot()

        pass

    def reset_contour(self):
        self.level_xy = [[[0, 0], [0, 0]] for i in range(8)]
        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels[i].set_data(x, y)

        self.plot.replot()

        pass
Пример #7
0
class SlindingTimeFreq(QWidget):
    def __init__(self, threadacquisition=None, parent = None,):
        super(SlindingTimeFreq, self).__init__(parent)
        
        self.threadacquisition = threadacquisition
        
        self.mainlayout = QHBoxLayout()
        self.setLayout(self.mainlayout)


        v = QVBoxLayout()
        self.mainlayout.addLayout(v)
        self.combo = QComboBox()
        v.addWidget(self.combo)
        self.plot = ImagePlot(yreverse=False, lock_aspect_ratio=False,)
        v.addWidget(self.plot)

        v = QVBoxLayout()
        self.mainlayout.addLayout(v)
        
        self.spinboxes = { }
        for param, value in {'xsize':2., 'f_start':1., 'f_stop':80., 'deltafreq' : .5, 'f0':2.5}.items():
            spin = QDoubleSpinBox( decimals = 1, singleStep = 0.1, value = value, minimum = 0., maximum = np.inf)
            self.spinboxes[spin] = param
            v.addWidget(QLabel(param))
            v.addWidget(spin)
            v.addSpacing(10)
            spin.valueChanged.connect(self.paramChanged)
        v.addStretch(4)

        self.image = None
        self.xsize = 2.

        self.paramsTimeFreq = dict(
                                                        f_start=1.,
                                                        f_stop = 80.,
                                                        deltafreq = .5,
                                                        sampling_rate = 1./self.threadacquisition.samplingInterval,
                                                        f0 = 2.5,
                                                        normalisation = 0.,
                                                        )
        self.recreateThread = True
        self.isComputing = False
        self.initializeTimeFreq()
        
        
        self.timer = QTimer(singleShot = False, interval = 200)
        self.timer.timeout.connect(self.refresh)
        self.timer.start()

    def initializeTimeFreq(self):
        self.plot.del_all_items()
        
        self.len_wavelet = int(self.xsize/self.threadacquisition.samplingInterval)
        self.wf = generate_wavelet_fourier(len_wavelet= self.len_wavelet, ** self.paramsTimeFreq).transpose()
        
        self.win = hamming(self.len_wavelet)
        self.map = zeros(self.wf.shape)
        self.image = make.image(self.map, title='TimeFreq',interpolation ='nearest')
        self.plot.add_item(self.image)
        
        p = self.paramsTimeFreq
        self.freqs = arange(p['f_start'],p['f_stop'],p['deltafreq'])
        
        
    def paramChanged(self):
        spin = self.sender()
        name = self.spinboxes[spin]
        if name =='xsize':
            self.xsize = spin.value()
            self.xsize = min(30., self.xsize)
        else:
            self.paramsTimeFreq[name] = spin.value()
        
        self.initializeTimeFreq()
        self.recreateThread = True
        
        self.refresh()

    def refresh(self):
        if self.combo.count()==0:
            self.combo.addItems(self.threadacquisition.channelNames)
        channel = self.combo.currentIndex ()
        
        if self.isComputing:
            return
        
        sig = self.threadacquisition.buffer[-self.len_wavelet:, channel]
        if sig.size != self.len_wavelet:
            print 'xsize too BIG!!', sig.size, self.len_wavelet
            return
        
        self.isComputing = True
        
        if self.recreateThread:
            self.thread = ThreadComputeTF(sig, self.wf, self.win, parent = self)
            self.thread.finished.connect(self.mapComputed)
            self.recreateThread = False
        else:
            self.thread.sig = sig
        self.thread.start()

    def mapComputed(self):
        xaxis, yaxis = self.plot.get_active_axes()
        self.plot.setAxisScale(yaxis, self.freqs[0], self.freqs[-1])
        self.plot.setAxisScale(xaxis,-self.xsize, 0.)

        self.image.set_ydata(self.freqs[0], self.freqs[-1])
        self.image.set_xdata(-self.xsize, 0.)
        
        self.image.set_data(self.map)

        self.plot.replot()

        self.isComputing = False