ParkFitting

:mod:` sans.fit.ParkFitting`

ParkFitting module contains SansParameter,Model,Data FitArrange, ParkFit,Parameter classes.All listed classes work together to perform a simple fit with park optimizer.

class sans.fit.ParkFitting.ParkFit

Bases: sans.fit.AbstractFitEngine.FitEngine

ParkFit performs the Fit.This class can be used as follow: #Do the fit Park create an engine: engine = ParkFit() Use data must be of type plottable Use a sans model

Add data with a dictionnary of FitArrangeList where Uid is a key and data is saved in FitArrange object. engine.set_data(data,Uid)

Set model parameter “M1”= model.name add {model.parameter.name:value}.

Note :Set_param() if used must always preceded set_model() for the fit to be performed.

engine.set_param( model,”M1”, {‘A’:2,’B’:4})

Add model with a dictionnary of FitArrangeList{} where Uid is a key and model is save in FitArrange object. engine.set_model(model,Uid)

engine.fit return chisqr,[model.parameter 1,2,..],[[err1....][..err2...]] chisqr1, out1, cov1=engine.fit({model.parameter.name:value},qmin,qmax)

Note :{model.parameter.name:value} is ignored in fit function since the user should make sure to call set_param himself.
createAssembly()
Extract sansmodel and sansdata from self.FitArrangelist ={Uid:FitArrange} Create parkmodel and park data ,form a list couple of parkmodel and parkdata create an assembly self.problem= park.Assembly([(parkmodel,parkdata)])
fit(q=None, handler=None, curr_thread=None)

Performs fit with park.fit module.It can perform fit with one model and a set of data, more than two fit of one model and sets of data or fit with more than two model associated with their set of data and constraints

Parameters:
  • pars – Dictionary of parameter names for the model and their values.
  • qmin – The minimum value of data’s range to be fit
  • qmax – The maximum value of data’s range to be fit
Note :

all parameter are ignored most of the time.Are just there to keep ScipyFit and ParkFit interface the same.

Returns:

result.fitness Value of the goodness of fit metric

Returns:

result.pvec list of parameter with the best value found during fitting

Returns:

result.cov Covariance matrix

get_model(Uid)
Parameters:
  • Uid – Uid is key in the dictionary containing the model to return
Returns:

a model at this uid or None if no FitArrange element was created with this Uid

get_problem_to_fit(Uid)

return the self.selected value of the fit problem of Uid

Parameters:
  • Uid – the Uid of the problem
remove_Fit_Problem(Uid)
remove fitarrange in Uid
select_problem_for_fit(Uid, value)

select a couple of model and data at the Uid position in dictionary and set in self.selected value to value

Parameters:
  • value – the value to allow fitting. can only have the value one or zero
set_data(data, Uid, smearer=None, qmin=None, qmax=None)

Receives plottable, creates a list of data to fit,set data in a FitArrange object and adds that object in a dictionary with key Uid.

Parameters:
  • data – data added
  • Uid – unique key corresponding to a fitArrange object with data
set_model(model, Uid, pars=[], constraints=[])

set a model on a given uid in the fit engine.

Parameters:
  • model – sans.models type
  • Uid – is the key of the fitArrange dictionary where model is saved as a value
  • pars – the list of parameters to fit
  • constraints

    list of tuple (name of parameter, value of parameters) the value of parameter must be a string to constraint 2 different parameters. Example: we want to fit 2 model M1 and M2 both have parameters A and B. constraints can be:

    constraints = [(M1.A, M2.B+2), (M1.B= M2.A *5),...,]
Note :

pars must contains only name of existing model’s parameters

Table Of Contents

Previous topic

Fitting

Next topic

ScipyFitting

This Page