Changeset 373 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Sep 16, 2011 3:51:06 PM (11 years ago)
Author:
vondreele
Message:

new covariance item in tree
new covariance matrix plotting
save cov matrix in file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r372 r373  
    621621            elif bakType == 'cosine':
    622622                yb += parmDict[key]*npcosd(xdata*iBak)
    623     elif bakType in ['interpolate',]:
     623    elif bakType in ['lin interpolate','inv interpolate','log interpolate',]:
    624624        if nBak == 1:
    625625            yb = np.ones_like(xdata)*parmDict[pfx+'Back:0']
     
    630630            yb = parmDict[pfx+'Back:0']*T1+parmDict[pfx+'Back:1']*T2
    631631        else:
    632             bakPos = np.linspace(xdata[0],xdata[-1],nBak,True)
     632            if bakType == 'lin interpolate':
     633                bakPos = np.linspace(xdata[0],xdata[-1],nBak,True)
     634            elif bakType == 'inv interpolate':
     635                bakPos = 1./np.linspace(1./xdata[-1],1./xdata[0],nBak,True)
     636            elif bakType == 'log interpolate':
     637                bakPos = np.exp(np.linspace(np.log(xdata[0]),np.log(xdata[-1]),nBak,True))
     638            bakPos[0] = xdata[0]
     639            bakPos[-1] = xdata[-1]
    633640            bakVals = np.zeros(nBak)
    634641            for i in range(nBak):
     
    654661            elif bakType == 'cosine':
    655662                dydb[iBak] = npcosd(xdata*iBak)
    656     elif bakType in ['interpolate',]:
     663    elif bakType in ['lin interpolate','inv interpolate','log interpolate',]:
    657664        if nBak == 1:
    658665            dydb[0] = np.ones_like(xdata)
     
    663670            dydb = [T1,T2]
    664671        else:
    665             bakPos = np.linspace(xdata[0],xdata[-1],nBak,True)
     672            if bakType == 'lin interpolate':
     673                bakPos = np.linspace(xdata[0],xdata[-1],nBak,True)
     674            elif bakType == 'inv interpolate':
     675                bakPos = 1./np.linspace(1./xdata[-1],1./xdata[0],nBak,True)
     676            elif bakType == 'log interpolate':
     677                bakPos = np.exp(np.linspace(np.log(xdata[0]),np.log(xdata[-1]),nBak,True))
     678            bakPos[0] = xdata[0]
     679            bakPos[-1] = xdata[-1]
    666680            dx = bakPos[1]-bakPos[0]
    667681            for i,pos in enumerate(bakPos):
    668682                if i == 0:
    669                     dydb[0] = np.where(xdata<bakPos[1],(bakPos[1]-xdata)/dx,0.)
     683                    dydb[0] = np.where(xdata<bakPos[1],(bakPos[1]-xdata)/(bakPos[1]-bakPos[0]),0.)
    670684                elif i == len(bakPos)-1:
    671                     dydb[i] = np.where(xdata>bakPos[-2],(bakPos[-1]-xdata)/dx,0.)
     685                    dydb[i] = np.where(xdata>bakPos[-2],(bakPos[-1]-xdata)/(bakPos[-1]-bakPos[-2]),0.)
    672686                else:
    673687                    dydb[i] = np.where(xdata>bakPos[i],
    674                         np.where(xdata<bakPos[i+1],(bakPos[i+1]-xdata)/dx,0.),
    675                         np.where(xdata>bakPos[i-1],(xdata-bakPos[i-1])/dx,0.))
     688                        np.where(xdata<bakPos[i+1],(bakPos[i+1]-xdata)/(bakPos[i+1]-bakPos[i]),0.),
     689                        np.where(xdata>bakPos[i-1],(xdata-bakPos[i-1])/(bakPos[i]-bakPos[i-1]),0.))
    676690    return dydb
    677691
Note: See TracChangeset for help on using the changeset viewer.