Changeset 1682
- Timestamp:
- Feb 28, 2015 9:16:41 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpwd.py
r1662 r1682 525 525 cw = np.diff(xdata) 526 526 cw = np.append(cw,cw[-1]) 527 sumBk = [0.,0.,0] 527 528 while True: 528 529 key = pfx+'Back;'+str(nBak) … … 531 532 else: 532 533 break 534 #empirical functions 533 535 if bakType in ['chebyschev','cosine']: 534 536 dt = xdata[-1]-xdata[0] … … 536 538 key = pfx+'Back;'+str(iBak) 537 539 if bakType == 'chebyschev': 538 yb += parmDict[key]*(2.*(xdata-xdata[0])/dt-1.)**iBak540 ybi = parmDict[key]*(2.*(xdata-xdata[0])/dt-1.)**iBak 539 541 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) 541 545 elif bakType in ['lin interpolate','inv interpolate','log interpolate',]: 542 546 if nBak == 1: … … 561 565 bakInt = si.interp1d(bakPos,bakVals,'linear') 562 566 yb = bakInt(xdata) 567 sumBk[0] = np.sum(yb) 568 #Debye function 563 569 if pfx+'difC' in parmDict: 564 570 ff = 1. … … 578 584 dbR = parmDict[pfx+'DebyeR;'+str(iD)] 579 585 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) 581 589 iD += 1 582 590 except KeyError: 583 591 break 592 #peaks 584 593 iD = 0 585 594 while True: … … 603 612 iFin = np.searchsorted(xdata,pkP+fmax) 604 613 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 606 616 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) 608 620 iD += 1 609 621 except KeyError: … … 612 624 print '**** WARNING - backround peak '+str(iD)+' sigma is negative; fix & try again ****' 613 625 break 614 return yb 626 return yb,sumBk 615 627 616 628 def getBackgroundDerv(hfx,parmDict,bakType,dataType,xdata): … … 836 848 'needs a doc string' 837 849 838 yb = getBackground('',parmDict,bakType,dataType,xdata) 850 yb = getBackground('',parmDict,bakType,dataType,xdata)[0] 839 851 yc = np.zeros_like(yb) 840 852 cw = np.diff(xdata) … … 1574 1586 1575 1587 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] 1577 1589 yc[xBeg:xFin] = getPeakProfile(dataType,parmDict,x[xBeg:xFin],varyList,bakType) 1578 1590 yd[xBeg:xFin] = y[xBeg:xFin]-yc[xBeg:xFin] … … 1685 1697 msg = 'test ' 1686 1698 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]) 1688 1700 gplot.plot(xdata,getPeakProfile(parmDict0,xdata,varyList,bakType)) 1689 1701 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]) 1691 1703 fplot.plot(xdata,getPeakProfile(parmDict1,xdata,varyList,bakType)) 1692 1704 -
trunk/GSASIIstrIO.py
r1664 r1682 2475 2475 print >>pFile,' Final refinement RF, RF^2 = %.2f%%, %.2f%% on %d reflections' \ 2476 2476 %(Histogram['Residuals'][pfx+'Rf'],Histogram['Residuals'][pfx+'Rf^2'],Histogram['Residuals'][pfx+'Nref']) 2477 print >>pFile,' Bragg intensity sum = %.3g'%(Histogram['Residuals'][pfx+'sumInt']) 2477 2478 2478 2479 if pfx+'Scale' in PhFrExtPOSig: … … 2851 2852 print >>pFile,ptstr 2852 2853 print >>pFile,sigstr 2854 sumBk = np.array(Histogram['sumBk']) 2855 print >>pFile,' Background sums: empirical %.3g, Debye %.3g, peaks %.3g, Total %.3g' \ 2856 %(sumBk[0],sumBk[1],sumBk[2],np.sum(sumBk)) 2853 2857 2854 2858 def PrintInstParmsSig(Inst,instSig): -
trunk/GSASIIstrMath.py
r1676 r1682 1772 1772 sumFosq = 0.0 1773 1773 sumdFsq = 0.0 1774 sumInt = 0.0 1774 1775 for refl in refDict['RefList']: 1775 1776 if 'C' in calcControls[hfx+'histType']: … … 1785 1786 elif iBeg < iFin: 1786 1787 yp[iBeg:iFin] = refl[11+im]*refl[9+im]*G2pwd.getFCJVoigt3(refl[5+im],refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg:iFin])) #>90% of time spent here 1788 sumInt += refl[11+im]*refl[9+im] 1787 1789 if Ka2: 1788 1790 pos2 = refl[5+im]+lamRatio*tand(refl[5+im]/2.0) # + 360/pi * Dlam/lam * tan(th) … … 1791 1793 iFin2 = min(np.searchsorted(x,pos2+fmax),xF) 1792 1794 yp[iBeg2:iFin2] += refl[11+im]*refl[9+im]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg2:iFin2])) #and here 1795 sumInt += refl[11+im]*refl[9+im]*kRatio 1793 1796 refl[8+im] = np.sum(np.where(ratio[iBeg:iFin2]>0.,yp[iBeg:iFin2]*ratio[iBeg:iFin2]/(refl[11+im]*(1.+kRatio)),0.0)) 1797 1794 1798 elif 'T' in calcControls[hfx+'histType']: 1795 1799 yp = np.zeros_like(yb) … … 1800 1804 yp[iBeg:iFin] = refl[11+im]*refl[9+im]*G2pwd.getEpsVoigt(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im],ma.getdata(x[iBeg:iFin])) #>90% of time spent here 1801 1805 refl[8+im] = np.sum(np.where(ratio[iBeg:iFin]>0.,yp[iBeg:iFin]*ratio[iBeg:iFin]/refl[11+im],0.0)) 1806 sumInt += refl[11+im]*refl[9+im] 1802 1807 Fo = np.sqrt(np.abs(refl[8+im])) 1803 1808 Fc = np.sqrt(np.abs(refl[9]+im)) … … 1812 1817 Histogram['Residuals'][phfx+'Rf'] = 100. 1813 1818 Histogram['Residuals'][phfx+'Rf^2'] = 100. 1819 Histogram['Residuals'][phfx+'sumInt'] = sumInt 1814 1820 Histogram['Residuals'][phfx+'Nref'] = len(refDict['RefList']) 1815 1821 Histogram['Residuals']['hId'] = hId … … 1852 1858 hfx = ':%d:'%(hId) 1853 1859 bakType = calcControls[hfx+'bakType'] 1854 yb = G2pwd.getBackground(hfx,parmDict,bakType,calcControls[hfx+'histType'],x)1860 yb,Histogram['sumBk'] = G2pwd.getBackground(hfx,parmDict,bakType,calcControls[hfx+'histType'],x) 1855 1861 yc = np.zeros_like(yb) 1856 1862 cw = np.diff(x)
Note: See TracChangeset
for help on using the changeset viewer.