ScipyFitting

:mod:` sans.fit.ScipyFitting`

ScipyFitting module contains FitArrange , ScipyFit, Parameter classes.All listed classes work together to perform a simple fit with scipy optimizer.

class sans.fit.ScipyFitting.ScipyFit

Bases: sans.fit.AbstractFitEngine.FitEngine

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

Add data with a dictionnary of FitArrangeDict 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.In case of Scipyfit set_param is called in fit () automatically.

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

Add model with a dictionnary of FitArrangeDict{} 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)

fit(q=None, handler=None, curr_thread=None, ftol=1.49012e-008)
get_model(id)
Parameters:id – id is key in the dictionary containing the model to return
Returns:a model at this id or None if no FitArrange element was created with this id
get_problem_to_fit(id)

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

Parameters:id – the id of the problem
remove_fit_problem(id)

remove fitarrange in id

select_problem_for_fit(id, value)

select a couple of model and data at the id 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, id, 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 id.

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

set a model on a given in the fit engine.

Parameters:model – sans.models type
:param : is the key of the fitArrange dictionary where model is
saved as a value
Parameters:
  • 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

class sans.fit.ScipyFitting.fitresult(model=None, param_list=None)

Bases: object

Storing fit result

print_summary()
set_fitness(fitness)
set_model(model)

Table Of Contents

Previous topic

ParkFitting

This Page