PEATDB/Ekin/Fitting.py
def doFit(ekindata=None, fitdata=None, model=None, expdata=None, vrs=None,
                noiter=50, conv=None, grad=None, LM_damper=1.0,
                guess=True, silent=False, callback=None,
                changevars=None, startvalues=None):
    """General class method for doing a fit of provided ekin data and model
       Returns the ekin fit data and the fitter instance used"""

    if conv == None:
        conv = conv
    if grad == None:
        grad = grad

    def updatenow(diff, vrs, fitvals, c, X):
        """Dummy callback for fit update"""
        pass
    if callback == None:
        callback = updatenow
        
    if expdata == None:            
        expdata = getExpData(ekindata)

    if expdata == None or len(expdata)<=1:
        print 'Not enough data to fit'
        return None, None
   
    if fitdata != None and len(fitdata) > 1:
        X = makeFitter(fitdata, expdata=expdata, callback=callback)
    else:
        X = getFitter(model, expdata=expdata, vrs=vrs, callback=callback)
    if X == None:
        print 'No fitter found!'
        return None, None

    if startvalues!=None:
        X.variables = startvalues
    if guess == True:
        X.guess_start()
        if silent == False:
            print 'guessed good start values', X.variables

    # Set the change vars
    X.setChangeVars(changevars)

    # Now do the fitting
    status, variables = X.fit(rounds = noiter, error_crit = conv, gradient_crit = grad,
                              damper_adjustment_factor = 2.0, LM_damper = LM_damper, silent=silent)
    fitdata = makeFitData(model, X.variables, X.getError())

    if silent == False:
        print X.getResult()
    return fitdata, X
General class method for doing a fit of provided ekin data and model
       Returns the ekin fit data and the fitter instance used
General class method for doing a fit of provided ekin data and model
Returns the ekin fit data and the fitter instance used
General class method for doing a fit of provided ekin data and model Returns the ekin fit data and the fitter instance used
def doFit(ekindata=None, fitdata=None, model=None, expdata=None, vrs=None,
                noiter=50, conv=None, grad=None, LM_damper=1.0,
                guess=True, silent=False, callback=None,
                changevars=None, startvalues=None):
    if conv == None:
        conv = conv
    if grad == None:
        grad = grad
    def updatenow(diff, vrs, fitvals, c, X):
        pass
    if callback == None:
        callback = updatenow
    if expdata == None:            
        expdata = getExpData(ekindata)
    if expdata == None or len(expdata)<=1:
        print 'Not enough data to fit'
        return None, None
    if fitdata != None and len(fitdata) > 1:
        X = makeFitter(fitdata, expdata=expdata, callback=callback)
    else:
        X = getFitter(model, expdata=expdata, vrs=vrs, callback=callback)
    if X == None:
        print 'No fitter found!'
        return None, None
    if startvalues!=None:
        X.variables = startvalues
    if guess == True:
        X.guess_start()
        if silent == False:
            print 'guessed good start values', X.variables
    X.setChangeVars(changevars)
    status, variables = X.fit(rounds = noiter, error_crit = conv, gradient_crit = grad,
                              damper_adjustment_factor = 2.0, LM_damper = LM_damper, silent=silent)
    fitdata = makeFitData(model, X.variables, X.getError())
    if silent == False:
        print X.getResult()
    return fitdata, X
def doFit ( ekindata = None , fitdata = None , model = None , expdata = None , vrs = None , noiter = 50 , conv = None , grad = None , LM_damper = 1.0 , guess = True , silent = False , callback = None , changevars = None , startvalues = None ) : if conv == None : conv = conv if grad == None : grad = grad def updatenow ( diff , vrs , fitvals , c , X ) : """Dummy callback for fit update""" pass if callback == None : callback = updatenow if expdata == None : expdata = getExpData ( ekindata ) if expdata == None or len ( expdata ) <= 1 : print 'Not enough data to fit' return None , None if fitdata != None and len ( fitdata ) > 1 : X = makeFitter ( fitdata , expdata = expdata , callback = callback ) else : X = getFitter ( model , expdata = expdata , vrs = vrs , callback = callback ) if X == None : print 'No fitter found!' return None , None if startvalues != None : X . variables = startvalues if guess == True : X . guess_start ( ) if silent == False : print 'guessed good start values' , X . variables X . setChangeVars ( changevars ) status , variables = X . fit ( rounds = noiter , error_crit = conv , gradient_crit = grad , damper_adjustment_factor = 2.0 , LM_damper = LM_damper , silent = silent ) fitdata = makeFitData ( model , X . variables , X . getError ( ) ) if silent == False : print X . getResult ( ) return fitdata , X
General class method for doing a fit of provided ekin data and model
Returns the ekin fit data and the fitter instance used
General class method for doing a fit of provided ekin data and model Returns the ekin fit data and the fitter instance used
"""General class method for doing a fit of provided ekin data and model
       Returns the ekin fit data and the fitter instance used""" """Dummy callback for fit update""" # Set the change vars # Now do the fitting
ekindata
fitdata
model
expdata
vrs
noiter
conv
grad
LM_damper
guess
silent
callback
changevars
startvalues