fitting Package¶
Gefit
Module¶
-
PyMca5.PyMcaMath.fitting.Gefit.
ChisqAlphaBeta
(model0, parameters, x, y, weight, constrains, model_deriv=None, linear=None)[source]¶
-
PyMca5.PyMcaMath.fitting.Gefit.
LeastSquaresFit
(model, parameters0, data=None, maxiter=100, constrains=None, weightflag=0, model_deriv=None, deltachi=None, fulloutput=0, xdata=None, ydata=None, sigmadata=None, linear=None)[source]¶ Typical use:
LeastSquaresFit(model_function, parameters, xdata=xvalues, ydata=yvalues)
- model_function - it has the form model_function(parameters, x) where parameters is a sequence
- containing the parameters to be refined and x is the array of values in which the function is to be evaluated.
parameters - sequence with the initial values to be refined
xdata - array with the x axis data points
ydata - array with the y axis data points
Additional keywords:
sigmadata - array with the uncertainties associated to ydata (default is sqrt(y) )
weightflag - 0 Means no weighted fit 1 means weighted fit
- constrains - if provided, it is a 2D sequence of dimension (3, n_parameters) where, for each
parameter denoted by the index i, the meaning is
- constrains[0][i] -> 0 - Free (Gefit.CFREE)
- 1 - Positive (Gefit.CPOSITIVE) 2 - Quoted (Gefit.CQUOTED) 3 - Fixed (Gefit.CFIXED) 4 - Factor (Gefit.CFACTOR) 5 - Delta (Gefit.CDELTA) 6 - Sum (Gefit.CSUM)
- constrains[1][i] -> Ignored if constrains[0][i] is 0, 1, 3
- Min value of the parameter if constrains[0][i] is Gefit.CQUOTED Index of fitted parameter to which it is related
- constrains[2][i] -> Ignored if constrains[0][i] is 0, 1, 3
- Max value of the parameter if constrains[0][i] is Gefit.CQUOTED Factor to apply to related parameter with index constrains[1][i] Difference with parameter with index constrains[1][i] Sum obtained when adding parameter with index constrains[1][i]
- model_deriv - function providing the derivatives of the fitting function respect to the fitted parameters.
- It will be called as model_deriv(parameters, index, x) where parameters are the current values of the fitting parameters, index is the fitting parameter index of which the the derivative has to be provided in the supplied array of x points.
linear - Flag to indicate a linear fit instead of a non-linear. Default is non-linear fit (=false)
maxiter - Maximum number of iterations (default is 100)
Output:
fitted_parameters, reduced_chi_square, uncertainties
-
PyMca5.PyMcaMath.fitting.Gefit.
LinearLeastSquaresFit
(model0, parameters0, data0, maxiter, constrains0, weightflag, model_deriv=None, deltachi=0.01, fulloutput=0, xdata=None, ydata=None, sigmadata=None)[source]¶
SimpleFitModule
Module¶
SimpleFitUserEstimatedFunctions
Module¶
Specfit
Module¶
-
class
PyMca5.PyMcaMath.fitting.Specfit.
Specfit
(*vars, **kw)[source]¶ Bases:
object
-
addbackground
(background=None, function=None, parameters=None, estimate=None)¶ method addbackground(self, background, function, parameters, estimate) Usage: self.addbackground(background,function,parameters,estimate=None) Input:
background: String with the name describing the function function: The actual function parameters: Parameters names [‘p1’,’p2’,’p3’,...] estimate: The initial parameters estimation function if any- Output:
- Returns 0 if everything went fine or a positive number in- dicating the offending parameter
-
addfilter
(filterfun, *vars, **kw)¶
-
addtheory
(theory=None, function=None, parameters=None, estimate=None, configure=None, derivative=None)¶ method addtheory(self, theory, function, parameters, estimate) Usage: self.addtheory(theory,function,parameters,estimate,configure=None)
or self.addtheory(theory=theory,
function=function, parameters=parameters, estimate=estimate)- Input:
theory: String with the name describing the function function: The actual function parameters: Parameters names [‘p1’,’p2’,’p3’,...] estimate: The initial parameters estimation function to be called if any configure: Optional function to be called to initialize parameters prior to fit derivative: Optional analytical derivative function.
Its signature should be function(parameter_values, parameter_index, x) See Gefit.py module for more information.- Output:
- Returns 0 if everything went fine or a positive number indicating the offending parameter
-
bkg_constant
(pars, x)¶ Constant background
-
bkg_internal
(pars, x)¶ Internal Background
-
bkg_linear
(pars, x)¶ Linear background
-
bkg_none
(pars, x)¶ Internal Background
-
bkg_squarefilter
(pars, x)¶ Square filter Background
-
configure
(**kw)¶ Configure the current theory passing a dictionary to the supply method
-
deletefilter
(self, *vars, **kw)¶ Deletes a filter from self.filterlist self.delete(2) just makes del(self.filterlist[2]) self.delete(filtername=’sort’) deletes any filter named sort
-
estimate
(mcafit=0)¶ Fill the parameters entries with an estimation made on the given data.
-
estimate_bkg
(xx, yy)¶
-
estimate_builtin_bkg
(xx, yy)¶
-
estimate_fun
(xx, yy, zz, xscaling=1.0, yscaling=None)¶
-
filter
(*vars, **kw)¶
-
fitfunction
(pars, t)¶
-
gendata
(*vars, **kw)¶
-
guess_fwhm
(**kw)¶
-
guess_yscaling
(*vars, **kw)¶
-
importfun
(file)¶
-
mcafit
(*var, **kw)¶
-
mcagetareas
(**kw)¶
-
mcagetresult
()¶
-
mcaregions
(peaks, fwhm)¶
-
mcaresidualssearch
(**kw)¶
-
mcaresidualssearch_old
(**kw)¶
-
myderiv
(param0, index, t0)¶
-
num_deriv
(param0, index, t0)¶
-
numderiv
(*vars, **kw)¶ numeriv(self,*vars,**kw) Usage: self.numderiv(x,y)
self.numderiv(x=x,y=y) self.numderiv()
-
pretreat
(xdata, ydata, xmin=None, xmax=None)¶
-
setbackground
(theory)¶ method: setbackground(self,background) Usage: self.setbackground(background) Input:
- theory: The name of the background to be used.
- It has to be one of the keys of self.bkgdict
- Output:
- returns 0 if everything went fine
-
setdata
(*vars, **kw)¶
-
settheory
(theory)¶ method: settheory(self,theory) Usage: self.settheory(theory) Input:
- theory: The name of the theory to be used.
- It has to be one of the keys of self.theorydict
- Output:
- returns 0 if everything went fine
-
smooth
(self, *vars, **kw)¶ Usage: self.smooth(y) self.smooth(y=y) self.smooth()
-
squarefilter
(*vars)¶
-
startfit
(mcafit=0)¶ Launch the fit routine
-
SpecfitFunctions
Module¶
-
class
PyMca5.PyMcaMath.fitting.SpecfitFunctions.
SpecfitFunctions
(config=None)[source]¶ Bases:
object
-
estimate_hypermet
(xx, yy, zzz, xscaling=1.0, yscaling=None)[source]¶ - if yscaling == None:
- try:
- yscaling=self.config[‘Yscaling’]
- except:
- yscaling=1.0
- if yscaling == 0:
- yscaling=1.0
-
periodic_gauss
(pars, x)[source]¶ Fit function periodic_gauss(pars, x) pars = [npeaks, delta, height, position, fwhm]
-
seek
(y, x=None, yscaling=None, fwhm=None, sensitivity=None, mca=None)[source]¶ - SpecfitFunctions.seek(self,y,
- x=None, yscaling=None,fwhm=None,sensitivity=None, mca=None)
It searches for peaks in the y array. If x it is given, it gives back the closest x(s) to the position of the peak(s). Otherways it gives back the index of the closest point to the peak.
-