This module provides a widget designed to configure and run a fitting process with constraints on parameters.
The main class is FitWidget. It relies on silx.math.fit.fitmanager, which relies on silx.math.fit.leastsq().
The user can choose between functions before running the fit. These function can be user defined, or by default are loaded from silx.math.fit.fittheories.
For a tutorial on how to use FitWidget, see Using FitWidget.
This widget can be used to configure, run and display results of a fitting process.
The standard steps for using this widget is to initialize it, then load the data to be fitted.
Optionally, you can also load user defined fit theories. If you skip this step, a series of default fit functions will be presented (gaussian-like functions), and you can later load your custom fit theories from an external file using the GUI.
A fit theory is a fit function and its associated features:
- estimation function,
- list of parameter names
- numerical derivative algorithm
- configuration widget
Once the widget is up and running, the user may select a fit theory and a background theory, change configuration parameters specific to the theory run the estimation, set constraints on parameters and run the actual fit.
The results are displayed in a table.
Parameters: |
|
---|
This dictionary defines the fit configuration widgets associated with the fit theories in fitmanager.theories
Keys must correspond to existing theory names, i.e. existing keys in fitmanager.theories.
Values must be instances of QDialog widgets with an additional output attribute, a dictionary storing configuration parameters interpreted by the corresponding fit theory.
The dialog can also define a setDefault method to initialize the widget values with values in a dictionary passed as a parameter. This will be executed first.
In case the widget does not actually inherit QDialog, it must at least implement the following methods (executed in this particular order):
- show(): should cause the widget to become visible to the user)
- exec_(): should run while the user is interacting with the widget, interrupting the rest of the program. It should typically end (return) when the user clicks an OK or a Cancel button.
- result(): must return True if the new configuration in attribute output is to be accepted (user clicked OK), or return False if output is to be rejected (user clicked Cancel)
To associate a custom configuration widget with a fit theory, use associateConfigDialog(). E.g.:
fw = FitWidget()
my_config_widget = MyGaussianConfigWidget(parent=fw)
fw.associateConfigDialog(theory_name="Gaussians",
config_widget=my_config_widget)
Set data to be fitted.
Parameters: |
|
---|
Associate an instance of custom configuration dialog widget to a fit theory or to a background theory.
This adds or modifies an item in the correspondence table configdialogs or bgconfigdialogs.
Parameters: |
|
---|---|
Raise: | KeyError if parameter theory_name does not match an existing fit theory or background theory in fitmanager. |
Raise: | AttributeError if the widget does not implement the mandatory methods (show, exec_, result, setDefault) or the mandatory attribute (output). |