Dispense
Navigation
Tips - Dritte
PmWiki
pmwiki.org
edit SideBar
|
< Mujpy.FFTResidues | Index | Mujpy.Server >
mugui Fit routine methods in version 1.0 wip. Complete version 1.0 wip, with working single fit, present logic, and push. Create new branch v2.0 followin PB ideas.
fit(self, model_in=daml) initialized self._the_model_ and sets up the dashboard, with private methods
_available_components_()
addcomponent(name,label)
- creates
self.model_components , a list of dictionaries {'name':name,'pars':pars} and pars is a gain a dictionary of keys 'name','value','flag',unction'
create_model(name)
checkvalidmodel(name)
chi(t,y,ey,pars)
fitplot(guess=False,plot=False) # does all the plots in the fit method. with private methods:
self._the_model_ is an instance of class mumodel (mucomponents, see below)
int2_int() # loads the model (the list of components and their required parameters) into mumodel
- as a list of lists by means of mumodel._load_data_ third argument (skipping, self), see mucomponents below
- identifies each method iterating
self.model_components ,
- extracts component
name = self.model_components[k]['name'] ,
- hence,
bndmthd = self._the_model_.__getattribute__(name)
- scans parameters looking for nonempty 'function' to translate its parameter indices from dashboard (each par is numbered progressively) to minuit (some par may be shared or calculated by functions, in general minuit has fewer parameters than the sum of parameters of the components)
int2min(return_names=False) # from internal parameter to minuit parameter (values)
load_fit(b) # read pickled fit data with pickle.load (dill)
- starts a new tab by self.fit(model.value) and sets the dashboard according to the read fit data
min2int(fitargs) # gotten rid of, also fitargs, lastfit promoted to principal container, initialized to []
min2csv(k) is a lambda function that returns the k-th parameter columns for reading that parameter in a csv file
int2csv never used! Returns a lists of lists, the inner list contains the csv indices of par and its error, and the internal index of their component
min2print(fitargs) prints on console
on_alpha_changed(change) # observe alpha dashboard text area
on_fit_request(b) # this triggers the minuit fit
- checks that at least one run is loaded
- calculates asymmetry (self.asymmetry is a mugui class public method)
- reads self.fit_range.value (a string of start stop [pack] bins)
- rebins data if pack>1
- loads parameters from dashboard into fitargs by int2min
- no global options yet, so it loads data into self._the_model
- invokes minuit for self._the_model_._chisquare_ with parameters fitargs
- does a migrad
- appends fitargs results to self.fitargs <<--- this must be changed in iminuit2
- if migrad_ok produces plot (fitplot)
on flag_changed(change) # observe parameter dashboard flags ! = ~
on_function_changed(change) # observe parameter functions (when flag is =) and check syntax by aux.muvalid
on_group_changed(change) # observe forward and backward text area, check for syntax of groups
on_integer(change) # seems not implemented (offset and version are not observed)
on_load_model(change) # when user writes a new model e.g. mgmgbgbl
- this triggers a new version of the fit tab self.fit that reinitializes self._the_model_
on_parvalue_changed(change) # check it is a float
on_plot_request(b) # invokes fitplot with plot=True
mucomponent methods
mumodel class follows the model name logic, typically damgbl is a dalpha correction da + a gaussian muon precession mg + a lorentzian decay ml
__init__(self) sets constants and help
_load_data_(self,x,y,_components_,_alpha_,e=1)
- stores x,y,e in self._x_, self._y_, self._e_
- removed self._global_ _locals_ (replaced by switchyards)
- _alpha_ is alpha value, defaults are for unnormalized chi_square, single fit
- _components_ is a list of lists [[method,[key,key,key] isminuit],...,[method,[key,key,key], isminuit], where da method is [], and eval(key) produces the parameter value
- self._components_ replicates it excluding da, if present, and self._ntruecomponents_ stores their total number save da, if present
- the core is performed as
f += component(self._x_,*p_comp) where component is the method and p_comp is a list of eval(key) values (*p_comp produces separate values form list)
- switch into 4 replicas, can fill one at a time:
_single_load_data_(self,x,y,_components_,_alpha:,e=1,_nglobals_=None,_locals_=None) , (A1 and B1) This is like now, remove ifs
- must assign _add_ to _add_single_
_multi_load_data_(self,x,y,_components_,_alpha:,e=1,_nglobals_=None,_locals_=None) , (A2 and B2) This is multi group, single run
- must assign _add_ to _add_multi_
_suite_load_data_(self,x,y,_components_,_alpha:,e=1,_nglobals_=None,_locals_=None) , (C1) This is suite, single group
- must assign _add_ to _add_suite_
_suite_multi_load_data_(self,x,y,_components_,_alpha:,e=1,_nglobals_=None,_locals_=None) (C2) This is suite multi group
- must assign _add_ to _add_suite_multi_
_add_(self,x,*argv) with
- x, since it may be computed either on data points (minuit) or on a denser array (plot)
- *argv list of par values at the given iteration
- _add_ distributes them among components and adds the sum for all (but da that is treated at the end)
- uses eval despite it is not recommended
- knows components by self._components_ and self._ntruecomponents_ defined in _load_data_
- deals with residues fft that has an additional flag (to include or exclude components)
_fft_init_ see above
_include_all_ reset after fft use
_chisquare_(self,*argv,axis=None) calculates chi2, sum(self._add_(self._x_,*argv) - self._y_)/self._e_)**2 ,axis=axis)
- public methods all the components, ml, mg, b, bg, bs, kt, ... *** all must accept x as first parameter to both compute fcn and plot function
- usage, mugui on_fit_request call _load_data_ providing t, asymmetries, and the _components_ list of lists as int2_int()
< Mujpy.FFTResidues | Index | Mujpy.Server >
|