This module contains the interactive GUI curve-fitting tools. They are based on Traits and TraitsGUI. Plotting is provided through the Chaco 2D plotting library , and, optionally, Mayavi for 3D plotting. The available models are those registered by the pymodelmit.core.register_model() mechanism.
Bases: traits.has_traits.HasTraits
This class represents the fitgui application state.
Parameters: |
|
---|
kwargs are passed in as any additional traits to apply to the application.
Updates the application state if the fit data are altered - the GUI will know if you give it a new data array, but not if the data is changed in-place.
Generates a python code string that can be used to generate a model with parameters matching the model in this FitGui.
Returns: | initializer string |
---|
Gets the underlying object representing the model for this fit.
Returns: | The pymodelfit.core.FunctionModel1D object. |
---|
Fit a 2d data set using the FitGui interface. A GUI application instance must already exist (e.g. interactive mode of ipython). This function is modal and will block until the user hits “OK” or “Cancel” - if non-blocking behavior is desired, create a FitGui object and call FitGui.edit_traits().
The following forms for input arguments are accepted:
fit_data(xdata,ydata)
fit_data(xdata,ydata,model)
This form requires a FunctionModel1D object that includes data
Parameters: |
|
---|
kwargs are passed into the fitgui initializer
Returns: | The model or None if fitting is cancelled or no model is assigned in the GUI. |
---|
Examples
>>> from numpy.random import randn
>>> fit_data(randn(100),randn(100))
This will bring up 100 normally-distributed points with no initial fitting model.
>>> from numpy.random import randn
>>> fit_data(randn(100),randn(100),'linear')
This will bring up 100 normally-distributed points with a best-fit linear model.
>>> from numpy.random import randn
>>> fit_data(randn(100),randn(100),'linear',weights=rand(100))
This will bring up 100 normally-distributed points with a best-fit linear model with the points weighted by uniform random values.
>>> from numpy import tile
>>> from numpy.random import randn,rand
>>> fit_data(randn(100),randn(100),'linear',weights=tile(rand(100),2).reshape((2,10)),fittype='yerr')
This will bring up 100 normally-distributed points with a linear model with the points weighted by a uniform random number (interpreted as inverse error) fit using the yerr algorithm instead of the default least-squares.
Note that the MultiFitGui requires Mayavi due to the need for 3D plotting.
Bases: traits.has_traits.HasTraits
data should be c x N where c is the number of data columns/axes and N is the number of points
Parameters: |
|
---|
extra keyword arguments get passed in as new traits (r[finmask],m[finmask],l[finmask]),names=’rh,Mh,Lh’,weights=w[finmask],models=models,dofits=False)