Changeset 1792
- Timestamp:
- Apr 17, 2015 11:50:01 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1791 r1792 3565 3565 dlg.CenterOnParent() 3566 3566 try: 3567 G2stMn.SeqRefine(self.GSASprojectfile,dlg)3567 OK,Msg = G2stMn.SeqRefine(self.GSASprojectfile,dlg) 3568 3568 finally: 3569 3569 dlg.Update(101.) # forces the Auto_Hide; needed after move w/Win & wx3.0 3570 3570 dlg.Destroy() 3571 3571 wx.Yield() 3572 dlg = wx.MessageDialog(self,'Load new result?','Refinement results',wx.OK|wx.CANCEL) 3573 try: 3574 if dlg.ShowModal() == wx.ID_OK: 3575 Id = 0 3576 self.PatternTree.DeleteChildren(self.root) 3577 if self.HKL: self.HKL = [] 3578 if self.G2plotNB.plotList: 3579 self.G2plotNB.clear() 3580 G2IO.ProjFileOpen(self) 3581 Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequential results') 3582 self.PatternTree.SelectItem(Id) 3583 3584 finally: 3585 dlg.Destroy() 3572 if OK: 3573 dlg = wx.MessageDialog(self,'Load new result?','Refinement results',wx.OK|wx.CANCEL) 3574 try: 3575 if dlg.ShowModal() == wx.ID_OK: 3576 Id = 0 3577 self.PatternTree.DeleteChildren(self.root) 3578 if self.HKL: self.HKL = [] 3579 if self.G2plotNB.plotList: 3580 self.G2plotNB.clear() 3581 G2IO.ProjFileOpen(self) 3582 Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequential results') 3583 self.PatternTree.SelectItem(Id) 3584 3585 finally: 3586 dlg.Destroy() 3587 else: 3588 self.ErrorDialog('Sequential refinement error',Msg) 3586 3589 3587 3590 def ErrorDialog(self,title,message,parent=None, wtype=wx.OK): -
trunk/GSASIIddataGUI.py
r1789 r1792 59 59 ''' 60 60 G2frame.dataFrame.SetStatusText('') 61 keyList = G2frame.GetHistogramNames(['PWDR','HKLF']) 61 62 UseList = data['Histograms'] 62 63 if UseList: … … 69 70 PhaseName = generalData['Name'] 70 71 SGData = generalData['SGData'] 71 keyList = UseList.keys()72 keyList.sort()73 72 if not hist and len(keyList): 74 73 hist = keyList[0] -
trunk/GSASIIlattice.py
r1773 r1792 970 970 Laue = SGData['SGLaue'] 971 971 Naxis = SGData['SGUniq'] 972 DH = np.inner(H,np.inner(G,H)) 972 if len(H.shape) == 1: 973 DH = np.inner(H,np.inner(G,H)) 974 else: 975 DH = np.array([np.inner(h,np.inner(G,h)) for h in H]) 973 976 if Laue == '2/m': 974 977 if Naxis == 'a': … … 984 987 DR = np.inner(H4,np.inner(G,H4)) 985 988 DHR = np.inner(H,np.inner(G,H4)) 986 987 989 else: 988 990 DR = np.inner(H3,np.inner(G,H3)) … … 991 993 phi = np.where(DHR <= 1.0,acosd(DHR),0.0) 992 994 if Laue == '-1': 993 BA = H [1]*a/(b-H[0]*cosd(ga))994 BB = H [0]*sind(ga)**2995 BA = H.T[1]*a/(b-H.T[0]*cosd(ga)) 996 BB = H.T[0]*sind(ga)**2 995 997 elif Laue == '2/m': 996 998 if Naxis == 'a': 997 BA = H [2]*b/(c-H[1]*cosd(al))998 BB = H [1]*sind(al)**2999 BA = H.T[2]*b/(c-H.T[1]*cosd(al)) 1000 BB = H.T[1]*sind(al)**2 999 1001 elif Naxis == 'b': 1000 BA = H [0]*c/(a-H[2]*cosd(be))1001 BB = H [2]*sind(be)**21002 BA = H.T[0]*c/(a-H.T[2]*cosd(be)) 1003 BB = H.T[2]*sind(be)**2 1002 1004 else: 1003 BA = H [1]*a/(b-H[0]*cosd(ga))1004 BB = H [0]*sind(ga)**21005 BA = H.T[1]*a/(b-H.T[0]*cosd(ga)) 1006 BB = H.T[0]*sind(ga)**2 1005 1007 elif Laue in ['mmm','4/m','4/mmm']: 1006 BA = H[1]*a 1007 BB = H[0]*b 1008 1008 BA = H.T[1]*a 1009 BB = H.T[0]*b 1009 1010 elif Laue in ['3R','3mR']: 1010 BA = H [0]+H[1]-2.0*H[2]1011 BB = SQ3*(H [0]-H[1])1011 BA = H.T[0]+H.T[1]-2.0*H.T[2] 1012 BB = SQ3*(H.T[0]-H.T[1]) 1012 1013 elif Laue in ['m3','m3m']: 1013 BA = H [1]1014 BB = H [0]1014 BA = H.T[1] 1015 BB = H.T[0] 1015 1016 else: 1016 BA = H [0]+2.0*H[1]1017 BB = SQ3*H [0]1017 BA = H.T[0]+2.0*H.T[1] 1018 BB = SQ3*H.T[0] 1018 1019 beta = atan2d(BA,BB) 1019 1020 return phi,beta … … 1062 1063 1063 1064 BD = 1.0-BC**2 1064 if BD > 1.e-6: 1065 C = rpd/math.sqrt(BD) 1066 else: 1067 C = 0. 1065 C = np.where(BD>1.e-6,rpd/np.sqrt(BD),0.) 1068 1066 dPSdA = [-C*(-BC1*SSomeg*SCchi-BC2*SSomeg*SSchi-BC3*SComeg), 1069 1067 -C*(-BC1*SComeg*SSchi+BC2*SComeg*SCchi), … … 1084 1082 dBBdF = BC1*SComeg-BC3*SSomeg*SCchi 1085 1083 1086 if BD > 1.e-6: 1087 dGMdA = [(BA*dBBdO-BB*dBAdO)/BD,(BA*dBBdC-BB*dBAdC)/BD,(BA*dBBdF-BB*dBAdF)/BD] 1088 else: 1089 dGMdA = [0.0,0.0,0.0] 1090 1084 dGMdA = np.where(BD > 1.e-6,[(BA*dBBdO-BB*dBAdO)/BD,(BA*dBBdC-BB*dBAdC)/BD, \ 1085 (BA*dBBdF-BB*dBAdF)/BD],[np.zeros_like(BD),np.zeros_like(BD),np.zeros_like(BD)]) 1091 1086 1092 1087 return psi,gam,dPSdA,dGMdA … … 1134 1129 import pytexture as ptx 1135 1130 if SGLaue in ['m3','m3m']: 1136 Kcl = 0.0 1131 if phi.shape: 1132 Kcl = np.zeros_like(phi) 1133 else: 1134 Kcl = 0. 1137 1135 for j in range(0,L+1,4): 1138 1136 im = j/4+1 1139 pcrs,dum = ptx.pyplmpsi(L,j,1,phi) 1137 if phi.shape: 1138 pcrs = np.array([ptx.pyplmpsi(L,j,1,p)[0] for p in phi]).flatten() 1139 else: 1140 pcrs,dum = ptx.pyplmpsi(L,j,1,phi) 1140 1141 Kcl += BOH['L='+str(L)][N-1][im-1]*pcrs*cosd(j*beta) 1141 1142 else: 1142 pcrs,dum = ptx.pyplmpsi(L,N,1,phi) 1143 if phi.shape: 1144 pcrs = np.array([ptx.pyplmpsi(L,N,1,p)[0] for p in phi]).flatten() 1145 else: 1146 pcrs,dum = ptx.pyplmpsi(L,N,1,phi) 1143 1147 pcrs *= RSQ2PI 1144 1148 if N: … … 1159 1163 'needs doc string' 1160 1164 import pytexture as ptx 1161 psrs,dpdps = ptx.pyplmpsi(L,M,1,psi) 1165 if psi.shape: 1166 psrs = np.array([ptx.pyplmpsi(L,M,1,p) for p in psi]) 1167 psrs,dpdps = np.reshape(psrs.flatten(),(-1,2)).T 1168 else: 1169 psrs,dpdps = ptx.pyplmpsi(L,M,1,psi) 1162 1170 psrs *= RSQ2PI 1163 1171 dpdps *= RSQ2PI -
trunk/GSASIImath.py
r1790 r1792 1589 1589 out += ("e{:d}").format(valoff) # add an exponent, when needed 1590 1590 return out 1591 1591 1592 ################################################################################ 1592 1593 ##### Texture fitting stuff 1593 1594 ################################################################################ 1594 1595 1595 def FitTexture(General,Gangls,refData): 1596 def FitTexture(General,Gangls,refData,keyList): 1597 import pytexture as ptx 1598 ptx.pyqlmninit() #initialize fortran arrays for spherical harmonics 1596 1599 1597 1600 def printSpHarm(textureData,SHtextureSig): … … 1670 1673 return Mat 1671 1674 1675 def errSpHarm2(values,SGData,cell,Gangls,shModel,refData,parmDict,varyList): 1676 parmDict.update(zip(varyList,values)) 1677 Mat = np.empty(0) 1678 Sangls = [parmDict['Sample '+'omega'],parmDict['Sample '+'chi'],parmDict['Sample '+'phi']] 1679 for hist in Gangls.keys(): 1680 Refs = refData[hist] 1681 # wt = np.sqrt(ref[4]) 1682 wt = 1. 1683 Refs[:,6] = 1. 1684 H = Refs[:,:3] 1685 phi,beta = G2lat.CrsAng(H,cell,SGData) 1686 psi,gam,x,x = G2lat.SamAng(Refs[:,3]/2.,Gangls[hist],Sangls,False) #assume not Bragg-Brentano! 1687 for item in parmDict: 1688 if 'C' in item: 1689 L,M,N = eval(item.strip('C')) 1690 Kcl = G2lat.GetKcl(L,N,SGData['SGLaue'],phi,beta) 1691 Ksl,x,x = G2lat.GetKsl(L,M,shModel,psi,gam) 1692 Lnorm = G2lat.Lnorm(L) 1693 Refs[:,6] += parmDict[item]*Lnorm*Kcl*Ksl 1694 mat = wt*(Refs[:,5]-Refs[:,6]) 1695 Mat = np.concatenate((Mat,mat)) 1696 return Mat 1697 1672 1698 def dervSpHarm(values,SGData,cell,Gangls,shModel,refData,parmDict,varyList): 1673 1699 Mat = np.empty(0) … … 1717 1743 begin = time.time() 1718 1744 values = np.array(Dict2Values(parmDict, varyList)) 1719 result = so.leastsq(errSpHarm ,values,Dfun=dervSpHarm,full_output=True,1745 result = so.leastsq(errSpHarm2,values,Dfun=dervSpHarm,full_output=True, 1720 1746 args=(SGData,cell,Gangls,Texture['Model'],refData,parmDict,varyList)) 1721 1747 ncyc = int(result[2]['nfev']/2) … … 1739 1765 break 1740 1766 1741 for hist in refData:1767 for hist in keyList: 1742 1768 print ' Texture corrections for '+hist 1743 1769 for ref in refData[hist]: -
trunk/GSASIIphsGUI.py
r1790 r1792 3808 3808 UseList = data['Histograms'] 3809 3809 hist = DData.G2hist 3810 keyList = G2frame.GetHistogramNames(hist[:4]) 3810 3811 sourceDict = UseList[hist] 3811 3812 if 'HKLF' in sourceDict['Histogram']: … … 3816 3817 for name in copyNames: 3817 3818 copyDict[name] = copy.deepcopy(sourceDict[name]) #force copy 3818 keyList = sorted(UseList.keys())3819 3819 if UseList: 3820 3820 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Copy parameters', 3821 'Copy parameters to which histograms?', 3822 keyList) 3821 'Copy parameters to which histograms?',keyList) 3823 3822 try: 3824 3823 if dlg.ShowModal() == wx.ID_OK: … … 3860 3859 for bab in babNames: 3861 3860 copyDict[name][bab] = sourceDict[name][bab][1] 3862 keyList = sorted(UseList.keys())3861 keyList = G2frame.GetHistogramNames(hist[:4]) 3863 3862 if UseList: 3864 3863 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Copy parameters', … … 3895 3894 finally: 3896 3895 dlg.Destroy() 3897 3898 3896 3899 3897 def OnSelDataCopy(event): 3900 hst = G2frame.PatternTree.GetItemText(G2frame.PatternId) 3901 histList = GetHistsLikeSelected(G2frame) 3902 if not histList: 3903 G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame) 3904 return 3905 # # Assemble a list of item labels 3906 # TextTable = {key:label for key,label,dig in 3907 # SetupSampleLabels(hst,data.get('Type'),Inst['Type'][0]) 3908 # } 3909 # # get flexible labels 3910 # TextTable.update({ 3911 # key:Controls[key] for key in Controls if key.startswith('FreePrm') 3912 # }) 3913 # # add a few extra 3914 # TextTable.update({ 3915 # 'Type':'Diffractometer type', 3916 # 'InstrName':'Instrument Name', 3917 # }) 3918 # # Assemble a list of dict entries that would be labeled in the Sample 3919 # # params data window (drop ranId and items not used). 3920 # keyList = [i for i in data.keys() if i in TextTable] 3921 # keyText = [TextTable[i] for i in keyList] 3922 # # sort both lists together, ordered by keyText 3923 # keyText, keyList = zip(*sorted(zip(keyText,keyList))) # sort lists 3924 # selectedKeys = [] 3925 # dlg = G2G.G2MultiChoiceDialog( 3926 # G2frame.dataFrame, 3927 # 'Select which sample parameters\nto copy', 3928 # 'Select sample parameters', keyText) 3929 # try: 3930 # if dlg.ShowModal() == wx.ID_OK: 3931 # selectedKeys = [keyList[i] for i in dlg.GetSelections()] 3932 # finally: 3933 # dlg.Destroy() 3934 # if not selectedKeys: return # nothing to copy 3935 # copyDict = {} 3936 # for parm in selectedKeys: 3937 # copyDict[parm] = data[parm] 3938 # dlg = G2G.G2MultiChoiceDialog( 3939 # G2frame.dataFrame, 3940 # 'Copy sample params from\n'+str(hst[5:])+' to...', 3941 # 'Copy sample parameters', histList) 3942 # try: 3943 # if dlg.ShowModal() == wx.ID_OK: 3944 # result = dlg.GetSelections() 3945 # for i in result: 3946 # item = histList[i] 3947 # Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,item) 3948 # sampleData = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Sample Parameters')) 3949 # sampleData.update(copy.deepcopy(copyDict)) 3950 # finally: 3951 # dlg.Destroy() 3952 G2plt.PlotPatterns(G2frame,plotType='SASD',newPlot=False) 3898 UseList = data['Histograms'] 3899 hist = DData.G2hist 3900 keyList = G2frame.GetHistogramNames(hist[:4]) 3901 sourceDict = UseList[hist] 3902 copyDict = {} 3903 if 'HKLF' in sourceDict['Histogram']: 3904 copyNames = ['Scale','Extinction','Babinet'] 3905 else: #PWDR 3906 copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet'] 3907 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame,'Select which parameters to copy', 3908 'Select phase data parameters', copyNames) 3909 try: 3910 if dlg.ShowModal() == wx.ID_OK: 3911 selectedItems = [copyNames[i] for i in dlg.GetSelections()] 3912 finally: 3913 dlg.Destroy() 3914 if not selectedItems: return # nothing to copy 3915 copyDict = {} 3916 for parm in selectedItems: 3917 copyDict[parm] = copy.deepcopy(sourceDict[parm]) 3918 if UseList: 3919 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Copy parameters', 3920 'Copy parameters to which histograms?',keyList) 3921 try: 3922 if dlg.ShowModal() == wx.ID_OK: 3923 for sel in dlg.GetSelections(): 3924 UseList[keyList[sel]].update(copy.deepcopy(copyDict)) 3925 finally: 3926 dlg.Destroy() 3953 3927 3954 3928 … … 5926 5900 phaseName = General['Name'] 5927 5901 Histograms = data['Histograms'] 5902 keyList = G2frame.GetHistogramNames('PWDR') 5928 5903 histNames = [] 5929 5904 refData = {} 5930 5905 Gangls = {} 5931 for name in Histograms.keys():5906 for name in keyList: 5932 5907 if 'PWDR' in name: 5933 5908 im = 0 … … 5947 5922 else: # xray - typical caked 2D image data 5948 5923 refData[name] = np.column_stack((Refs[0],Refs[1],Refs[2],Refs[5+im],Refs[8+im],Refs[12+im+it],np.zeros_like(Refs[0]))) 5949 Error = G2mth.FitTexture(General,Gangls,refData )5924 Error = G2mth.FitTexture(General,Gangls,refData,keyList) 5950 5925 if Error: 5951 5926 wx.MessageBox(Error,caption='Fit Texture Error',style=wx.ICON_EXCLAMATION) -
trunk/GSASIIstrMain.py
r1782 r1792 42 42 43 43 ateln2 = 8.0*math.log(2.0) 44 DEBUG = False44 DEBUG = True 45 45 46 46 def RefineCore(Controls,Histograms,Phases,restraintDict,rigidbodyDict,parmDict,varyList, … … 246 246 print ' *** ERROR - you have no phases to refine! ***' 247 247 print ' *** Refine aborted ***' 248 r aise Exception248 return False,'No phases' 249 249 if not Histograms: 250 250 print ' *** ERROR - you have no data to refine with! ***' 251 251 print ' *** Refine aborted ***' 252 r aise Exception252 return False,'No data' 253 253 rigidbodyDict = G2stIO.GetRigidBodies(GPXfile) 254 254 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) … … 259 259 print '**** WARNING - lattice parameters should not be refined in a sequential refinement ****' 260 260 print '**** instead use the Dij parameters for each powder histogram ****' 261 return False,'Lattice parameter refinement error - see console message' 262 if '::C(' in item: 263 print '**** WARNING - phase texture parameters should not be refined in a sequential refinement ****' 264 print '**** instead use the C(L,N) parameters for each powder histogram ****' 265 return False,'Phase texture refinement error - see console message' 261 266 if 'Seq Data' in Controls: 262 267 histNames = Controls['Seq Data'] … … 319 324 #print 'Errors',errmsg 320 325 #if warnmsg: print 'Warnings',warnmsg 321 r aise Exception(' *** Refine aborted ***')326 return False,' Constraint error' 322 327 #print G2mv.VarRemapShow(varyList) 323 328 if not ihst: … … 368 373 line += 'none' 369 374 print line 370 r aise Exception375 return False,line 371 376 372 377 ifPrint = False … … 419 424 print ' Sequential refinement results are in file: '+ospath.splitext(GPXfile)[0]+'.lst' 420 425 print ' ***** Sequential refinement successful *****' 426 return True,'Success' 421 427 422 428 def RetDistAngle(DisAglCtls,DisAglData): -
trunk/GSASIIstrMath.py
r1791 r1792 1275 1275 for item in SHnames: 1276 1276 L,N = eval(item.strip('C')) 1277 # Kcl = G2lat.GetKcl(L,N,SGData['SGLaue'],phi,beta) 1278 # Ksl,x,x = G2lat.GetKsl(L,0,'0',psi,gam) 1279 # Lnorm = G2lat.Lnorm(L) 1280 # odfCor += parmDict[phfx+item]*Lnorm*Kcl*Ksl 1277 1281 Kcsl,Lnorm = G2lat.GetKclKsl(L,N,SGData['SGLaue'],psi,phi,beta) 1278 1282 odfCor += parmDict[phfx+item]*Lnorm*Kcsl … … 1301 1305 for item in SHnames: 1302 1306 L,N = eval(item.strip('C')) 1307 # Kcl = G2lat.GetKcl(L,N,SGData['SGLaue'],phi,beta) 1308 # Ksl,x,x = G2lat.GetKsl(L,0,'0',psi,gam) 1309 # Lnorm = G2lat.Lnorm(L) 1310 # odfCor += parmDict[phfx+item]*Lnorm*Kcl*Ksl 1311 # dFdODF[phfx+item] = Kcl*Ksl*Lnorm 1303 1312 Kcsl,Lnorm = G2lat.GetKclKsl(L,N,SGData['SGLaue'],psi,phi,beta) 1304 1313 odfCor += parmDict[phfx+item]*Lnorm*Kcsl
Note: See TracChangeset
for help on using the changeset viewer.