Changeset 2372 for trunk/GSASIIplot.py
- Timestamp:
- Jul 12, 2016 3:50:52 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r2369 r2372 3012 3012 ''' 3013 3013 3014 def OnPick(event): 3015 if plotType not in ['Inv. pole figure',]: 3016 return 3017 ind = event.ind[0] 3018 h,k,l = RefSets[ind] 3019 msg = '%d,%d,%d=%.2f'%(h,k,l,Rmd[ind]) 3020 Page.canvas.SetToolTipString(msg) 3021 3022 def rp2xyz(r,p): 3023 z = npcosd(r) 3024 xy = np.sqrt(1.-z**2) 3025 return xy*npcosd(p),xy*npsind(p),z 3026 3027 def OnMotion(event): 3028 if plotType not in ['Inv. pole figure',]: 3029 return 3030 if event.xdata and event.ydata: #avoid out of frame errors 3031 xpos = event.xdata 3032 ypos = event.ydata 3033 r = xpos**2+ypos**2 3034 if r <= 1.0: 3035 r,p = 2.*npatand(np.sqrt(r)),npatan2d(ypos,xpos) #stereoproj. 3036 if p<0.: 3037 p += 360. 3038 ipf = lut(r*np.pi/180.,p*np.pi/180.) 3039 xyz = np.inner(Bmat.T,np.array([rp2xyz(r,p)])) 3040 x,y,z = list(xyz/np.max(np.abs(xyz))) 3041 G2frame.G2plotNB.status.SetStatusText( 3042 'psi =%9.3f, beta =%9.3f, MRD =%9.3f hkl=%5.2f,%5.2f,%5.2f'%(r,p,ipf,x,y,z),1) 3043 3014 3044 import scipy.interpolate as si 3015 3045 generalData = data['General'] … … 3020 3050 Start = False 3021 3051 cell = generalData['Cell'][1:] 3022 A ,B= G2lat.cell2AB(cell[:6])3052 Amat,Bmat = G2lat.cell2AB(cell[:6]) 3023 3053 Vol = cell[6] 3024 3054 useList = data['Histograms'] … … 3048 3078 plotNum = G2frame.G2plotNB.plotList.index(plotType) 3049 3079 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 3080 Page.canvas.mpl_connect('pick_event', OnPick) 3081 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 3050 3082 Page.Choice = None 3051 3083 G2frame.G2plotNB.RaisePageNoRefresh(Page) … … 3078 3110 3079 3111 iso,aniso = coeff[1][:2] 3080 axes = np.inner(A ,np.array(coeff[3]))3112 axes = np.inner(Amat,np.array(coeff[3])) 3081 3113 axes /= nl.norm(axes) 3082 3114 Shkl = np.array(coeff[1]) … … 3107 3139 3108 3140 def genMustrain(xyz,SGData,A,Shkl): 3109 uvw = np.inner(A .T,xyz)3141 uvw = np.inner(Amat.T,xyz) 3110 3142 Strm = np.array(G2spc.MustrainCoeff(uvw,SGData)) 3111 3143 Sum = np.sum(np.multiply(Shkl,Strm)) … … 3117 3149 if np.any(Shkl): 3118 3150 XYZ = np.dstack((X,Y,Z)) 3119 XYZ = np.nan_to_num(np.apply_along_axis(genMustrain,2,XYZ,SGData,A ,Shkl))3151 XYZ = np.nan_to_num(np.apply_along_axis(genMustrain,2,XYZ,SGData,Amat,Shkl)) 3120 3152 X,Y,Z = np.dsplit(XYZ,3) 3121 3153 X = X[:,:,0] … … 3185 3217 refSet = np.vstack((refSet,-refSet)) #add Friedel pairs 3186 3218 refSet = [np.where(ref[2]<0,-1.*ref,ref) for ref in refSet] #take +l of each pair then remove duplicates 3187 refSet = set([str(ref).strip('[]').replace('-0',' 0') for ref in refSet])3188 refSet = [np.fromstring(item,sep=' ') for item in refSet]3219 refSet = [str(ref).strip('[]').replace('-0',' 0') for ref in refSet] 3220 refSet = [np.fromstring(item,sep=' ') for item in set(refSet)] 3189 3221 refSets[ir] = refSet 3222 RefSets = [] 3190 3223 for ir,refSet in enumerate(refSets): 3191 3224 r,beta,phi = G2lat.HKL2SpAng(refSet,cell[:6],SGData) #radius, inclination, azimuth … … 3195 3228 Beta += list(beta) 3196 3229 Rmd += len(phi)*[obsRMD[ir],] 3230 RefSets += refSet 3231 RefSets = np.array(RefSets) 3197 3232 Beta = np.abs(np.array(Beta)) 3198 3233 Phi = np.array(Phi) … … 3200 3235 Rmd = np.array(Rmd) 3201 3236 Rmd = np.where(Rmd<0.,0.,Rmd) 3202 y,x = np.sin(Beta)*np.cos(Phi),np.sin(Beta)*np.sin(Phi)3237 x,y = np.tan(Beta/2.)*np.cos(Phi),np.tan(Beta/2.)*np.sin(Phi) 3203 3238 sq2 = 1.0/math.sqrt(2.0) 3204 3239 npts = 201 … … 3210 3245 # GSASIIpath.IPyBreak() 3211 3246 try: 3212 sfac = 13247 sfac = 0.5 3213 3248 while True: 3214 3249 try: … … 3228 3263 pass 3229 3264 Img = Plot.imshow(Z.T,aspect='equal',cmap=G2frame.ContourColor,extent=[-1,1,-1,1]) 3230 Plot.plot( x,y,'+')3265 Plot.plot(-x,y,'+',picker=3) 3231 3266 Page.figure.colorbar(Img) 3232 3267 Plot.axis('off') 3233 Plot.set_title('0 0 1 Inverse pole figure for %s'%(phase)) 3234 Plot.set_xlabel(G2frame.Projection.capitalize()+' projection') 3268 Plot.set_title('0 0 1 Inverse pole figure for %s\n%s'%(phase,hist)) 3235 3269 3236 3270 Page.canvas.draw() … … 3414 3448 Plot.axis('off') 3415 3449 Plot.set_title('%d %d %d Pole figure for %s'%(h,k,l,pName)) 3416 Plot.set_xlabel(G2frame.Projection.capitalize()+' projection')3417 3450 Page.canvas.draw() 3418 3451
Note: See TracChangeset
for help on using the changeset viewer.