Changeset 326 for trunk/GSASIIplot.py
- Timestamp:
- Jun 30, 2011 11:38:20 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r313 r326 1114 1114 Vol = cell[6] 1115 1115 useList = data['Histograms'] 1116 for item in useList: 1117 if useList[item]['Show']: 1118 break 1119 else: 1120 self.G2plotNB.Delete('Microstrain') 1121 return #nothing to show!! 1122 1116 1123 numPlots = len(useList) 1117 1124 … … 1121 1128 Page.figure.clf() 1122 1129 Plot = mp3d.Axes3D(Page.figure) 1130 if not Page.IsShown(): 1131 Page.Show() 1123 1132 except ValueError: 1124 1133 Plot = mp3d.Axes3D(self.G2plotNB.add3D('Microstrain')) … … 1189 1198 dict generalData contains all phase info needed which is in data 1190 1199 ''' 1200 1191 1201 shModels = ['cylindrical','none','shear - 2/m','rolling - mmm'] 1192 1202 SamSym = dict(zip(shModels,['0','-1','2/m','mmm'])) … … 1195 1205 SGData = generalData['SGData'] 1196 1206 textureData = generalData['SH Texture'] 1207 if not textureData['Order']: 1208 self.G2plotNB.Delete('Texture') 1209 return #no plot!! 1197 1210 SHData = generalData['SH Texture'] 1198 1211 SHCoef = SHData['SH Coeff'][1] 1199 1212 cell = generalData['Cell'][1:7] 1200 1213 Start = True 1201 1214 1215 def OnMotion(event): 1216 Page.canvas.SetToolTipString('') 1217 if event.xdata and event.ydata: #avoid out of frame errors 1218 if 'Pole figure' in SHData['PlotType']: 1219 xpos = event.xdata 1220 ypos = event.ydata 1221 Int = 0 1222 if xpos**2+ypos**2 < 1.0: 1223 r,p = 2.*npasind(np.sqrt(xpos**2+ypos**2)*0.707106782),npatan2d(ypos,xpos) 1224 pf = G2lat.polfcal(ODFln,SamSym[textureData['Model']],np.array([r,]),np.array([p,])) 1225 self.G2plotNB.status.SetFields(['','phi =%9.3f, gam =%9.3f, MRD =%9.3f'%(r,p,pf)]) 1226 1202 1227 try: 1203 1228 plotNum = self.G2plotNB.plotList.index('Texture') … … 1211 1236 plotNum = self.G2plotNB.plotList.index('Texture') 1212 1237 Page = self.G2plotNB.nb.GetPage(plotNum) 1238 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 1213 1239 Page.SetFocus() 1214 1240 … … 1218 1244 ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData) 1219 1245 X = np.linspace(0,90.0,26) 1220 Y = np.zeros_like(X) 1221 for i,a in enumerate(X): 1222 Y[i] = G2lat.polfcal(ODFln,SamSym[textureData['Model']],a,0.0) 1246 Y = G2lat.polfcal(ODFln,SamSym[textureData['Model']],X,0.0) 1223 1247 Plot.plot(X,Y,color='k',label=str(SHData['PFhkl'])) 1224 1248 Plot.legend(loc='best') … … 1227 1251 Plot.set_ylabel('MRD',fontsize=14) 1228 1252 1229 1230 1253 else: 1231 # self.G2plotNB.status.SetStatusText('Adjust frame size to get desired aspect ratio',1) 1232 if 'inverse' in SHData['PlotType']: 1254 if 'Inverse' in SHData['PlotType']: 1233 1255 PX = np.array(SHData['PFxyz']) 1234 1256 gam = atan2d(PX[0],PX[1]) 1257 xy = math.sqrt(PX[0]**2+PX[1]**2) 1258 xyz = math.sqrt(PX[0]**2+PX[1]**2+PX[2]**2) 1259 psi = asind(xy/xyz) 1260 npts = 201 1261 ODFln = G2lat.Glnh(Start,SHCoef,psi,gam,SamSym[textureData['Model']]) 1262 X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts)) 1263 R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten() 1264 R = np.where(R <= 1.,2.*npasind(R*0.70710678),0.0) 1265 Z = np.zeros_like(R) 1266 time0 = time.time() 1267 Z = G2lat.invpolfcal(ODFln,SGData,R,P) 1268 print 'inverse time:',time.time()-time0 1269 Z = np.reshape(Z,(npts,npts)) 1270 CS = Plot.contour(Y,X,Z,aspect='equal') 1271 Plot.clabel(CS,fontsize=9,inline=1) 1272 Img = Plot.imshow(Z.T,aspect='equal',cmap='binary',extent=[-1,1,-1,1]) 1273 if newPlot: 1274 Page.figure.colorbar(Img) 1275 newPlot = False 1276 Plot.set_title('Inverse pole figure for XYZ='+str(SHData['PFxyz'])) 1277 print 'inverse pole figure',Img 1278 1235 1279 else: 1236 1280 PH = np.array(SHData['PFhkl']) … … 1242 1286 R = np.where(R <= 1.,2.*npasind(R*0.70710678),0.0) 1243 1287 Z = np.zeros_like(R) 1288 time0 = time.time() 1244 1289 Z = G2lat.polfcal(ODFln,SamSym[textureData['Model']],R,P) 1290 print 'polfig time:',time.time()-time0 1245 1291 Z = np.reshape(Z,(npts,npts)) 1246 Img = Plot.imshow(Z.T,aspect='equal',cmap='binary') 1292 CS = Plot.contour(Y,X,Z,aspect='equal') 1293 Plot.clabel(CS,fontsize=9,inline=1) 1294 Img = Plot.imshow(Z.T,aspect='equal',cmap='binary',extent=[-1,1,-1,1]) 1247 1295 if newPlot: 1248 1296 Page.figure.colorbar(Img) 1249 1297 newPlot = False 1250 1298 Plot.set_title('Pole figure for HKL='+str(SHData['PFhkl'])) 1299 print 'pole figure',Img 1251 1300 Page.canvas.draw() 1252 return1253 1254 1301 1255 1302 def PlotExposedImage(self,newPlot=False,event=None):
Note: See TracChangeset
for help on using the changeset viewer.