- Timestamp:
- Jan 21, 2016 10:25:48 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASII.py ¶
r2127 r2129 705 705 ref[3+Super] = 0 706 706 else: 707 ref[3+Super] = 1 #twin id ?707 ref[3+Super] = 1 #twin id 708 708 else: 709 709 ref[3] = 0 … … 3166 3166 dsp = G2lat.Pos2dsp(Inst,peak[0]) 3167 3167 if 'T' in Type: #TOF - more cols 3168 FWHM = 2.*G2pwd.getgamFW(peak[10],peak[8]) #to get delta-TOF from Gam(peak) 3168 sig = 2.35482*np.sqrt(peak[8]) 3169 gam = peak[10] 3170 FWHM = 2.*G2pwd.getgamFW(gam,sig) #to get delta-TOF from Gam(peak) 3169 3171 file.write("%10.2f %10.5f %12.2f %10.3f %10.3f %10.3f %10.3f %10.3f\n" % \ 3170 3172 (peak[0],dsp,peak[2],np.sqrt(max(0.0001,peak[4])),peak[6],peak[8],peak[10],FWHM)) 3171 3173 else: #CW 3172 FWHM = 2.*G2pwd.getgamFW(peak[6],peak[4]) #to get delta-2-theta in deg. from Gam(peak) 3174 sig = 2.35482*np.sqrt(peak[4])/100. 3175 gam = peak[6]/100. 3176 FWHM = 2.*G2pwd.getgamFW(gam,sig) #to get delta-2-theta in deg. from Gam(peak) 3173 3177 file.write("%10.3f %10.5f %12.2f %10.5f %10.5f %10.5f \n" % \ 3174 3178 (peak[0],dsp,peak[2],np.sqrt(max(0.0001,peak[4]))/100.,peak[6]/100.,FWHM/100.)) #convert to deg … … 3205 3209 file.write('%s \n'%(' h k l m d-space 2-theta wid F**2')) 3206 3210 for peak in peaks['RefList']: 3207 FWHM = 2.*G2pwd.getgamFW(peak[7],peak[6])3208 3211 if 'T' in peaks.get('Type','PXC'): 3212 sig = 2.35482*np.sqrt(peak[6]) 3213 gam = peak[7] 3214 FWHM = 2.*G2pwd.getgamFW(gam,sig) 3209 3215 file.write(" %3d %3d %3d %3d %10.5f %10.2f %10.5f %10.3f \n" % \ 3210 3216 (int(peak[0]),int(peak[1]),int(peak[2]),int(peak[3]),peak[4],peak[5],FWHM,peak[8])) 3211 3217 else: 3218 sig = 2.35482*np.sqrt(peak[6])/100. 3219 gam = peak[7]/100. 3220 FWHM = 2.*G2pwd.getgamFW(gam,sig) 3212 3221 file.write(" %3d %3d %3d %3d %10.5f %10.5f %10.5f %10.3f \n" % \ 3213 3222 (int(peak[0]),int(peak[1]),int(peak[2]),int(peak[3]),peak[4],peak[5],FWHM/100.,peak[8])) -
TabularUnified trunk/GSASIIgrid.py ¶
r2127 r2129 23 23 import sys 24 24 import os 25 import random as ran 25 26 import numpy as np 26 27 import numpy.ma as ma … … 2991 2992 'Scale':1.0,'oldxy':[],'viewDir':[1,0,0]},'Super':Super,'SuperVec':SuperVec} 2992 2993 G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName) 2993 2994 # def OnMerge(self,event): 2995 # if not len(self.HKL): 2996 # print 'No data' 2997 # return 2998 # self.newHKL = np.copy(self.HKL) 2999 # for H in self.newHKL: 3000 # H[:4] = np.rint(np.inner(self.Trans,H[:4])) 3001 # self.newHKL = np.asarray(self.newHKL) 3002 # self.newHKL = G2lat.LaueUnique(self.Laue,self.newHKL) 3003 # dlg = wx.ProgressDialog('Build HKL dictonary','',len(self.newHKL)+1, 3004 # style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 3005 # HKLdict = {} 3006 # for ih,hkl in enumerate(self.newHKL): 3007 # if str(hkl[:4]) not in HKLdict: 3008 # HKLdict[str(hkl[:4])] = [hkl[:4],[hkl[4:],]] 3009 # else: 3010 # HKLdict[str(hkl[:4])][1].append(hkl[4:]) 3011 # dlg.Update(ih) 3012 # dlg.Destroy() 3013 # self.newHKL = [] 3014 # dlg = wx.ProgressDialog('Processing merge','',len(HKLdict)+1, 3015 # style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 3016 # sumDf = 0. 3017 # sumFo = 0. 3018 # for ih,hkl in enumerate(HKLdict): 3019 # HKL = HKLdict[hkl] 3020 # newHKL = list(HKL[0]) 3021 # if len(HKL[1]) > 1: 3022 # fos = np.array(HKL[1]) 3023 # wFo = 1/fos[:,1]**2 3024 # Fo = np.average(fos[:,0],weights=wFo) 3025 # std = np.std(fos[:,0]) 3026 # sig = np.sqrt(np.mean(fos[:,1])**2+std**2) 3027 # sumFo += np.sum(fos[:,0]) 3028 # sumDf += np.sum(np.abs(fos[:,0]-Fo)) 3029 # dlg.Update(ih) 3030 # else: 3031 # Fo = HKL[1][0][0] 3032 # sig = HKL[1][0][1] 3033 # newHKL += [Fo,sig] 3034 # if Fo > 0.: 3035 # self.newHKL.append(list(newHKL)) 3036 # dlg.Destroy() 3037 # self.newHKL = np.array(self.newHKL) 3038 # print 'merge R = %6.2f%s for %d reflections'%(100.*sumDf/sumFo,'%',self.newHKL.shape[0]) 3039 # self.newHKL = G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(self.newHKL,3),2),1),0) 3040 2994 3041 2995 def OnMergeHKL(event): 2996 Name = G2frame.PatternTree.GetItemText(G2frame.PatternId) 2997 Inst = G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame, 2998 G2frame.PatternId,'Instrument Parameters')) 2999 refList = np.copy(data[1]['RefList']) 3042 3000 dlg = MergeDialog(G2frame,data) 3043 3001 try: 3044 3002 if dlg.ShowModal() == wx.ID_OK: 3045 3003 Trans,Cent,Laue = dlg.GetSelection() 3046 print "do merge here: ",Cent,Laue3047 3004 else: 3048 3005 return 3049 3006 finally: 3050 3007 dlg.Destroy() 3051 3052 print 'merge HKLF' 3053 3008 Super = data[1]['Super'] 3009 refList = G2lat.transposeHKLF(Trans,Super,refList) 3010 refList = G2lat.LaueUnique(Laue,refList) 3011 dlg = wx.ProgressDialog('Build HKL dictonary','',len(refList)+1, 3012 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 3013 HKLdict = {} 3014 for ih,hkl in enumerate(refList): 3015 if str(hkl[:3+Super]) not in HKLdict: 3016 HKLdict[str(hkl[:3+Super])] = [hkl[:3+Super],[hkl[3+Super:],]] 3017 else: 3018 HKLdict[str(hkl[:3+Super])][1].append(hkl[3+Super:]) 3019 dlg.Update(ih) 3020 dlg.Destroy() 3021 mergeRef = [] 3022 dlg = wx.ProgressDialog('Processing merge','',len(HKLdict)+1, 3023 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 3024 sumDf = 0. 3025 sumFo = 0. 3026 for ih,hkl in enumerate(HKLdict): 3027 HKL = HKLdict[hkl] 3028 newHKL = list(HKL[0])+list(HKL[1][0]) 3029 if len(HKL[1]) > 1: 3030 fos = np.array(HKL[1]) 3031 wFo = 1/fos[:,3]**2 3032 Fo = np.average(fos[:,2],weights=wFo) 3033 std = np.std(fos[:,2]) 3034 sig = np.sqrt(np.mean(fos[:,3])**2+std**2) 3035 sumFo += np.sum(fos[:,2]) 3036 sumDf += np.sum(np.abs(fos[:,2]-Fo)) 3037 dlg.Update(ih) 3038 newHKL[5+Super] = Fo 3039 newHKL[6+Super] = sig 3040 newHKL[8+Super] = Fo 3041 if newHKL[5+Super] > 0.: 3042 mergeRef.append(list(newHKL)) 3043 dlg.Destroy() 3044 if Super: 3045 mergeRef = G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(mergeRef,3),2),1),0) 3046 else: 3047 mergeRef = G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(mergeRef,2),1),0) 3048 mergeRef = np.array(mergeRef) 3049 print 'merge R = %6.2f%s for %d reflections'%(100.*sumDf/sumFo,'%',mergeRef.shape[0]) 3050 HKLFlist = [] 3051 newName = Name+' '+Laue 3052 if G2frame.PatternTree.GetCount(): 3053 item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root) 3054 while item: 3055 name = G2frame.PatternTree.GetItemText(item) 3056 if name.startswith('HKLF ') and name not in HKLFlist: 3057 HKLFlist.append(name) 3058 item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie) 3059 newName = G2obj.MakeUniqueLabel(newName,HKLFlist) 3060 newData = copy.deepcopy(data) 3061 newData[0]['ranId'] = ran.randint(0,sys.maxint) 3062 newData[1]['RefList'] = mergeRef 3063 Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text=newName) 3064 G2frame.PatternTree.SetItemPyData(Id,newData) 3065 G2frame.PatternTree.SetItemPyData( 3066 G2frame.PatternTree.AppendItem(Id,text='Instrument Parameters'),Inst) 3067 G2frame.PatternTree.SetItemPyData( 3068 G2frame.PatternTree.AppendItem(Id,text='Reflection List'),{}) #dummy entry for GUI use 3069 3054 3070 def OnErrorAnalysis(event): 3055 3071 G2plt.PlotDeltSig(G2frame,kind) -
TabularUnified trunk/GSASIIlattice.py ¶
r2126 r2129 524 524 return Hmax 525 525 526 def transposeHKLF(transMat,Super,refList): 527 newRefs = np.copy(refList) 528 for H in newRefs: 529 H[:3+Super] = np.rint(np.inner(transMat,H[:3+Super])) 530 return newRefs 531 526 532 def sortHKLd(HKLd,ifreverse,ifdup,ifSS=False): 527 ''' needs doc string533 '''sort reflection list on d-spacing; can sort in either order 528 534 529 535 :param HKLd: a list of [h,k,l,d,...]; … … 940 946 mat4 = np.array([[0,1,0],[-1,0,0],[0,0,1]]) 941 947 mat3 = np.array([[0,-1,0],[1,-1,0],[0,0,1]]) 948 mat6 = np.array([[0,1,0],[-1,1,0],[0,0,1]]) 942 949 #triclinic 943 if Laue == '1': 950 if Laue == '1': #ok 944 951 pass 945 elif Laue == '-1': 952 elif Laue == '-1': #ok 946 953 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 954 HKLFT[:3] = np.where(HKLFT[0]==0,np.where(HKLFT[1]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]),HKLFT[:3]) 947 955 #monoclinic - all 3 settings 948 elif Laue == '2(a)': 949 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([1,-1,-1])[:,nxs],HKLFT[:3]) 950 elif Laue == '2': 951 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,1,-1])[:,nxs],HKLFT[:3]) 952 elif Laue == '2(c)': 953 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]) 954 elif Laue == 'm(a)': 956 elif Laue == '2(a)': #ok 957 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([1,-1,-1])[:,nxs],HKLFT[:3]) 958 HKLFT[:3] = np.where(HKLFT[2]==0,np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]),HKLFT[:3]) 959 elif Laue == '2': #ok 960 HKLFT[:3] = np.where(HKLFT[0]<=0,HKLFT[:3]*np.array([-1,1,-1])[:,nxs],HKLFT[:3]) 961 HKLFT[:3] = np.where(HKLFT[0]==0,np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,-1])[:,nxs],HKLFT[:3]),HKLFT[:3]) 962 elif Laue == '2(c)': #ok 963 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]) 964 HKLFT[:3] = np.where(HKLFT[1]==0,np.where(HKLFT[2]<0,HKLFT[:3]*np.array([-1,1,-1])[:,nxs],HKLFT[:3]),HKLFT[:3]) 965 elif Laue == 'm(a)': #ok 955 966 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,1,1])[:,nxs],HKLFT[:3]) 956 elif Laue == 'm': 957 HKLFT[:3] = np.where(HKLFT[ 0]<0,HKLFT[:3]*np.array([1,-1,1])[:,nxs],HKLFT[:3])958 elif Laue == 'm(c)': 959 HKLFT[:3] = np.where(HKLFT[ 0]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3])967 elif Laue == 'm': #ok 968 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,1])[:,nxs],HKLFT[:3]) 969 elif Laue == 'm(c)': #ok 970 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]) 960 971 elif Laue == '2/m(a)': 961 972 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,-1])[:,nxs],HKLFT[:3]) 962 HKLFT[:3] = np.where(HKLFT[ 2]<0,HKLFT[:3]*np.array([-1,1,1])[:,nxs],HKLFT[:3])963 elif Laue == '2/m': 973 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,1,1])[:,nxs],HKLFT[:3]) 974 elif Laue == '2/m': #ok 964 975 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,1,-1])[:,nxs],HKLFT[:3]) 965 HKLFT[:3] = np.where(HKLFT[ 2]<0,HKLFT[:3]*np.array([1,-1,1])[:,nxs],HKLFT[:3])976 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,1])[:,nxs],HKLFT[:3]) 966 977 elif Laue == '2/m(c)': 967 HKLFT[:3] = np.where(HKLFT[ 0]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3])968 HKLFT[:3] = np.where(HKLFT[ 1]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3])978 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]) 979 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]) 969 980 #orthorhombic - 3 settings 970 elif Laue == '222': 981 elif Laue == '222': #ok 971 982 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]) 972 983 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,-1])[:,nxs],HKLFT[:3]) 973 elif Laue == '2mm': 974 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]) 975 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([1,-1,1])[:,nxs],HKLFT[:3]) 976 elif Laue == 'm2m': 984 HKLFT[:3] = np.where(HKLFT[0]==0,np.where(HKLFT[2]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]),HKLFT[:3]) 985 HKLFT[:3] = np.where(HKLFT[1]==0,np.where(HKLFT[2]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]),HKLFT[:3]) 986 elif Laue == '2mm': #ok 987 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,1])[:,nxs],HKLFT[:3]) 988 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]) 989 elif Laue == 'm2m': #ok 977 990 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,1,1])[:,nxs],HKLFT[:3]) 978 HKLFT[:3] = np.where(HKLFT[ 0]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3])979 elif Laue == 'mm2': 991 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]) 992 elif Laue == 'mm2': #ok 980 993 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,1,1])[:,nxs],HKLFT[:3]) 981 994 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,1])[:,nxs],HKLFT[:3]) 982 elif Laue == 'mmm': 995 elif Laue == 'mmm': #ok 983 996 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,1,1])[:,nxs],HKLFT[:3]) 984 997 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,1])[:,nxs],HKLFT[:3]) … … 987 1000 elif Laue == '-3': 988 1001 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 989 HKLFT[:3] = np.where(HKLFT[ 0]<HKLF[1],np.inner(HKLFT[:3]*mat3[:,:,nxs]),HKLFT[:3])1002 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 990 1003 elif Laue == '3/m': 991 1004 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]) 992 HKLFT[:3] = np.where(HKLFT[ 0]<HKLF[1],np.inner(HKLFT[:3]*mat3[:,:,nxs]),HKLFT[:3])1005 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 993 1006 elif Laue == '3': 994 HKLFT[:3] = np.where(HKLFT[ 0]<HKLF[1],np.inner(HKLFT[:3]*mat3[:,:,nxs]),HKLFT[:3])1007 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 995 1008 elif Laue == '32': 996 1009 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([-1,1,-1])[:,nxs],HKLFT[:3]) 997 HKLFT[:3] = np.where(HKLFT[0]<HKLF[1],np.inner(HKLFT[:3]*mat3[:,:,nxs]),HKLFT[:3]) 998 HKLFT[:3] = np.where(HKLFT[0]<HKLF[1],np.inner(HKLFT[:3]*mat3[:,:,nxs]),HKLFT[:3]) 1010 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 999 1011 elif Laue == '3m': 1000 1012 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,1,1])[:,nxs],HKLFT[:3]) 1001 HKLFT[:3] = np.where(HKLFT[ 0]<HKLF[1],np.inner(HKLFT[:3]*mat3[:,:,nxs]),HKLFT[:3])1013 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 1002 1014 #tetragonal 1003 1015 elif Laue == '4/m': 1004 1016 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]) 1005 1017 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,1,-1])[:,nxs],HKLFT[:3]) 1006 HKLFT[:3] = np.where(HKLFT[1]<HKLF [0],np.inner(HKLFT[:3]*mat4[:,:,nxs]),HKLFT[:3])1018 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1007 1019 elif Laue == '4/mmm': 1008 1020 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1009 1021 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1010 1022 HKLFT[:3] = np.where(HKLFT[2]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1011 HKLFT[:3] = np.where(HKLFT[1]<HKLF [0],np.inner(HKLFT[:3]*mat4[:,:,nxs]),HKLFT[:3])1023 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1012 1024 elif Laue == '4': 1013 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]) 1014 HKLFT[:3] = np.where(HKLFT[1]<HKLF[0],np.inner(HKLFT[:3]*mat4[:,:,nxs]),HKLFT[:3]) 1025 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]) 1026 HKLFT[:3] = np.where(HKLFT[1]==0,np.where(HKLFT[2]<0,HKLFT[:3]*np.array([-1,1,-1])[:,nxs],HKLFT[:3]),HKLFT[:3]) 1027 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1015 1028 elif Laue == '-4': 1016 1029 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1017 HKLFT[:3] = np.where(HKLFT[1]<HKLF [0],np.inner(HKLFT[:3]*mat4[:,:,nxs]),HKLFT[:3])1030 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1018 1031 elif Laue == '422': 1019 1032 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,1])[:,nxs],HKLFT[:3]) 1020 1033 HKLFT[:3] = np.where(HKLFT[1]<0,HKLFT[:3]*np.array([1,-1,-1])[:,nxs],HKLFT[:3]) 1021 HKLFT[:3] = np.where(HKLFT[1]<HKLF [0],np.inner(HKLFT[:3]*mat4[:,:,nxs]),HKLFT[:3])1034 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1022 1035 elif Laue == '-42m': 1023 1036 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1037 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1024 1038 elif Laue == '42m': 1025 1039 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1040 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1026 1041 #hexagonal 1027 1042 elif Laue == '6/m': 1028 1043 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1044 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 1029 1045 elif Laue == '6/mmm': 1030 1046 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1047 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 1031 1048 elif Laue == '6': 1032 1049 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1050 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 1033 1051 elif Laue == '-6': 1034 1052 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1053 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 1035 1054 elif Laue == '622': 1036 1055 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1056 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 1037 1057 elif Laue == '-62m': 1038 1058 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1059 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 1039 1060 elif Laue == '62m': 1040 1061 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1062 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat3[nxs,:,:])).T,HKLFT[:3]) 1041 1063 #cubic 1042 1064 elif Laue == 'm3': 1043 1065 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1066 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1044 1067 elif Laue == 'm3m': 1045 1068 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1069 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1046 1070 elif Laue == '23': 1047 1071 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1072 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1048 1073 elif Laue == '432': 1049 1074 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1075 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1050 1076 elif Laue == '-432': 1051 1077 HKLFT[:3] = np.where(HKLFT[0]<0,HKLFT[:3]*np.array([-1,-1,-1])[:,nxs],HKLFT[:3]) 1078 HKLFT[:3] = np.where(HKLFT[1]<HKLFT[0],np.squeeze(np.inner(HKLF[:,:3],mat4[nxs,:,:])).T,HKLFT[:3]) 1052 1079 return HKLFT.T 1053 1080 -
TabularUnified trunk/GSASIImath.py ¶
r2115 r2129 3176 3176 3177 3177 def getCWsig(ins,pos): 3178 '''get CW peak profile sigma 3178 '''get CW peak profile sigma^2 3179 3179 3180 3180 :param dict ins: instrument parameters with at least 'U', 'V', & 'W' 3181 3181 as values only 3182 3182 :param float pos: 2-theta of peak 3183 :returns: float getCWsig: peak sigma 3183 :returns: float getCWsig: peak sigma^2 3184 3184 3185 3185 ''' … … 3188 3188 3189 3189 def getCWsigDeriv(pos): 3190 '''get derivatives of CW peak profile sigma wrt U,V, & W3190 '''get derivatives of CW peak profile sigma^2 wrt U,V, & W 3191 3191 3192 3192 :param float pos: 2-theta of peak 3193 3193 3194 :returns: list getCWsigDeriv: d(sig )/dU, d(sig)/dV & d(sig)/dW3194 :returns: list getCWsigDeriv: d(sig^2)/dU, d(sig)/dV & d(sig)/dW 3195 3195 3196 3196 ''' … … 3220 3220 3221 3221 def getTOFsig(ins,dsp): 3222 '''get TOF peak profile sigma 3222 '''get TOF peak profile sigma^2 3223 3223 3224 3224 :param dict ins: instrument parameters with at least 'sig-0', 'sig-1' & 'sig-q' … … 3226 3226 :param float dsp: d-spacing of peak 3227 3227 3228 :returns: float getTOFsig: peak sigma 3228 :returns: float getTOFsig: peak sigma^2 3229 3229 3230 3230 ''' … … 3232 3232 3233 3233 def getTOFsigDeriv(dsp): 3234 '''get derivatives of TOF peak profile gammawrt sig-0, sig-1, & sig-q3234 '''get derivatives of TOF peak profile sigma^2 wrt sig-0, sig-1, & sig-q 3235 3235 3236 3236 :param float dsp: d-spacing of peak … … 4082 4082 h,k,l,m,d,pos,sig,gam,f = ref[:9] 4083 4083 if d >= MCSA['dmin']: 4084 sig = G2pwd.getgamFW( sig,gam)/sq8ln2 #--> sig from FWHM4084 sig = G2pwd.getgamFW(gam,sig)/sq8ln2 #--> sig from FWHM 4085 4085 SQ = 0.25/d**2 4086 4086 allFF.append(allM*[G2el.getFFvalues(FFtables,SQ,True)[i] for i in allT]/np.max(allM)) -
TabularUnified trunk/GSASIIpwd.py ¶
r2049 r2129 457 457 def getWidthsCW(pos,sig,gam,shl): 458 458 '''Compute the peak widths used for computing the range of a peak 459 for constant wavelength data. 460 On low-angle side, 10 FWHM are used, on high-angle side 15 are used459 for constant wavelength data. On low-angle side, 10 FWHM are used, 460 on high-angle side 15 are used, low angle side extended by axial divergence 461 461 (for peaks above 90 deg, these are reversed.) 462 462 ''' 463 widths = [np.sqrt(sig)/100.,gam/ 200.]464 fwhm = 2.355*widths[0]+ 2.*widths[1]463 widths = [np.sqrt(sig)/100.,gam/100.] 464 fwhm = 2.355*widths[0]+widths[1] 465 465 fmin = 10.*(fwhm+shl*abs(npcosd(pos))) 466 466 fmax = 15.0*fwhm … … 470 470 471 471 def getWidthsTOF(pos,alp,bet,sig,gam): 472 'needs a doc string' 472 '''Compute the peak widths used for computing the range of a peak 473 for constant wavelength data. 10 FWHM are used on both sides each 474 extended by exponential coeff. 475 ''' 473 476 lnf = 3.3 # =log(0.001/2) 474 477 widths = [np.sqrt(sig),gam] … … 494 497 495 498 def getgamFW(g,s): 496 'needs a doc string' 499 '''Compute total FWHM from Thompson, Cox & Hastings (1987), J. Appl. Cryst. 20, 79-83 500 501 :param g: float Lorentzian FWHM 502 :param s: float Gaussian FWHM 503 504 :returns float: total FWHM of pseudoVoigt 505 ''' 497 506 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.) 498 return gamFW( g,s)507 return gamFW(s,g) 499 508 500 509 def getFCJVoigt(pos,intens,sig,gam,shl,xdata): … … 901 910 else: 902 911 sig = G2mth.getCWsig(parmDict,tth) 903 sig = max(sig,0.001) #avoid neg sigma 912 sig = max(sig,0.001) #avoid neg sigma^2 904 913 gamName = 'gam'+str(iPeak) 905 914 if gamName in varyList:
Note: See TracChangeset
for help on using the changeset viewer.