FitWidget

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.

API

class silx.gui.fit.FitWidget.FitWidget(parent=None, title=None, fitmngr=None, enableconfig=True, enablestatus=True, enablebuttons=True)[source]

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.

__init__(parent=None, title=None, fitmngr=None, enableconfig=True, enablestatus=True, enablebuttons=True)[source]
Parameters:
  • parent – Parent widget
  • title – Window title
  • fitmngr – User defined instance of silx.math.fit.fitmanager.FitManager, or None
  • enableconfig – If True, activate widgets to modify the fit configuration (select between several fit functions or background functions, apply global constraints, peak search parameters…)
  • enablestatus – If True, add a fit status widget, to display a message when fit estimation is available and when fit results are available, as well as a measure of the fit error.
  • enablebuttons – If True, add buttons to run estimation and fitting.
setData(x, y, sigmay=None, xmin=None, xmax=None)[source]

Set data to be fitted.

Parameters:
  • x (Sequence or numpy array or None) – Abscissa data. If None, xdata` is set to numpy.array([0.0, 1.0, 2.0, ..., len(y)-1])
  • y (Sequence or numpy array or None) – The dependant data y = f(x). y must have the same shape as x if x is not None.
  • sigmay (Sequence or numpy array or None) – The uncertainties in the ydata array. These are used as weights in the least-squares problem. If None, the uncertainties are assumed to be 1.
  • xmin – Lower value of x values to use for fitting
  • xmax – Upper value of x values to use for fitting

Table Of Contents

Previous topic

fit: Fit widgets

Next topic

hdf5: HDF5 widgets

This Page