# Changeset 2132

Ignore:
Timestamp:
Jan 22, 2016 10:10:43 AM (7 years ago)
Message:

more rationalization of FWHM calculations

Location:
trunk
Files:
7 edited

Unmodified
Removed
• ## trunk/GSASII.py

 r2129 dsp = G2lat.Pos2dsp(Inst,peak[0]) if 'T' in Type:  #TOF - more cols sig = 2.35482*np.sqrt(peak[8]) sig = np.sqrt(peak[8]) gam = peak[10] FWHM = 2.*G2pwd.getgamFW(gam,sig)      #to get delta-TOF from Gam(peak) FWHM = G2pwd.getgamFW(gam,sig)      #to get delta-TOF from Gam(peak) file.write("%10.2f %10.5f %12.2f %10.3f %10.3f %10.3f %10.3f %10.3f\n" % \ (peak[0],dsp,peak[2],np.sqrt(max(0.0001,peak[4])),peak[6],peak[8],peak[10],FWHM)) else:               #CW sig = 2.35482*np.sqrt(peak[4])/100. gam = peak[6]/100. FWHM = 2.*G2pwd.getgamFW(gam,sig)      #to get delta-2-theta in deg. from Gam(peak) sig = np.sqrt(peak[4])/100. #var -> sig in deg gam = peak[6]/100.  #-> gam in deg FWHM = G2pwd.getgamFW(gam,sig)      #to get delta-2-theta in deg. from Gam(peak) file.write("%10.3f %10.5f %12.2f %10.5f %10.5f %10.5f \n" % \ (peak[0],dsp,peak[2],np.sqrt(max(0.0001,peak[4]))/100.,peak[6]/100.,FWHM/100.)) #convert to deg for peak in peaks['RefList']: if 'T' in peaks.get('Type','PXC'): sig = 2.35482*np.sqrt(peak[6]) sig = np.sqrt(peak[6]) gam = peak[7] FWHM = 2.*G2pwd.getgamFW(gam,sig) FWHM = G2pwd.getgamFW(gam,sig) file.write(" %3d %3d %3d %3d %10.5f %10.2f %10.5f %10.3f \n" % \ (int(peak[0]),int(peak[1]),int(peak[2]),int(peak[3]),peak[4],peak[5],FWHM,peak[8])) else: sig = 2.35482*np.sqrt(peak[6])/100. sig = np.sqrt(peak[6])/100. gam = peak[7]/100. FWHM = 2.*G2pwd.getgamFW(gam,sig) FWHM = G2pwd.getgamFW(gam,sig) file.write(" %3d %3d %3d %3d %10.5f %10.5f %10.5f %10.3f \n" % \ (int(peak[0]),int(peak[1]),int(peak[2]),int(peak[3]),peak[4],peak[5],FWHM/100.,peak[8]))
• ## trunk/GSASIImath.py

 r2129 h,k,l,m,d,pos,sig,gam,f = ref[:9] if d >= MCSA['dmin']: sig = G2pwd.getgamFW(gam,sig)/sq8ln2        #--> sig from FWHM sig = np.sqrt(sig)      #var -> sig in centideg sig = G2pwd.getgamFW(gam,sig)/sq8ln2        #FWHM -> sig in centideg SQ = 0.25/d**2 allFF.append(allM*[G2el.getFFvalues(FFtables,SQ,True)[i] for i in allT]/np.max(allM))
• ## trunk/GSASIIphsGUI.py

 r2116 indx = np.searchsorted(xdata[0],pos) try: FWHM = max(0.001,G2pwd.getFWHM(pos,Inst))/100.0 FWHM = max(0.001,G2pwd.getFWHM(pos,Inst)) # We want to estimate Pawley F^2 as a drop-in replacement for F^2 calculated by the structural # routines, which use Icorr * F^2 * peak profile, where peak profile has an area of 1.  So
• ## trunk/GSASIIplot.py

 r2127 Z = np.ones_like(X) data = G2mth.setPeakparms(Parms,Parms2,X,Z) s = 1.17741*np.sqrt(data[4])*np.pi/18000. g = data[6]*np.pi/36000. G = G2pwd.getgamFW(g,s) s = np.sqrt(data[4])*np.pi/18000.   #var -> sig(radians) g = data[6]*np.pi/18000.    #centideg -> radians G = G2pwd.getgamFW(g,s)/2.  #delt-theta Y = s/nptand(X/2.) Z = g/nptand(X/2.) fit = G2mth.setPeakparms(Parms,Parms2,X,Z,useFit=True) sf = 1.17741*np.sqrt(fit[4])*np.pi/18000. gf = fit[6]*np.pi/36000. Gf = G2pwd.getgamFW(gf,sf) sf = np.sqrt(fit[4])*np.pi/18000. gf = fit[6]*np.pi/18000. Gf = G2pwd.getgamFW(gf,sf)/2. Yf = sf/nptand(X/2.) Zf = gf/nptand(X/2.) X.append(4.0*math.pi*sind(peak[0]/2.0)/lam) try: s = 1.17741*math.sqrt(peak[4])*math.pi/18000. s = math.sqrt(peak[4])*math.pi/18000. except ValueError: s = 0.01 g = peak[6]*math.pi/36000. G = G2pwd.getgamFW(g,s) g = peak[6]*math.pi/18000. G = G2pwd.getgamFW(g,s)/2. Y.append(s/tand(peak[0]/2.)) Z.append(g/tand(peak[0]/2.))
• ## trunk/GSASIIpwd.py

 r2129 def getFWHM(pos,Inst): '1.17741*pi/180 = sqrt(8ln2)/(2pi/180)' sig = lambda Th,U,V,W: 1.17741*np.sqrt(max(0.001,U*tand(Th)**2+V*tand(Th)+W))*np.pi/180. '''Compute total FWHM from Thompson, Cox & Hastings (1987), J. Appl. Cryst. 20, 79-83 via getgamFW(g,s). :param pos: float peak position in deg 2-theta or tof in musec :param Inst: dict instrument parameters :returns float: total FWHM of pseudoVoigt in deg or musec ''' sig = lambda Th,U,V,W: np.sqrt(max(0.001,U*tand(Th)**2+V*tand(Th)+W)) sigTOF = lambda dsp,S0,S1,S2,Sq:  S0+S1*dsp**2+S2*dsp**4+Sq/dsp**2 gam = lambda Th,X,Y: (X/cosd(Th)+Y*tand(Th))*math.pi/180. gam = lambda Th,X,Y: (X/cosd(Th)+Y*tand(Th)) gamTOF = lambda dsp,X,Y: X*dsp+Y*dsp**2 if 'C' in Inst['Type'][0]: s = sig(pos/2.,Inst['U'][1],Inst['V'][1],Inst['W'][1])*100. g = gam(pos/2.,Inst['X'][1],Inst['Y'][1])*100. s = sig(pos/2.,Inst['U'][1],Inst['V'][1],Inst['W'][1]) g = gam(pos/2.,Inst['X'][1],Inst['Y'][1]) return getgamFW(g,s)/100.  #returns FWHM in deg else: dsp = pos/Inst['difC'][0] s = sigTOF(dsp,Inst['sig-0'][1],Inst['sig-1'][1],Inst['sig-2'][1],Inst['sig-q'][1]) g = gamTOF(dsp,Inst['X'][1],Inst['Y'][1]) return getgamFW(g,s) return getgamFW(g,s) def getgamFW(g,s): '''Compute total FWHM from Thompson, Cox & Hastings (1987), J. Appl. Cryst. 20, 79-83 :param g: float Lorentzian FWHM :param s: float Gaussian FWHM lambda fxn needs FWHM for both Gaussian & Lorentzian components :param g: float Lorentzian gamma = FWHM(L) :param s: float Gaussian sig :returns float: total FWHM of pseudoVoigt ''' gamFW = lambda s,g: np.exp(np.log(s**5+2.69269*s**4*g+2.42843*s**3*g**2+4.47163*s**2*g**3+0.07842*s*g**4+g**5)/5.) return gamFW(s,g) return gamFW(2.35482*s,g)   #sqrt(8ln2)*sig = FWHM(G) def getFCJVoigt(pos,intens,sig,gam,shl,xdata):
• ## trunk/exports/G2export_csv.py

 r2103 else:        #convert to deg h,k,l,m,mult,dsp,pos,sig,gam,Fobs,Fcalc,phase,Icorr,Prfo = refItem[:14] FWHM = G2pwd.getgamFW(gam,sig) self.Write(fmt.format(h,k,l,m,pos,Fobs,Fcalc,phase,mult,    \ np.sqrt(max(sig,0.0001))/100.,gam/100.,FWHM/100.,i)) s = np.sqrt(max(sig,0.0001))/100.   #var -> sig in deg g = gam/100.    #-> deg FWHM = G2pwd.getgamFW(g,s) self.Write(fmt.format(h,k,l,m,pos,Fobs,Fcalc,phase,mult,s,g,FWHM,i)) else: WriteList(self,("h","k","l",tname,"F_obs","F_calc","phase","mult","sig","gam","FWHM","Prfo","phase #")) else:        #convert to deg h,k,l,mult,dsp,pos,sig,gam,Fobs,Fcalc,phase,Icorr,Prfo = refItem[:13] FWHM = G2pwd.getgamFW(gam,sig) self.Write(fmt.format(h,k,l,pos,Fobs,Fcalc,phase,mult,  \ np.sqrt(max(sig,0.0001))/100.,gam/100.,FWHM/100.,Prfo,i)) g = gam/100. s = np.sqrt(max(sig,0.0001))/100. FWHM = G2pwd.getgamFW(g,s) self.Write(fmt.format(h,k,l,pos,Fobs,Fcalc,phase,mult,s,g,FWHM,Prfo,i)) self.CloseFile() print(str(hist)+'reflections written to file '+str(self.fullpath))
• ## trunk/exports/G2export_examples.py

 r1997 if 'T' in phasDict['Type']: h,k,l,m,mult,dsp,pos,sig,gam,Fobs,Fcalc,phase,x,x,x,x,prfo = refItem[:17] FWHM = 2.*G2pwd.getgamFW(gam,sig) FWHM = G2pwd.getgamFW(gam,sig) self.Write(fmt.format(hklfmt.format(h,k,l,m),pos,Fobs,Fcalc,phase,mult,sig,gam,FWHM,prfo)) else: h,k,l,m,mult,dsp,pos,sig,gam,Fobs,Fcalc,phase,x,prfo = refItem[:14] FWHM = 2.*G2pwd.getgamFW(gam,sig) self.Write(fmt.format(hklfmt.format(h,k,l,m),pos,Fobs,Fcalc,phase,mult, \ np.sqrt(max(sig,0.0001))/100.,gam/100.,FWHM/100.,prfo)) g = gam/100.    #centideg -> deg s = np.sqrt(max(sig,0.0001))/100.   #var -> sig in deg FWHM = G2pwd.getgamFW(g,s)  #FWHM self.Write(fmt.format(hklfmt.format(h,k,l,m),pos,Fobs,Fcalc,phase,mult,s,g,FWHM,prfo)) else: self.Write(94*'=') if 'T' in phasDict['Type']: h,k,l,mult,dsp,pos,sig,gam,Fobs,Fcalc,phase,x,x,x,x,prfo = refItem[:16] FWHM = 2.*G2pwd.getgamFW(gam,sig) FWHM = G2pwd.getgamFW(gam,sig) self.Write(fmt.format(hklfmt.format(h,k,l),pos,Fobs,Fcalc,phase,mult,np.sqrt(max(sig,0.0001)),gam,FWHM,prfo)) else: h,k,l,mult,dsp,pos,sig,gam,Fobs,Fcalc,phase,x,prfo = refItem[:13] FWHM = 2.*G2pwd.getgamFW(gam,sig) g = gam/100.    #centideg -> deg s = np.sqrt(max(sig,0.0001))/100.   #var -> sig in deg FWHM = G2pwd.getgamFW(g,s) self.Write(fmt.format(hklfmt.format(h,k,l),pos,Fobs,Fcalc,phase,mult,   \ np.sqrt(max(sig,0.0001))/100.,gam/100.,FWHM/100.,prfo)) s,g,FWHM,prfo)) self.CloseFile() print(str(hist)+'reflections written to file '+str(self.fullpath))
Note: See TracChangeset for help on using the changeset viewer.