示例#1
0
 def plot_correlation(self):
     # correlate options - get all the data to plot
     xchoice = self.xCorr.GetSelection()
     ychoice = self.yCorr.GetSelection()
     leg = [self.calcList.GetItemText(i) for i in getListCtrlSelection(self.calcList)]
     data, info = interface.getCorr(xchoice, ychoice, [self.calcs[i] for i in getListCtrlSelection(self.calcList)])
     msg = [leg, data, info]
     try:
         self.plot_frame.Raise()
     except (AttributeError, wx.PyDeadObjectError):
         self.plot_frame = PlotCorrFrame(self)
         self.plot_frame.Show()
     pub.sendMessage('corr.plot', message=msg)
示例#2
0
 def replot(self):
     sind = getListCtrlSelection(self.PlotsCtrl)
     ng = len(sind)
     ncols = round(ng**0.5)
     if ncols == 0.:
         ncols = 1.
     nrows = math.ceil(ng / ncols)
     self.fig.clear()
     
     for i, igraph in enumerate(sind):
         color = iter(cm.get_cmap('prism')([x/24. for x in range(24)]))
         title = self.PlotsCtrl.GetItemText(igraph)
         axes = self.fig.add_subplot(nrows,ncols,i+1)
         axes.set_title(title)
         sdata = []
         if self.ByCalcsChkBox.IsChecked():
             for ins in range(len(self.names)):
                 sdata.append(axes.scatter(self.data[igraph][ins][0], self.data[igraph][ins][1], c = next(color)))
         else:
             for ds in self.data:
                 sdata.append(axes.scatter(ds[igraph][0], ds[igraph][1], c = next(color)))
                 
     # get legend
     self.fig.legend(sdata, self.leg, scatterpoints = 1)
     self.canvas.draw()
示例#3
0
 def plot_property(self):
     # plot options - get all the data to plot
     ptype = self.propType.GetItems()[self.propType.GetSelection()]
     pchoice = self.propChoice.GetItems()[self.propChoice.GetSelection()]
     data_class = self.propChoices.dataClass(ptype, pchoice)
     leg = [self.calcList.GetItemText(i) for i in getListCtrlSelection(self.calcList)]
     t1 = time.clock()
     plot_data = interface.getData(ptype, data_class, leg,
                                   [self.calcs[i] for i in getListCtrlSelection(self.calcList)])
     self.SetStatusText('Calculation time: %7.2f s.' % (time.clock() - t1))
     msg = plot_data
     try:
         self.plot_frame.Raise()
     except (AttributeError, wx.PyDeadObjectError):
         self.plot_frame = PlotFuncFrame(self)
         self.plot_frame.Show()
     pub.sendMessage('data.plot', message=msg)
示例#4
0
 def DoPopup(self, pos):
     """ pos should be in client coords """
     if self.context_menu:
         selectBeforePopup(self, pos)
         selection = getListCtrlSelection(self)
         if len(selection) > 0:
             self.PopupMenu(self.context_menu)
             return
示例#5
0
 def DoPopup(self, pos):
     """ pos should be in client coords """
     if self.context_menu:
         selectBeforePopup(self, pos)
         selection = getListCtrlSelection(self)
         if len(selection) > 0:
             self.PopupMenu(self.context_menu)
             return
示例#6
0
 def on_DeselectBtn(self, evt):
     sind = getListCtrlSelection(self.OptionsList)
     if sind:
         ds = 0
         for si in sind:
             option_text = self.selected_options.pop(si - ds)
             self.OptionsList.DeleteItem(si - ds)
             self.parent.remove_FDF_option(option_text)
             ds += 1
         return 0
     return 1
示例#7
0
 def upBtnPress(self, event):
     # selection indices
     sind = getListCtrlSelection(self.calcList)
     if sind:
         # number of deleted strings
         ds = 0
         for si in sind:
             self.calcs.pop(si - ds)
             self.calcList.DeleteItem(si - ds)
             ds += 1
         return 0
     return 1
示例#8
0
    def replot(self, cfd = True):
        sind = getListCtrlSelection(self.PlotsCtrl)
        print sind
        ng = len(sind)
        ncols = round(ng**0.5)
        if ncols == 0.:
            ncols = 1.
        nrows = math.ceil(ng / ncols)
        self.fig.clear()
        # clear fitting data as well
        if cfd:
            self.fit_points = []
        self.FitBtn.SetLabel("Begin fit")
        self.fitting = False

        for i, igraph in enumerate(sind):
            title = self.PlotsCtrl.GetItemText(igraph)
            axes = self.fig.add_subplot(nrows,ncols,i+1)
            axes.set_title(title)
            if self.ByCalcsChkBox.IsChecked():
                if not hasattr(self.data[igraph],'var_x'):
                    x = self.data[igraph].x
                else:
                    x = range(len(self.data[igraph].x))
                    axes.get_xaxis().set_ticks(x)
                    axes.get_xaxis().set_ticklabels(self.data[igraph].x, rotation=60, size='x-small')
                for y in self.data[igraph].y:
                    axes.plot(x, y)
            else:
                for d in self.data:
                    if not hasattr(d,'var_x'):
                        x = d.x
                    else:
                        x = range(len(d.x))
                        axes.get_xaxis().set_ticks(x) 
                        axes.get_xaxis().set_ticklabels(d.x, rotation=60, size='x-small') 
                    axes.plot(x, d.y[igraph])
        # get legend
        lines = self.fig.axes[0].get_lines()
        self.fig.legend(lines, self.leg, 1)
        self.fig.tight_layout()
        self.canvas.draw()
示例#9
0
    def FitBtnPress(self, evt):
        sind = getListCtrlSelection(self.PlotsCtrl)
        if len(sind) > 1:
            print 'There should be one axis!'
            return
        sind = sind[0]
        
        if not self.fitting:
            # begin fit; show dialog
            dlg = FitDialog(self, sets = self.leg)
            if not dlg.ShowModal() == wx.ID_OK:
                dlg.Destroy()
                return
            # get data from dialog
            opts, iset = dlg.GetFitOptions()
            dlg.Destroy()
            # some quirks to begin fitting
            self.FitBtn.SetLabel("Finish fit")
            self.fitting = True
            self.canvas.Bind(wx.EVT_LEFT_DCLICK, self.OnCanvasClick)
            # get fit set according to the state of GBC checkbox
            if self.ByCalcsChkBox.IsChecked():
                fit_set = (self.data[sind][self.x], self.data[sind][self.PlotsCtrl.GetItemText(iset)])
            else:
                fit_set = (self.data[iset][self.x], self.data[iset][self.PlotsCtrl.GetItemText(sind)])
            self.fit = fit.Fit(opts, fit_set) 
        else:
            # try to end fit
            if not self.fit.is_enough(len(self.fit_points)):
                return
            self.canvas.Unbind(wx.EVT_LEFT_DCLICK)
# fitting itself
            p, x, y = self.fit.fit(self.fit_points)
            self.replot()
            ax = self.fig.gca()
            ax.plot(x, y, '--x')
            self.canvas.draw()
            self.AddFitInfo(self.fit.FitInfo())
示例#10
0
 def GetSelection(self):
     return getListCtrlSelection(self)
示例#11
0
 def GetSelection(self):
     return getListCtrlSelection(self)