Changeset 335 for trunk/GSASIIplot.py
- Timestamp:
- Jul 7, 2011 1:53:57 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r327 r335 49 49 npacosd = lambda x: 180.*np.arccos(x)/np.pi 50 50 npasind = lambda x: 180.*np.arcsin(x)/np.pi 51 npatand = lambda x: 180.*np.arctan(x)/np.pi 51 52 npatan2d = lambda x,y: 180.*np.arctan2(x,y)/np.pi 52 53 … … 1021 1022 instParms = self.PatternTree.GetItemPyData( \ 1022 1023 G2gd.GetPatternTreeItemId(self,PatternId, 'Instrument Parameters')) 1023 if instParms[0][0] == 'PXC':1024 if instParms[0][0] in ['PXC','PNC']: 1024 1025 lam = instParms[1][1] 1025 1026 if len(instParms[1]) == 13: … … 1088 1089 for peak in peaks: 1089 1090 X.append(4.0*math.pi*sind(peak[0]/2.0)/lam) 1090 s = 1.17741*math.sqrt(peak[4])*math.pi/18000. 1091 try: 1092 s = 1.17741*math.sqrt(peak[4])*math.pi/18000. 1093 except ValueError: 1094 s = 0.01 1091 1095 g = peak[6]*math.pi/18000. 1092 1096 G = gamFW(g,s) … … 1211 1215 SHCoef = SHData['SH Coeff'][1] 1212 1216 cell = generalData['Cell'][1:7] 1217 Amat,Bmat = G2lat.cell2AB(cell) 1218 sq2 = 1.0/math.sqrt(2.0) 1213 1219 1220 def rp2xyz(r,p): 1221 z = npcosd(r) 1222 xy = np.sqrt(1.-z**2) 1223 return xy*npsind(p),xy*npcosd(p),z 1224 1214 1225 def OnMotion(event): 1215 Page.canvas.SetToolTipString('')1226 SHData = data['General']['SH Texture'] 1216 1227 if event.xdata and event.ydata: #avoid out of frame errors 1217 if 'Pole figure' in SHData['PlotType']: 1218 xpos = event.xdata 1219 ypos = event.ydata 1220 Int = 0 1221 if xpos**2+ypos**2 < 1.0: 1222 r,p = 2.*npasind(np.sqrt(xpos**2+ypos**2)*0.707106782),npatan2d(ypos,xpos) 1228 xpos = event.xdata 1229 ypos = event.ydata 1230 if 'Inverse' in SHData['PlotType']: 1231 r = xpos**2+ypos**2 1232 if r <= 1.0: 1233 if 'equal' in self.Projection: 1234 r,p = 2.*npasind(np.sqrt(r)*sq2),npatan2d(ypos,xpos) 1235 else: 1236 r,p = 2.*npatand(np.sqrt(r)),npatan2d(ypos,xpos) 1237 ipf = G2lat.invpolfcal(IODFln,SGData,np.array([r,]),np.array([p,])) 1238 xyz = np.inner(Amat.T,np.array([rp2xyz(r,p)])) 1239 y,x,z = list(xyz/np.max(np.abs(xyz))) 1240 1241 self.G2plotNB.status.SetFields(['', 1242 'psi =%9.3f, beta =%9.3f, MRD =%9.3f xyz=%5.2f,%5.2f,%5.2f'%(r,p,ipf,x,y,z)]) 1243 1244 elif 'Axial' in SHData['PlotType']: 1245 pass 1246 1247 else: #ordinary pole figure 1248 z = xpos**2+ypos**2 1249 if z <= 1.0: 1250 z = np.sqrt(z) 1251 if 'equal' in self.Projection: 1252 r,p = 2.*npasind(z*sq2),npatan2d(ypos,xpos) 1253 else: 1254 r,p = 2.*npatand(z),npatan2d(ypos,xpos) 1223 1255 pf = G2lat.polfcal(ODFln,SamSym[textureData['Model']],np.array([r,]),np.array([p,])) 1224 1256 self.G2plotNB.status.SetFields(['','phi =%9.3f, gam =%9.3f, MRD =%9.3f'%(r,p,pf)]) 1225 1257 1226 1258 try: 1227 1259 plotNum = self.G2plotNB.plotList.index('Texture') … … 1236 1268 Page = self.G2plotNB.nb.GetPage(plotNum) 1237 1269 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 1238 Page.SetFocus() 1239 1270 1271 Page.SetFocus() 1272 self.G2plotNB.status.SetFields(['','']) 1273 PH = np.array(SHData['PFhkl']) 1274 phi,beta = G2lat.CrsAng(PH,cell,SGData) 1275 ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData) 1276 PX = np.array(SHData['PFxyz']) 1277 gam = atan2d(PX[0],PX[1]) 1278 xy = math.sqrt(PX[0]**2+PX[1]**2) 1279 xyz = math.sqrt(PX[0]**2+PX[1]**2+PX[2]**2) 1280 psi = asind(xy/xyz) 1281 IODFln = G2lat.Glnh(Start,SHCoef,psi,gam,SamSym[textureData['Model']]) 1240 1282 if 'Axial' in SHData['PlotType']: 1241 PH = np.array(SHData['PFhkl'])1242 phi,beta = G2lat.CrsAng(PH,cell,SGData)1243 ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData)1244 1283 X = np.linspace(0,90.0,26) 1245 1284 Y = G2lat.polfcal(ODFln,SamSym[textureData['Model']],X,0.0) … … 1251 1290 1252 1291 else: 1292 npts = 201 1253 1293 if 'Inverse' in SHData['PlotType']: 1254 PX = np.array(SHData['PFxyz'])1255 gam = atan2d(PX[0],PX[1])1256 xy = math.sqrt(PX[0]**2+PX[1]**2)1257 xyz = math.sqrt(PX[0]**2+PX[1]**2+PX[2]**2)1258 psi = asind(xy/xyz)1259 npts = 2011260 ODFln = G2lat.Glnh(Start,SHCoef,psi,gam,SamSym[textureData['Model']])1261 1294 X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts)) 1262 1295 R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten() 1263 R = np.where(R <= 1.,2.*npasind(R*0.70710678),0.0) 1296 if 'equal' in self.Projection: 1297 R = np.where(R <= 1.,2.*npasind(R*sq2),0.0) 1298 else: 1299 R = np.where(R <= 1.,2.*npatand(R),0.0) 1264 1300 Z = np.zeros_like(R) 1265 Z = G2lat.invpolfcal( ODFln,SGData,R,P)1301 Z = G2lat.invpolfcal(IODFln,SGData,R,P) 1266 1302 Z = np.reshape(Z,(npts,npts)) 1267 1303 CS = Plot.contour(Y,X,Z,aspect='equal') 1268 1304 Plot.clabel(CS,fontsize=9,inline=1) 1269 Img = Plot.imshow(Z.T,aspect='equal',cmap= 'binary',extent=[-1,1,-1,1])1305 Img = Plot.imshow(Z.T,aspect='equal',cmap=self.ContourColor,extent=[-1,1,-1,1]) 1270 1306 if newPlot: 1271 1307 # Page.figure.colorbar(Img) #colorbar fails - crashes gsasii 1272 1308 newPlot = False 1273 1309 Plot.set_title('Inverse pole figure for XYZ='+str(SHData['PFxyz'])) 1310 Plot.set_xlabel(self.Projection.capitalize()+' projection') 1274 1311 1275 1312 else: 1276 PH = np.array(SHData['PFhkl'])1277 phi,beta = G2lat.CrsAng(PH,cell,SGData)1278 npts = 2011279 ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData)1280 1313 X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts)) 1281 1314 R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten() 1282 R = np.where(R <= 1.,2.*npasind(R*0.70710678),0.0) 1315 if 'equal' in self.Projection: 1316 R = np.where(R <= 1.,2.*npasind(R*sq2),0.0) 1317 else: 1318 R = np.where(R <= 1.,2.*npatand(R),0.0) 1283 1319 Z = np.zeros_like(R) 1284 1320 Z = G2lat.polfcal(ODFln,SamSym[textureData['Model']],R,P) … … 1286 1322 CS = Plot.contour(Y,X,Z,aspect='equal') 1287 1323 Plot.clabel(CS,fontsize=9,inline=1) 1288 Img = Plot.imshow(Z.T,aspect='equal',cmap= 'binary',extent=[-1,1,-1,1])1324 Img = Plot.imshow(Z.T,aspect='equal',cmap=self.ContourColor,extent=[-1,1,-1,1]) 1289 1325 if newPlot: 1290 1326 # Page.figure.colorbar(Img) #colorbar fails - crashes gsasii 1291 1327 newPlot = False 1292 1328 Plot.set_title('Pole figure for HKL='+str(SHData['PFhkl'])) 1329 Plot.set_xlabel(self.Projection.capitalize()+' projection') 1293 1330 Page.canvas.draw() 1294 1331
Note: See TracChangeset
for help on using the changeset viewer.