Changeset 1682 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Feb 28, 2015 9:16:41 AM (8 years ago)
Author:
vondreele
Message:

do sums of Bragg intensity, and background terms put results into .lst file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r1662 r1682  
    525525    cw = np.diff(xdata)
    526526    cw = np.append(cw,cw[-1])
     527    sumBk = [0.,0.,0]
    527528    while True:
    528529        key = pfx+'Back;'+str(nBak)
     
    531532        else:
    532533            break
     534#empirical functions
    533535    if bakType in ['chebyschev','cosine']:
    534536        dt = xdata[-1]-xdata[0]   
     
    536538            key = pfx+'Back;'+str(iBak)
    537539            if bakType == 'chebyschev':
    538                 yb += parmDict[key]*(2.*(xdata-xdata[0])/dt-1.)**iBak
     540                ybi = parmDict[key]*(2.*(xdata-xdata[0])/dt-1.)**iBak
    539541            elif bakType == 'cosine':
    540                 yb += parmDict[key]*npcosd(xdata*iBak)
     542                ybi = parmDict[key]*npcosd(xdata*iBak)
     543            yb += ybi
     544            sumBk[0] = np.sum(ybi)
    541545    elif bakType in ['lin interpolate','inv interpolate','log interpolate',]:
    542546        if nBak == 1:
     
    561565            bakInt = si.interp1d(bakPos,bakVals,'linear')
    562566            yb = bakInt(xdata)
     567        sumBk[0] = np.sum(yb)
     568#Debye function       
    563569    if pfx+'difC' in parmDict:
    564570        ff = 1.
     
    578584            dbR = parmDict[pfx+'DebyeR;'+str(iD)]
    579585            dbU = parmDict[pfx+'DebyeU;'+str(iD)]
    580             yb += ff*dbA*np.sin(q*dbR)*np.exp(-dbU*q**2)/(q*dbR)
     586            ybi = ff*dbA*np.sin(q*dbR)*np.exp(-dbU*q**2)/(q*dbR)
     587            yb += ybi
     588            sumBk[1] += np.sum(ybi)
    581589            iD += 1       
    582590        except KeyError:
    583591            break
     592#peaks
    584593    iD = 0
    585594    while True:
     
    603612                iFin = np.searchsorted(xdata,pkP+fmax)
    604613            if 'C' in dataType:
    605                 yb[iBeg:iFin] += pkI*getFCJVoigt3(pkP,pkS,pkG,0.002,xdata[iBeg:iFin])
     614                ybi = pkI*getFCJVoigt3(pkP,pkS,pkG,0.002,xdata[iBeg:iFin])
     615                yb[iBeg:iFin] += ybi
    606616            else:   #'T'OF
    607                 yb[iBeg:iFin] += pkI*getEpsVoigt(pkP,1.,1.,pkS,pkG,xdata[iBeg:iFin])
     617                ybi = pkI*getEpsVoigt(pkP,1.,1.,pkS,pkG,xdata[iBeg:iFin])
     618                yb[iBeg:iFin] += ybi
     619            sumBk[2] += np.sum(ybi)
    608620            iD += 1       
    609621        except KeyError:
     
    612624            print '**** WARNING - backround peak '+str(iD)+' sigma is negative; fix & try again ****'
    613625            break       
    614     return yb
     626    return yb,sumBk
    615627   
    616628def getBackgroundDerv(hfx,parmDict,bakType,dataType,xdata):
     
    836848    'needs a doc string'
    837849   
    838     yb = getBackground('',parmDict,bakType,dataType,xdata)
     850    yb = getBackground('',parmDict,bakType,dataType,xdata)[0]
    839851    yc = np.zeros_like(yb)
    840852    cw = np.diff(xdata)
     
    15741586       
    15751587    sigDict = dict(zip(varyList,sig))
    1576     yb[xBeg:xFin] = getBackground('',parmDict,bakType,dataType,x[xBeg:xFin])
     1588    yb[xBeg:xFin] = getBackground('',parmDict,bakType,dataType,x[xBeg:xFin])[0]
    15771589    yc[xBeg:xFin] = getPeakProfile(dataType,parmDict,x[xBeg:xFin],varyList,bakType)
    15781590    yd[xBeg:xFin] = y[xBeg:xFin]-yc[xBeg:xFin]
     
    16851697    msg = 'test '
    16861698    gplot = plotter.add('FCJ-Voigt, 11BM').gca()
    1687     gplot.plot(xdata,getBackground('',parmDict0,bakType,'PXC',xdata))   
     1699    gplot.plot(xdata,getBackground('',parmDict0,bakType,'PXC',xdata)[0])   
    16881700    gplot.plot(xdata,getPeakProfile(parmDict0,xdata,varyList,bakType))
    16891701    fplot = plotter.add('FCJ-Voigt, Ka1+2').gca()
    1690     fplot.plot(xdata,getBackground('',parmDict1,bakType,'PXC',xdata))   
     1702    fplot.plot(xdata,getBackground('',parmDict1,bakType,'PXC',xdata)[0])   
    16911703    fplot.plot(xdata,getPeakProfile(parmDict1,xdata,varyList,bakType))
    16921704   
Note: See TracChangeset for help on using the changeset viewer.