コード例 #1
0
ファイル: analyse_data_widget.py プロジェクト: ben741/LabGUI
    def fit_func_changed(self):
        """
        when a new fit fonction is choosen, the fit parameters are 
        automatically adjusted
        """

        new_func_name = str(self.fitCombo.currentText())

        self.fit_func = io.import_module_func(self.fonctions_module,
                                              new_func_name,
                                              package=self.fonctions_pkg)

        self.fit_params["fit_func"] = new_func_name

        #if the user defined extra physical parameters needed once the fit
        #is performed, they will be defined in the dict PHYS_PARAMS
        if new_func_name in ad.PHYS_PARAMS:
            self.physparam_list = ad.PHYS_PARAMS[new_func_name]
        else:
            self.physparam_list = []

        #update the layout according to the parameters
        self.remove_phys_layout()
        self.remove_fit_layout()

        self.create_fit_layout()
        self.create_phys_layout()
コード例 #2
0
ファイル: analyse_data_widget.py プロジェクト: ben741/LabGUI
    def manage_fix_value_fit_params(self):
        """
        this methods goes through the list of parameters and see whether
        they are fixed or not, then generate a fonction with only the 
        non fixed parameters that can be varied by the fitting procedure
        """
        at_least_one_param_fixed = False

        #prepare the list of argument of ad.restrict_function_parameters
        fit_func_var = []
        for fp in self.fit_params["fix_param"]:

            #if the fit param is set to fixed == True
            if self.fit_params["fix_param"][fp]:

                at_least_one_param_fixed = True

                #retrieve the value of the text_box with that parameter name
                fitp_fixed_value = self.get_lineedit_value(fp)

                #modify the value list to create a fonction with this
                #parameter fixed
                fit_func_var.append(fitp_fixed_value)

                #assigns the value to the fixed fit param
                self.fit_params["fit_func_params"][fp] = fitp_fixed_value

            else:

                #prepare the value list to create a fonction with this
                #parameter value to be varied to find the best fit
                fit_func_var.append(None)

        original_func = io.import_module_func(self.fonctions_module,
                                              str(self.fit_params["fit_func"]),
                                              package=self.fonctions_pkg)

        if at_least_one_param_fixed:
            #modifing the fit function by fixing some of its variables
            self.fit_func = ad.restrict_function_parameters(
                original_func, fit_func_var)

        else:

            self.fit_func = original_func
コード例 #3
0
ファイル: analyse_data_widget.py プロジェクト: ben741/LabGUI
    def __init__(self,
                 parent=None,
                 fonctions_module=FONCTIONS_MODULE,
                 fonctions_pkg=FONCTIONS_PKG):
        super(FittingWidget, self).__init__(parent)

        if not parent == None:

            #this will be triggered whenever the user changes the plot limits
            #or whenever the software changes increases the dataset
            self.connect(
                parent,
                QtCore.SIGNAL(
                    "selections_limits(PyQt_PyObject,int,int,int,int)"),
                self.update_selection_limits)

            #this will call update_experiment whenever the dataset is updated
            self.connect(parent,
                         QtCore.SIGNAL("data_array_updated(PyQt_PyObject)"),
                         self.update_data_and_fit)
            self.connect(
                parent,
                QtCore.SIGNAL("instrument_hub_connected(PyQt_PyObject)"),
                self.update_instruments_information)

            self.connect(parent, QtCore.SIGNAL("removed_selection_box()"),
                         self.selection_removed)

            self.connect(
                parent, QtCore.SIGNAL("plotwindowtype_changed(PyQt_PyObject)"),
                self.data_type_changed)

        #loads the lists of functions from a module
        self.fonctions_pkg = fonctions_pkg

        if parent == None:
            self.fonctions_module = fonctions_module

            self.fit_funcs_names = io.list_module_func(self.fonctions_module)
        else:
            self.fonctions_module = ".%s" % (fonctions_module)
            self.fit_funcs_names = io.list_module_func(
                self.fonctions_module, package=self.fonctions_pkg)

        # main layout of the form is the verticallayout
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        """
        here will be displayed the button to create subsets and choose between livefit or postfit, also the number of the subset is displayed
        """
        self.commandLayout = QtGui.QHBoxLayout()

        self.fitCombo = QtGui.QComboBox(self)
        self.fitCombo.setObjectName("fit_comboBox")
        self.fitCombo.addItems(self.fit_funcs_names)
        self.save_fitButton = QtGui.QPushButton(self)
        self.save_fitButton.setText("Save single fit")
        self.save_setButton = QtGui.QPushButton(self)
        self.save_setButton.setText("Save set fit")
        self.live_fitButton = QtGui.QPushButton(self)
        self.live_fitButton.setText("Enable Fit")

        #initializes the fonction list in the ComboBox for the first time
        if parent == None:
            self.fit_func = io.import_module_func(
                self.fonctions_module, str(self.fitCombo.currentText()))
        else:
            self.fit_func = io.import_module_func(
                self.fonctions_module,
                str(self.fitCombo.currentText()),
                package=self.fonctions_pkg)

        #assigns the name of the fit fonction (python2 and python3)
        try:
            self.fit_params["fit_func"] = self.fit_func.func_name
        except:
            self.fit_params["fit_func"] = self.fit_func.__name__

        self.commandLayout.addWidget(self.fitCombo)
        self.commandLayout.addWidget(self.save_fitButton)
        self.commandLayout.addWidget(self.save_setButton)
        self.commandLayout.addWidget(self.live_fitButton)
        self.verticalLayout.addLayout(self.commandLayout)
        """
        here will be displayed the x-axis boundaries over which the plot is made
        """
        self.create_selection_layout()

        #if the user defined extra physical parameters needed once the fit
        #is performed, they will be defined in the dict PHYS_PARAMS
        if self.fit_params["fit_func"] in ad.PHYS_PARAMS:
            self.physparam_list = ad.PHYS_PARAMS[self.fit_params["fit_func"]]
        else:
            self.physparam_list = []

        self.create_fit_layout()
        self.create_phys_layout()

        self.setLayout(self.verticalLayout)

        self.connect(self.fitCombo, QtCore.SIGNAL("currentIndexChanged(int)"),
                     self.fit_func_changed)

        self.connect(self.live_fitButton, QtCore.SIGNAL('clicked()'),
                     self.on_live_fitButton_clicked)

        #this helps to toggle all the button according to the state False
        #it starts in True)
        self.on_live_fitButton_clicked()

        self.connect(self.save_fitButton, QtCore.SIGNAL('clicked()'),
                     self.on_save_fitButton_clicked)

        self.connect(self.save_setButton, QtCore.SIGNAL('clicked()'),
                     self.on_save_setButton_clicked)