Example #1
0
 def create_autofit_group(self):        
     auto_button = QPushButton(get_icon('apply.png'), _("Run"), self)
     auto_button.clicked.connect(self.autofit)
     autoprm_button = QPushButton(get_icon('settings.png'), _("Settings"),
                                  self)
     autoprm_button.clicked.connect(self.edit_parameters)
     xrange_button = QPushButton(get_icon('xrange.png'), _("Bounds"), self)
     xrange_button.setCheckable(True)
     xrange_button.toggled.connect(self.toggle_xrange)
     auto_layout = QVBoxLayout()
     auto_layout.addWidget(auto_button)
     auto_layout.addWidget(autoprm_button)
     auto_layout.addWidget(xrange_button)
     self.button_list += [auto_button, autoprm_button, xrange_button]
     return create_groupbox(self, _("Automatic fit"), layout=auto_layout)
Example #2
0
 def setup_widget_layout(self):
     self.fit_layout = QHBoxLayout()
     self.params_layout = QGridLayout()
     params_group = create_groupbox(self, _("Fit parameters"),
                                    layout=self.params_layout)
     if self.auto_fit_enabled:
         auto_group = self.create_autofit_group()
         self.fit_layout.addWidget(auto_group)
     self.fit_layout.addWidget(params_group)
     self.plot_layout.addLayout(self.fit_layout, 1, 0)
     
     vlayout = QVBoxLayout(self)
     vlayout.addWidget(self.toolbar)
     vlayout.addLayout(self.plot_layout)
     self.setLayout(vlayout)
Example #3
0
 def create_autofit_group(self):
     auto_button = QPushButton(get_icon("apply.png"), _("Run"), self)
     auto_button.clicked.connect(self.autofit)
     autoprm_button = QPushButton(get_icon("settings.png"), _("Settings"),
                                  self)
     autoprm_button.clicked.connect(self.edit_parameters)
     xrange_button = QPushButton(get_icon("xrange.png"), _("Bounds"), self)
     xrange_button.setCheckable(True)
     xrange_button.toggled.connect(self.toggle_xrange)
     auto_layout = QVBoxLayout()
     auto_layout.addWidget(auto_button)
     auto_layout.addWidget(autoprm_button)
     auto_layout.addWidget(xrange_button)
     self.button_list += [auto_button, autoprm_button, xrange_button]
     return create_groupbox(self, _("Automatic fit"), layout=auto_layout)
Example #4
0
    def setup_widget_layout(self):
        self.fit_layout = QHBoxLayout()
        self.params_layout = QGridLayout()
        params_group = create_groupbox(self,
                                       _("Fit parameters"),
                                       layout=self.params_layout)
        if self.auto_fit_enabled:
            auto_group = self.create_autofit_group()
            self.fit_layout.addWidget(auto_group)
        self.fit_layout.addWidget(params_group)
        self.plot_layout.addLayout(self.fit_layout, 1, 0)

        vlayout = QVBoxLayout(self)
        vlayout.addWidget(self.toolbar)
        vlayout.addLayout(self.plot_layout)
        self.setLayout(vlayout)
Example #5
0
    def set_data(self,
                 x,
                 y,
                 fitfunc=None,
                 fitparams=None,
                 fitargs=None,
                 fitkwargs=None,
                 xmin=None,
                 xmax=None,
                 sigma=None,
                 **autofit_params):

        if self.fitparams is not None and fitparams is not None:
            self.clear_params_layout()

        if not isinstance(fitfunc, (tuple, list, np.ndarray, dict)):
            fitfunc = [fitfunc]
            fitparams = [fitparams]
        elif isinstance(fitfunc, dict):
            self.fitnames = fitfunc.keys()
            fitfunc = fitfunc.values()
            #fitparams = fitparams.values()

        if self.fitnames == []:
            self.fitnames = ['Fit %d' % (i + 1) for i in xrange(len(fitfunc))]
        self._idxlen = len(fitfunc)
        self.x = x
        self.y = y

        if sigma is None:
            sigma = np.ones(x.shape)
        self.sigma = sigma

        if fitfunc is not None:
            self.fitfunc = fitfunc
        if fitparams is not None:
            self.fitparams = fitparams
        if fitargs is not None:
            self.fitargs = fitargs
        if fitkwargs is not None:
            self.fitkwargs = fitkwargs

        self.autofit_prm = AutoFitParam(title=_("Automatic fitting options"))
        if xmin is None:
            self.autofit_prm.xmin = x.min()
        else:
            self.autofit_prm.xmin = xmin
        if xmax is None:
            self.autofit_prm.xmax = x.max()
        else:
            self.autofit_prm.xmax = xmax

        self.compute_imin_imax()

        if self.fitparams is not None and fitparams is not None:
            for i in xrange(self._idxlen):
                self.params_layouts.append(QGridLayout())
                params_group = create_groupbox(self,
                                               _(""),
                                               layout=self.params_layouts[i])
                self.tabs.addTab(params_group, _('%s') % self.fitnames[i])

            self.populate_params_layout()

        if autofit_params is not None:
            self.set_autofit_param(**autofit_params)

        self.refresh()