ParkFitting module contains SansParameter,Model,Data FitArrange, ParkFit,Parameter classes.All listed classes work together to perform a simple fit with park optimizer.
Bases: park.assembly.Assembly
Interrupt the current function evaluation.
Forward this to the currently executing model if possible.
Extend result from the fit with the calculated parameters.
Add a model to the end of set.
Parameters: | fitness – the fitting model |
---|
The fitting model can be an instance of park.assembly.Fitness, or a tuple of (park.model.Model,`park.data.Data1D`) :param weight: model weighting (usually 1.0) :param isfitted: whether model should be fit (equivalent to weight 0.)
Return the covariance matrix inv(J’J) at point p.
Recalculate the theory functions, and from them, the residuals and chisq.
Note : | Call this after the parameters have been updated. |
---|
Return an alphabetical list of the fitting parameters.
This function is called once at the beginning of a fit, and serves as a convenient place to precalculate what can be precalculated such as the set of fitting parameters and the parameter expressions evaluator.
Add a model to a particular position in the set.
Returns true if the parameter set is in a feasible region of the modeling space.
Query if a particular model is fitted.
Set isfitted to value if value is supplied.
Parameters: |
|
---|
Returns the derivative wrt the fit parameters at point p.
Numeric derivatives are calculated based on step, where step is the portion of the total range for parameter j, or the portion of point value p_j if the range on parameter j is infinite.
Details to send back to the fitting client on an improved fit.
status is ‘start’, ‘step’ or ‘end’ depending if this is the first result to return, an improved result, or the final result.
[Not implemented]
Set the parameters resulting from the fit into the parameter set, and update the calculated expression.
The parameter values may be retrieved by walking the assembly.parameterset tree, checking each parameter for isfitted, iscomputed, or isfixed. For example:
assembly.set_result(result)
for p in assembly.parameterset.flatten():
if p.isfitted():
print "%s %g in [%g,%g]"%(p.path,p.value,p.range[0],p.range[1])
elif p.iscomputed():
print "%s computed as %g"%(p.path.p.value)
This does not calculate the function or the residuals for these parameters. You can call assembly.eval() to do this. The residuals will be set in assembly[i].residuals. The theory and data are model specific, and can be found in assembly[i].fitness.data.
Return parameter uncertainty.
This is just the sqrt diagonal of covariance matrix inv(J’J) at point p.
Query the weight on a particular model.
Set weight to value if value is supplied.
Parameters : |
|
---|---|
Returns: | model weight |
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. |
---|
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)])
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: |
|
---|---|
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 |
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 |
return the self.selected value of the fit problem of id
Parameters: | id – the id of the problem |
---|
remove fitarrange in id
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 |
---|
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: |
|
---|
set a model on a given in the fit engine.
Parameters: | model – sans.models type |
---|
Parameters: |
|
---|---|
Note : | pars must contains only name of existing model’s parameters |