DataPipeline/Base.py
def processFits(self, rawdata, models=None, variables=None, ind=None,
                    parentkey='', Em=None):
        """Process the a dict of possibly nested dicts
            ind: the index indicating the level of recursion, used to find the right model
                 and variable
            parentkey: the label from the parent dict that will be matched to the fits
            returns: final set of fits"""

        nesting = self.getDictNesting(rawdata)

        if models == None:
            models = self.models
            variables = self.variables

        if len(models) == 0:
            print 'no models found for fitting!'
            return None, None
        if ind == None:
            ind = len(models)-1

        def getmodelinfo():
            model = models[ind][1]
            try:
                var = variables[ind][1]
            except:
                var = ''
            if var == '':
                var = self.findVariableName(model)
            return model, var

        currmodel,currvariable = getmodelinfo()
        #print models, variables
        #print nesting,currmodel,currvariable,parentkey

        if nesting == 0:
            #bottom level of nesting, we just fit
            xerror = float(self.xerror); yerror = float(self.yerror)
            E = Utilities.getEkinProject(rawdata, xerror=xerror, yerror=yerror)
            print rawdata.keys(), parentkey, currmodel
            E,fit = self.getFits(E, currmodel, currvariable, str(parentkey))
            Em.addProject(E, label=parentkey)
            return E,fit
        else:
            #if there is nesting we pass the subdicts recursively and get their fits
            fitdata = {}
            for l in rawdata.keys():
                if parentkey != '':
                    lbl = str(l)+'_'+str(parentkey)
                else:
                    lbl = l
                #now we pass each child node recursively
                E,fit = self.processFits(rawdata[l], ind=ind-1, parentkey=lbl, Em=Em)
                fitdata[l] = fit
            E = Utilities.getEkinProject(fitdata)
            if parentkey == '': parentkey = 'final'
            E,fit = self.getFits(E, currmodel, currvariable, str(parentkey))
            Em.addProject(E,label=parentkey)
            return E,fit
Process the a dict of possibly nested dicts
            ind: the index indicating the level of recursion, used to find the right model
                 and variable
            parentkey: the label from the parent dict that will be matched to the fits
            returns: final set of fits
Process the a dict of possibly nested dicts
ind: the index indicating the level of recursion, used to find the right model
and variable
parentkey: the label from the parent dict that will be matched to the fits
returns: final set of fits
Process the a dict of possibly nested dicts ind : the index indicating the level of recursion used to find the right model and variable parentkey : the label from the parent dict that will be matched to the fits returns : final set of fits
def processFits(self, rawdata, models=None, variables=None, ind=None,
                    parentkey='', Em=None):
        nesting = self.getDictNesting(rawdata)
        if models == None:
            models = self.models
            variables = self.variables
        if len(models) == 0:
            print 'no models found for fitting!'
            return None, None
        if ind == None:
            ind = len(models)-1
        def getmodelinfo():
            model = models[ind][1]
            try:
                var = variables[ind][1]
            except:
                var = ''
            if var == '':
                var = self.findVariableName(model)
            return model, var
        currmodel,currvariable = getmodelinfo()
        if nesting == 0:
            xerror = float(self.xerror); yerror = float(self.yerror)
            E = Utilities.getEkinProject(rawdata, xerror=xerror, yerror=yerror)
            print rawdata.keys(), parentkey, currmodel
            E,fit = self.getFits(E, currmodel, currvariable, str(parentkey))
            Em.addProject(E, label=parentkey)
            return E,fit
        else:
            fitdata = {}
            for l in rawdata.keys():
                if parentkey != '':
                    lbl = str(l)+'_'+str(parentkey)
                else:
                    lbl = l
                E,fit = self.processFits(rawdata[l], ind=ind-1, parentkey=lbl, Em=Em)
                fitdata[l] = fit
            E = Utilities.getEkinProject(fitdata)
            if parentkey == '': parentkey = 'final'
            E,fit = self.getFits(E, currmodel, currvariable, str(parentkey))
            Em.addProject(E,label=parentkey)
            return E,fit
def processFits ( self , rawdata , models = None , variables = None , ind = None , parentkey = '' , Em = None ) : nesting = self . getDictNesting ( rawdata ) if models == None : models = self . models variables = self . variables if len ( models ) == 0 : print 'no models found for fitting!' return None , None if ind == None : ind = len ( models ) - 1 def getmodelinfo ( ) : model = models [ ind ] [ 1 ] try : var = variables [ ind ] [ 1 ] except : var = '' if var == '' : var = self . findVariableName ( model ) return model , var currmodel , currvariable = getmodelinfo ( ) if nesting == 0 : xerror = float ( self . xerror ) ; yerror = float ( self . yerror ) E = Utilities . getEkinProject ( rawdata , xerror = xerror , yerror = yerror ) print rawdata . keys ( ) , parentkey , currmodel E , fit = self . getFits ( E , currmodel , currvariable , str ( parentkey ) ) Em . addProject ( E , label = parentkey ) return E , fit else : fitdata = { } for l in rawdata . keys ( ) : if parentkey != '' : lbl = str ( l ) + '_' + str ( parentkey ) else : lbl = l E , fit = self . processFits ( rawdata [ l ] , ind = ind - 1 , parentkey = lbl , Em = Em ) fitdata [ l ] = fit E = Utilities . getEkinProject ( fitdata ) if parentkey == '' : parentkey = 'final' E , fit = self . getFits ( E , currmodel , currvariable , str ( parentkey ) ) Em . addProject ( E , label = parentkey ) return E , fit
Process the a dict of possibly nested dicts
ind: the index indicating the level of recursion, used to find the right model
and variable
parentkey: the label from the parent dict that will be matched to the fits
returns: final set of fits
Process the a dict of possibly nested dicts ind : the index indicating the level of recursion used to find the right model and variable parentkey : the label from the parent dict that will be matched to the fits returns : final set of fits
"""Process the a dict of possibly nested dicts
            ind: the index indicating the level of recursion, used to find the right model
                 and variable
            parentkey: the label from the parent dict that will be matched to the fits
            returns: final set of fits""" #print models, variables #print nesting,currmodel,currvariable,parentkey #bottom level of nesting, we just fit #if there is nesting we pass the subdicts recursively and get their fits #now we pass each child node recursively
self
rawdata
models
variables
ind
parentkey
Em