Changeset 1958
- Timestamp:
- Aug 21, 2015 2:57:01 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r1943 r1958 2962 2962 for value in data[0]: 2963 2963 if 'Nref' in value: 2964 mainSizer.Add((5,5),)2965 2964 pfx = value.split('Nref')[0] 2966 2965 name = data[0].get(pfx.split(':')[0]+'::Name','?') 2967 mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' For phase '+name+':')) 2968 mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1, 2969 u' Unweighted phase residuals RF\u00b2: %.3f%%, RF: %.3f%% on %d reflections '% \ 2970 (data[0][pfx+'Rf^2'],data[0][pfx+'Rf'],data[0][value]))) 2966 if 'SS' in value: 2967 mainSizer.Add((5,5),) 2968 mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' For incommensurate phase '+name+':')) 2969 for m,(Rf2,Rf,Nobs) in enumerate(zip(data[0][pfx+'Rf^2'],data[0][pfx+'Rf'],data[0][value])): 2970 mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1, 2971 u' m = +/- %d: RF\u00b2: %.3f%%, RF: %.3f%% on %d reflections '% \ 2972 (m,Rf2,Rf,Nobs))) 2973 else: 2974 mainSizer.Add((5,5),) 2975 mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' For phase '+name+':')) 2976 mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1, 2977 u' Unweighted phase residuals RF\u00b2: %.3f%%, RF: %.3f%% on %d reflections '% \ 2978 (data[0][pfx+'Rf^2'],data[0][pfx+'Rf'],data[0][value]))) 2979 2971 2980 mainSizer.Add((5,5),) 2972 2981 mainSizer.Layout() -
trunk/GSASIImath.py
r1957 r1958 929 929 Smult,TauT = SStauM # both atoms x SGops 930 930 m = SSUniq.T[3] 931 nh = np.zeros(1) 931 A = np.array(XSSdata[:3]) #sin mods x waves x atoms 932 B = np.array(XSSdata[3:]) #cos mods... 932 933 if XSSdata.ndim > 2: 933 934 nh = np.arange(XSSdata.shape[1]) #0..max harmonic order-1 934 M = np.where(m>0,m+nh[:,np.newaxis],m-nh[:,np.newaxis]) # waves x SGops 935 A = np.array(XSSdata[:3]) #sin mods x waves x atoms 936 B = np.array(XSSdata[3:]) #cos mods... 937 HdotA = (np.inner(A.T,SSUniq.T[:3].T)+SSPhi+TauT[:,np.newaxis,:]) # atoms X waves x SGops 938 HdotB = (np.inner(B.T,SSUniq.T[:3].T)+SSPhi) #+TauT[:,np.newaxis,:]) # ditto 939 GpA = sp.jn(M,twopi*HdotA) # atoms x waves x SGops 940 GpB = sp.jn(M,twopi*HdotB)*(1.j)**M # ditto 941 Gp = np.sum(GpA+GpB,axis=1) # atoms x SGops 942 return np.real(Gp).T,np.imag(Gp).T # SGops x atoms 935 M = np.where(m>0,m+nh[:,np.newaxis],m-nh[:,np.newaxis]) # waves x SGops 936 HdotA = (np.inner(A.T,SSUniq.T[:3].T)) #atoms X waves x SGops 937 HdotB = (np.inner(B.T,SSUniq.T[:3].T)) # ditto 938 Hdot = np.sqrt(HdotA**2+HdotB**2) 939 Hphi = np.sum(np.arctan2(HdotB,HdotA)*M,axis=1) 940 GpA = np.sum(sp.jn(-M,twopi*Hdot),axis=1) # sum on waves 941 else: 942 HdotA = np.inner(A.T,SSUniq.T[:3].T) #atoms X SGops 943 HdotB = np.inner(B.T,SSUniq.T[:3].T) # ditto 944 Hdot = np.sqrt(HdotA**2+HdotB**2) 945 Hphi = np.arctan2(HdotB,HdotA) 946 GpA = sp.jn(-m,twopi*Hdot) # atoms x SGops 947 948 # GSASIIpath.IPyBreak() 949 return GpA.T,Hphi.T # SGops x atoms 943 950 944 951 def ModulationDerv(waveTypes,SSUniq,SSPhi,FSSdata,XSSdata,USSdata,SStauM): 945 952 import scipy.special as sp 946 m = SSUniq.T[3]953 Smult,TauT = SStauM # both atoms x SGops 947 954 nh = np.zeros(1) 948 955 if XSSdata.ndim > 2: … … 950 957 M = np.where(m>0,m+nh[:,np.newaxis],m-nh[:,np.newaxis]) 951 958 A = np.array([[a,b] for a,b in zip(XSSdata[:3],XSSdata[3:])]) 952 HdotA = twopi*(np.inner( SSUniq.T[:3].T,A.T)+SSPhi)959 HdotA = twopi*(np.inner(A.T,SSUniq.T[:3].T)+SSPhi+TauT[:,np.newaxis,:]) 953 960 Gpm = sp.jn(M-1,HdotA) 954 961 Gpp = sp.jn(M+1,HdotA) … … 995 1002 atoms = data['Atoms'] 996 1003 drawAtoms = drawingData['Atoms'] 1004 Fade = np.zeros(len(drawAtoms)) 997 1005 for atom in atoms: 998 1006 atxyz = G2spc.MoveToUnitCell(np.array(atom[cx:cx+3]))[0] 999 1007 atuij = np.array(atom[cia+2:cia+8]) 1000 1008 waveType = atom[-1]['SS1']['waveType'] 1009 Sfrac = atom[-1]['SS1']['Sfrac'] 1001 1010 Spos = atom[-1]['SS1']['Spos'] 1002 1011 Sadp = atom[-1]['SS1']['Sadp'] … … 1007 1016 sop,ssop,icent = G2spc.OpsfromStringOps(opr,SGData,SSGData) 1008 1017 sdet,ssdet,dtau,dT,tauT = G2spc.getTauT(tau,sop,ssop,atxyz) 1009 smul = sdet *ssdet1010 # tauT *= icent 1018 smul = sdet # n-fold vs m operator on wave 1019 tauT *= icent #invert wave on -1 1011 1020 wave = np.zeros(3) 1012 1021 uwave = np.zeros(6) 1022 #how do I handle Sfrac? - fade the atoms? 1023 if len(Sfrac): 1024 scof = [] 1025 ccof = [] 1026 for i,sfrac in enumerate(Sfrac): 1027 if not i and 'Crenel' in waveType: 1028 Fade[ind] += fracCrenel(tauT,sfrac[0][0],sfrac[0][1]) 1029 else: 1030 scof.append(sfrac[0][0]) 1031 ccof.append(sfrac[0][1]) 1032 if len(scof): 1033 Fade[ind] += np.sum(fracFourier(tauT,scof,ccof)) 1013 1034 if len(Spos): 1014 1035 scof = [] … … 1040 1061 X = G2spc.ApplyStringOps(opr,SGData,atxyz+wave) 1041 1062 drawatom[dcx:dcx+3] = X 1042 return drawAtoms 1063 return drawAtoms,Fade 1043 1064 1044 1065 -
trunk/GSASIIphsGUI.py
r1957 r1958 2442 2442 waveSizer.Add(wx.StaticText(waveData,label=' %s parameters: %s'%(waveName,str(names).rstrip(']').lstrip('[').replace("'",''))),0,WACV) 2443 2443 for ival,val in enumerate(wave[0]): 2444 if any(CSI[Stype][0][ival]):2444 if np.any(CSI[Stype][0][ival]): 2445 2445 waveVal = wx.TextCtrl(waveData,value='%.4f'%(val),style=wx.TE_PROCESS_ENTER) 2446 2446 waveVal.Bind(wx.EVT_TEXT_ENTER,OnWaveVal) -
trunk/GSASIIplot.py
r1957 r1958 3031 3031 scof.append(spos[0][:3]) 3032 3032 ccof.append(spos[0][3:]) 3033 wave += G2mth.posFourier(tau,np.array(scof),np.array(ccof), -1) #hmm, why -1 work for Na2CO3?3033 wave += G2mth.posFourier(tau,np.array(scof),np.array(ccof),1) #hmm, why -1 work for Na2CO3? 3034 3034 if mapData['Flip']: 3035 3035 Title = 'Charge flip' … … 4414 4414 if keyBox: 4415 4415 OnKeyPressed(event) 4416 Draw('key') 4416 return 4417 Draw('key up') 4417 4418 4418 4419 def OnKeyPressed(event): #On key down for repeating operation - used to change tau... … … 4433 4434 G2frame.tau %= 1. #force 0-1 range 4434 4435 G2frame.G2plotNB.status.SetStatusText('Modulation tau = %.2f'%(G2frame.tau),1) 4435 data['Drawing']['Atoms'] = G2mth.ApplyModulation(data,G2frame.tau) #modifies drawing atom array!4436 data['Drawing']['Atoms'],Fade = G2mth.ApplyModulation(data,G2frame.tau) #modifies drawing atom array! 4436 4437 SetDrawAtomsText(data['Drawing']['Atoms']) 4437 4438 G2phG.FindBondsDraw(data) #rebuild bonds & polygons 4438 Draw('key') 4439 if not np.any(Fade): 4440 Fade += 1 4441 Draw('key down',Fade) 4439 4442 4440 4443 def GetTruePosition(xy,Add=False): … … 5001 5004 glShadeModel(GL_SMOOTH) 5002 5005 5003 def Draw(caller='' ):5006 def Draw(caller='',Fade=None): 5004 5007 #useful debug? 5005 5008 # if caller: … … 5075 5078 # glEnable(GL_BLEND) 5076 5079 # glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) 5080 if Fade == None: 5081 atmFade = np.ones(len(drawingData['Atoms'])) 5082 else: 5083 atmFade = Fade 5077 5084 for iat,atom in enumerate(drawingData['Atoms']): 5078 5085 x,y,z = atom[cx:cx+3] … … 5084 5091 atNum = -1 5085 5092 CL = atom[cs+2] 5086 atColor = np.array(CL)/255. 5093 if not atmFade[iat]: 5094 continue 5095 atColor = atmFade[iat]*np.array(CL)/255. 5087 5096 if drawingData['showRigidBodies'] and atom[ci] in rbAtmDict: 5088 5097 bndColor = Or -
trunk/GSASIIspc.py
r1957 r1958 1506 1506 CSI = [np.zeros((2),dtype='i'),np.zeros(2)] 1507 1507 if 'Crenel' in waveType: 1508 dF = fracCrenel(tau,delt2[:1],delt2[1:]).squeeze()1508 dF = np.zeros_like(tau) 1509 1509 else: 1510 1510 dF = fracFourier(tau,nH,delt2[:1],delt2[1:]).squeeze() … … 1517 1517 fsc = np.ones(2,dtype='i') 1518 1518 if 'Crenel' in waveType: 1519 dFT = fracCrenel(tauT,delt2[:1],delt2[1:]).squeeze()1519 dFT = np.zeros_like(tau) 1520 1520 fsc = [1,1] 1521 1521 else: #Fourier … … 1571 1571 sdet,ssdet,dtau,dT,tauT = getTauT(tau,sop,ssop,XYZ) 1572 1572 xsc = np.ones(6,dtype='i') 1573 if waveType == 'Fourier':1573 if 'Fourier' in waveType: 1574 1574 dXT = posFourier(np.sort(tauT),nH,delt6[:3],delt6[3:]) #+np.array(XYZ)[:,np.newaxis,np.newaxis] 1575 1575 elif waveType == 'Sawtooth': -
trunk/GSASIIstrMath.py
r1957 r1958 640 640 for isym,(sop,ssop) in enumerate(zip(SGOps,SSOps)): 641 641 sdet,ssdet,dtau,dT,tauT = G2spc.getTauT(0,sop,ssop,xyz) 642 Smult[ix][isym] = sdet *ssdet642 Smult[ix][isym] = sdet 643 643 TauT[ix][isym] = tauT 644 644 return Smult,TauT … … 971 971 972 972 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 973 SGInv = SGData['SGInv'] 973 974 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 974 975 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) … … 978 979 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 979 980 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) 980 SStauM = GetSSTauM(SGData['SGOps'],SSGData['SSGOps'],pfx,calcControls,Xdata) 981 SStauM = list(GetSSTauM(SGData['SGOps'],SSGData['SSGOps'],pfx,calcControls,Xdata)) 982 if SGData['SGInv']: 983 SStauM[0] = np.hstack((SStauM[0],SStauM[0])) 984 SStauM[1] = np.hstack((SStauM[1],SStauM[1])) 985 modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']]) 981 986 FF = np.zeros(len(Tdata)) 982 987 if 'NC' in calcControls[hfx+'histType']: … … 1011 1016 Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata]) 1012 1017 FF = refDict['FF']['FF'][iref][Tindx] 1013 Uniq = np.inner(H[:3],SGMT) 1014 SSUniq = np.inner(H,SSGMT) 1015 Phi = np.inner(H[:3],SGT) 1016 SSPhi = np.inner(H,SSGT) 1017 GfpuA,GfpuB = G2mth.Modulation(waveTypes,SSUniq,SSPhi,FSSdata,XSSdata,USSdata,SStauM) 1018 HM = np.zeros(4) 1019 HM[:3] += H[3]*modQ 1020 HM += H 1021 Uniq = np.inner(HM[:3],SGMT) 1022 SSUniq = np.inner(HM,SSGMT) 1023 Phi = np.inner(HM[:3],SGT) 1024 SSPhi = np.inner(HM,SSGT) 1025 if SGInv: #if centro - expand HKL sets 1026 Uniq = np.vstack((Uniq,-Uniq)) 1027 SSUniq = np.vstack((SSUniq,-SSUniq)) 1028 Phi = np.hstack((Phi,-Phi)) 1029 SSPhi = np.hstack((SSPhi,-SSPhi)) 1030 GfpuA,Hphi = G2mth.Modulation(waveTypes,SSUniq,SSPhi,FSSdata,XSSdata,USSdata,SStauM) 1018 1031 phase = twopi*(np.inner(Uniq,(dXdata.T+Xdata.T))+Phi[:,np.newaxis]) 1019 1032 sinp = np.sin(phase) … … 1025 1038 Tcorr = Tiso*Tuij*Mdata*Fdata/len(Uniq) 1026 1039 fa = np.array([(FF+FP-Bab)*cosp*Tcorr,-FPP*sinp*Tcorr]) #2 x sym x atoms 1027 fb = np.zeros_like(fa) #ditto 1028 if not SGData['SGInv']: 1029 fb = np.array([(FF+FP-Bab)*sinp*Tcorr,FPP*cosp*Tcorr]) 1030 fa = fa*GfpuA[np.newaxis,:,:]-fb*GfpuB[np.newaxis,:,:] 1031 fb = fb*GfpuA[np.newaxis,:,:]+fa*GfpuB[np.newaxis,:,:] 1032 fas = np.real(np.sum(np.sum(fa,axis=1),axis=1)) #real 1040 fb = np.array([(FF+FP-Bab)*sinp*Tcorr,FPP*cosp*Tcorr]) 1041 fa *= GfpuA 1042 fb *= GfpuA 1043 fas = np.real(np.sum(np.sum(fa,axis=1),axis=1)) 1033 1044 fbs = np.real(np.sum(np.sum(fb,axis=1),axis=1)) 1034 1045 fasq = fas**2 … … 1037 1048 refl[7+im] = np.sum(fasq)+np.sum(fbsq) 1038 1049 refl[10+im] = atan2d(fbs[0],fas[0]) 1050 # GSASIIpath.IPyBreak() 1039 1051 1040 1052 def SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict): … … 2772 2784 sumdF = 0 2773 2785 sumdF2 = 0 2786 if im: 2787 sumSSFo = np.zeros(10) 2788 sumSSFo2 = np.zeros(10) 2789 sumSSdF = np.zeros(10) 2790 sumSSdF2 = np.zeros(10) 2791 sumSSwYo = np.zeros(10) 2792 sumSSwdf2 = np.zeros(10) 2793 SSnobs = np.zeros(10) 2774 2794 nobs = 0 2775 2795 nrej = 0 2776 2796 next = 0 2797 maxH = 0 2777 2798 if calcControls['F**2']: 2778 2799 for i,ref in enumerate(refDict['RefList']): … … 2792 2813 df[i] = -w*(ref[5+im]-ref[7+im]) 2793 2814 sumwYo += (w*ref[5+im])**2 #w*Fo^2 2815 if im: #accumulate super lattice sums 2816 ind = int(abs(ref[3])) 2817 sumSSFo[ind] += Fo 2818 sumSSFo2[ind] += ref[5+im] 2819 sumSSdF[ind] += abs(Fo-np.sqrt(ref[7+im])) 2820 sumSSdF2[ind] += abs(ref[5+im]-ref[7+im]) 2821 sumSSwYo[ind] += (w*ref[5+im])**2 #w*Fo^2 2822 sumSSwdf2[ind] += df[i]**2 2823 SSnobs[ind] += 1 2824 maxH = max(maxH,ind) 2794 2825 else: 2795 2826 if ref[3+im]: … … 2816 2847 df[i] = -w*(Fo-Fc) 2817 2848 sumwYo += (w*Fo)**2 2849 if im: 2850 ind = int(abs(ref[3])) 2851 sumSSFo[ind] += Fo 2852 sumSSFo2[ind] += ref[5+im] 2853 sumSSdF[ind] += abs(Fo-Fc) 2854 sumSSdF2[ind] += abs(ref[5+im]-ref[7+im]) 2855 sumSSwYo[ind] += (w*Fo)**2 2856 sumSSwdf2[ind] += df[i]**2 2857 SSnobs[ind] += 1 2858 maxH = max(maxH,ind) 2818 2859 else: 2819 2860 if ref[3+im]: … … 2831 2872 Histogram['Residuals'][phfx+'Nrej'] = nrej 2832 2873 Histogram['Residuals'][phfx+'Next'] = next 2874 if im: 2875 Histogram['Residuals'][phfx+'SSRf'] = 100.*sumSSdF[:maxH+1]/sumSSFo[:maxH+1] 2876 Histogram['Residuals'][phfx+'SSRf^2'] = 100.*sumSSdF2[:maxH+1]/sumSSFo2[:maxH+1] 2877 Histogram['Residuals'][phfx+'SSNref'] = SSnobs[:maxH+1] 2878 Histogram['Residuals']['SSwR'] = np.sqrt(sumSSwdf2[:maxH+1]/sumSSwYo[:maxH+1])*100. 2833 2879 Nobs += nobs 2834 2880 Nrej += nrej
Note: See TracChangeset
for help on using the changeset viewer.