PEATDB/plugins/VantHoffAnalysis.py
def fitElwellSchellman(self,E=None, d=None, xy=None,transwidth=50,
                                invert=False,show=True,figname=None):
        """Fit entire raw data simultaneously to the three main thermodynamic
           parameters using Elwell/Schellman method"""
        if E !=None:
            ek = E.getDataset(d)
            x,y,a, xerr,yerr = ek.getAll()
        elif xy!=None:
            x,y = xy
        else:
            return
        if invert == True:
            y = [max(y)-i for i in y[:]]
        f=plt.figure(figsize=(10,5))
        ax=f.add_subplot(121)
        p=ax.plot(x,y,'o',alpha=0.5)
        ax.set_xlabel('T');ax.set_xlabel('mdeg')
        ax.set_title('raw data')

        x1,y1,x,y = self.transformCD(x,y,transwidth,ax)

        t=[];dg=[]
        R=8.3144e-3
        for T,fu in zip(x,y):
            if fu>=1 or fu<=0:
                continue
            K = fu/(1-fu)
            deltaGt = -R * T * math.log(K)
            dg.append(deltaGt)
            t.append(T)

        ax1=f.add_subplot(122)
        p=ax1.plot(t,dg,'x',mew=2,color='black')
        ax1.set_xlabel('T'); ax1.set_ylabel('dG(T)')
        ax.set_title('stability curve')

        A,X=Fitting.doFit(expdata=zip(t,dg),model='schellman',grad=1e-9,conv=1e-9)
        fity = X.getFitLine(t)
        p=ax1.plot(t,fity,'r',lw=2)
        fd=X.getFitDict()
        self.drawParams(ax1,fd)
        deltaH=fd['deltaH']; deltacp=fd['deltacp']; Tm=fd['Tm']
        f.suptitle("Method 2 - deltaH: %2.2f deltaCp: %2.2e Tm: %2.2f" %(deltaH,deltacp,Tm),size=18)
        if show == True:
            self.showTkFigure(f)

        if figname == None: figname = d
        figname = figname.replace('.','_')
        fname = figname+'m1'+'.png'
        f.savefig(fname,dpi=300)
        print 'plot saved to %s' %os.path.abspath(fname)
        if E!=None:
            fdata = Fitting.makeFitData(X.name,vrs=X.variables)
            E.insertDataset(xydata=[t,dg], newname=d+'_vanthoff2',replace=True,fit=fdata)
            #E.saveProject()
        return deltaH, Tm, deltacp
Fit entire raw data simultaneously to the three main thermodynamic
           parameters using Elwell/Schellman method
Fit entire raw data simultaneously to the three main thermodynamic
parameters using Elwell/Schellman method
Fit entire raw data simultaneously to the three main thermodynamic parameters using Elwell / Schellman method
def fitElwellSchellman(self,E=None, d=None, xy=None,transwidth=50,
                                invert=False,show=True,figname=None):
        if E !=None:
            ek = E.getDataset(d)
            x,y,a, xerr,yerr = ek.getAll()
        elif xy!=None:
            x,y = xy
        else:
            return
        if invert == True:
            y = [max(y)-i for i in y[:]]
        f=plt.figure(figsize=(10,5))
        ax=f.add_subplot(121)
        p=ax.plot(x,y,'o',alpha=0.5)
        ax.set_xlabel('T');ax.set_xlabel('mdeg')
        ax.set_title('raw data')
        x1,y1,x,y = self.transformCD(x,y,transwidth,ax)
        t=[];dg=[]
        R=8.3144e-3
        for T,fu in zip(x,y):
            if fu>=1 or fu<=0:
                continue
            K = fu/(1-fu)
            deltaGt = -R * T * math.log(K)
            dg.append(deltaGt)
            t.append(T)
        ax1=f.add_subplot(122)
        p=ax1.plot(t,dg,'x',mew=2,color='black')
        ax1.set_xlabel('T'); ax1.set_ylabel('dG(T)')
        ax.set_title('stability curve')
        A,X=Fitting.doFit(expdata=zip(t,dg),model='schellman',grad=1e-9,conv=1e-9)
        fity = X.getFitLine(t)
        p=ax1.plot(t,fity,'r',lw=2)
        fd=X.getFitDict()
        self.drawParams(ax1,fd)
        deltaH=fd['deltaH']; deltacp=fd['deltacp']; Tm=fd['Tm']
        f.suptitle("Method 2 - deltaH: %2.2f deltaCp: %2.2e Tm: %2.2f" %(deltaH,deltacp,Tm),size=18)
        if show == True:
            self.showTkFigure(f)
        if figname == None: figname = d
        figname = figname.replace('.','_')
        fname = figname+'m1'+'.png'
        f.savefig(fname,dpi=300)
        print 'plot saved to %s' %os.path.abspath(fname)
        if E!=None:
            fdata = Fitting.makeFitData(X.name,vrs=X.variables)
            E.insertDataset(xydata=[t,dg], newname=d+'_vanthoff2',replace=True,fit=fdata)
        return deltaH, Tm, deltacp
def fitElwellSchellman ( self , E = None , d = None , xy = None , transwidth = 50 , invert = False , show = True , figname = None ) : if E != None : ek = E . getDataset ( d ) x , y , a , xerr , yerr = ek . getAll ( ) elif xy != None : x , y = xy else : return if invert == True : y = [ max ( y ) - i for i in y [ : ] ] f = plt . figure ( figsize = ( 10 , 5 ) ) ax = f . add_subplot ( 121 ) p = ax . plot ( x , y , 'o' , alpha = 0.5 ) ax . set_xlabel ( 'T' ) ; ax . set_xlabel ( 'mdeg' ) ax . set_title ( 'raw data' ) x1 , y1 , x , y = self . transformCD ( x , y , transwidth , ax ) t = [ ] ; dg = [ ] R = 8.3144e-3 for T , fu in zip ( x , y ) : if fu >= 1 or fu <= 0 : continue K = fu / ( 1 - fu ) deltaGt = - R * T * math . log ( K ) dg . append ( deltaGt ) t . append ( T ) ax1 = f . add_subplot ( 122 ) p = ax1 . plot ( t , dg , 'x' , mew = 2 , color = 'black' ) ax1 . set_xlabel ( 'T' ) ; ax1 . set_ylabel ( 'dG(T)' ) ax . set_title ( 'stability curve' ) A , X = Fitting . doFit ( expdata = zip ( t , dg ) , model = 'schellman' , grad = 1e-9 , conv = 1e-9 ) fity = X . getFitLine ( t ) p = ax1 . plot ( t , fity , 'r' , lw = 2 ) fd = X . getFitDict ( ) self . drawParams ( ax1 , fd ) deltaH = fd [ 'deltaH' ] ; deltacp = fd [ 'deltacp' ] ; Tm = fd [ 'Tm' ] f . suptitle ( "Method 2 - deltaH: %2.2f deltaCp: %2.2e Tm: %2.2f" % ( deltaH , deltacp , Tm ) , size = 18 ) if show == True : self . showTkFigure ( f ) if figname == None : figname = d figname = figname . replace ( '.' , '_' ) fname = figname + 'm1' + '.png' f . savefig ( fname , dpi = 300 ) print 'plot saved to %s' % os . path . abspath ( fname ) if E != None : fdata = Fitting . makeFitData ( X . name , vrs = X . variables ) E . insertDataset ( xydata = [ t , dg ] , newname = d + '_vanthoff2' , replace = True , fit = fdata ) return deltaH , Tm , deltacp
Fit entire raw data simultaneously to the three main thermodynamic
parameters using Elwell/Schellman method
Fit entire raw data simultaneously to the three main thermodynamic parameters using Elwell / Schellman method
"""Fit entire raw data simultaneously to the three main thermodynamic
           parameters using Elwell/Schellman method""" #E.saveProject()
self
E
d
xy
transwidth
invert
show
figname