PEATDB/plugins/KineticsAnalysis.py
def fitportion(self, edata, currfit, reverse=True, percs=None, X=None):
        """Compare fits using different portions of the data and return best.
           This method is not that reliable.. as its biased towards the fits with
           least no of points as they have lower sum sq diffs... """
        import copy
        if percs==None:
            percs = [0.7, 0.5, 0.3]

        currsqdiff = 100
        currdata = edata
        currX=X
        for perc in percs:
            tmpdata = copy.deepcopy(edata)
            ekd = EkinDataset(tmpdata)
            kys=ekd.DPkeys()
            lenp = int(len(kys)*perc)
            if reverse == True:
                i=len(kys)
                kys.reverse()
                for e in kys:
                    ekd.setDPActive(e, 0)
                    if i==lenp or not e in kys:
                        break
                    i-=1
            else:
                i=0
                for e in kys:
                    ekd.setDPActive(e, 0)
                    if i==lenp or not e in kys:
                        break
                    i+=1
            try:
                newfit, X = Fitting.doFit(tmpdata, model='Linear', conv=1e-8, grad=1e-8, silent=True)
                newsqdiff = X.getpercSqDiff()
            except:
                continue

            if newsqdiff < currsqdiff:
                best=perc
                currdata = tmpdata
                currfit = newfit
                currsqdiff = newsqdiff
                currX = X
        return currdata, currfit, currX
Compare fits using different portions of the data and return best.
           This method is not that reliable.. as its biased towards the fits with
           least no of points as they have lower sum sq diffs... 
Compare fits using different portions of the data and return best.
This method is not that reliable.. as its biased towards the fits with
least no of points as they have lower sum sq diffs
Compare fits using different portions of the data and return best . This method is not that reliable .. as its biased towards the fits with least no of points as they have lower sum sq diffs
def fitportion(self, edata, currfit, reverse=True, percs=None, X=None):
        import copy
        if percs==None:
            percs = [0.7, 0.5, 0.3]
        currsqdiff = 100
        currdata = edata
        currX=X
        for perc in percs:
            tmpdata = copy.deepcopy(edata)
            ekd = EkinDataset(tmpdata)
            kys=ekd.DPkeys()
            lenp = int(len(kys)*perc)
            if reverse == True:
                i=len(kys)
                kys.reverse()
                for e in kys:
                    ekd.setDPActive(e, 0)
                    if i==lenp or not e in kys:
                        break
                    i-=1
            else:
                i=0
                for e in kys:
                    ekd.setDPActive(e, 0)
                    if i==lenp or not e in kys:
                        break
                    i+=1
            try:
                newfit, X = Fitting.doFit(tmpdata, model='Linear', conv=1e-8, grad=1e-8, silent=True)
                newsqdiff = X.getpercSqDiff()
            except:
                continue
            if newsqdiff < currsqdiff:
                best=perc
                currdata = tmpdata
                currfit = newfit
                currsqdiff = newsqdiff
                currX = X
        return currdata, currfit, currX
def fitportion ( self , edata , currfit , reverse = True , percs = None , X = None ) : import copy if percs == None : percs = [ 0.7 , 0.5 , 0.3 ] currsqdiff = 100 currdata = edata currX = X for perc in percs : tmpdata = copy . deepcopy ( edata ) ekd = EkinDataset ( tmpdata ) kys = ekd . DPkeys ( ) lenp = int ( len ( kys ) * perc ) if reverse == True : i = len ( kys ) kys . reverse ( ) for e in kys : ekd . setDPActive ( e , 0 ) if i == lenp or not e in kys : break i -= 1 else : i = 0 for e in kys : ekd . setDPActive ( e , 0 ) if i == lenp or not e in kys : break i += 1 try : newfit , X = Fitting . doFit ( tmpdata , model = 'Linear' , conv = 1e-8 , grad = 1e-8 , silent = True ) newsqdiff = X . getpercSqDiff ( ) except : continue if newsqdiff < currsqdiff : best = perc currdata = tmpdata currfit = newfit currsqdiff = newsqdiff currX = X return currdata , currfit , currX
Compare fits using different portions of the data and return best.
Compare fits using different portions of the data and return best .
"""Compare fits using different portions of the data and return best.
           This method is not that reliable.. as its biased towards the fits with
           least no of points as they have lower sum sq diffs... """
self
edata
currfit
reverse
percs
X