Changeset 3900
- Timestamp:
- Apr 15, 2019 4:15:37 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImath.py
r3896 r3900 3667 3667 return Rhos 3668 3668 3669 Blk = 8 #8 seems optimal3669 Blk = 400 #400 doesn't seem to matter 3670 3670 nBlk = len(XYZ)//Blk #select Blk so this is an exact divide 3671 3671 mapShape = np.array(rho.shape) -
trunk/GSASIIphsGUI.py
r3897 r3900 5193 5193 'backColor':[0,0,0],'depthFog':False,'Zclip':50.0,'cameraPos':50.,'Zstep':0.5, 5194 5194 'radiusFactor':0.85,'contourLevel':1.,'bondRadius':0.1,'ballScale':0.33, 5195 'vdwScale':0.67,'ellipseProb':50,'sizeH':0.50,'unitCellBox':True, 5195 'vdwScale':0.67,'ellipseProb':50,'sizeH':0.50,'unitCellBox':True,'contourMax':1.0, 5196 5196 'showABC':True,'selectedAtoms':[],'Atoms':[],'oldxy':[],'magMult':1.0, 5197 5197 'bondList':{},'viewDir':[1,0,0],'Plane':[[0,0,1],False,False,0.0,[255,255,0]]} … … 5212 5212 if 'contourLevel' not in drawingData: 5213 5213 drawingData['contourLevel'] = 1. 5214 if 'contourMax' not in drawingData: 5215 drawingData['contourMax'] = 1. 5214 5216 if 'viewDir' not in drawingData: 5215 5217 drawingData['viewDir'] = [0,0,1] … … 6130 6132 def OnContourLevel(event): 6131 6133 drawingData['contourLevel'] = contourLevel.GetValue()/100. 6132 contourLevelTxt.SetLabel(' Contour level: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax']))6134 contourLevelTxt.SetLabel(' Rho maximum: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax'])) 6133 6135 G2plt.PlotStructure(G2frame,data) 6134 6136 … … 6209 6211 6210 6212 if generalData['Map']['rhoMax']: 6211 contourLevelTxt = wx.StaticText(drawOptions,-1,' Contour level: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax']))6213 contourLevelTxt = wx.StaticText(drawOptions,-1,' Rho maximum: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax'])) 6212 6214 slideSizer.Add(contourLevelTxt,0,WACV) 6213 6215 contourLevel = wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=int(100*drawingData['contourLevel'])) … … 6256 6258 G2plt.PlotStructure(G2frame,data) 6257 6259 6260 def OnContourMax(event): 6261 drawingData['contourMax'] = contourMax.GetValue()/100. 6262 contourMaxTxt.SetLabel(' Max.: '+'%.2f'%(drawingData['contourMax']*generalData['Map']['rhoMax'])) 6263 G2plt.PlotStructure(G2frame,data) 6264 6258 6265 def OnViewPoint(event): 6259 6266 event.Skip() … … 6345 6352 showSizer.Add(line2Sizer) 6346 6353 6347 if generalData['Map']['rhoMax'] and drawingData['unitCellBox']:6354 if generalData['Map']['rhoMax']: 6348 6355 line3Sizer = wx.BoxSizer(wx.HORIZONTAL) 6349 6356 … … 6352 6359 showCS.SetValue(drawingData['showSlice']) 6353 6360 line3Sizer.Add(showCS,0,WACV) 6361 contourMaxTxt = wx.StaticText(drawOptions,-1,' Max.: '+'%.2f'%(drawingData['contourMax']*generalData['Map']['rhoMax'])) 6362 line3Sizer.Add(contourMaxTxt,0,WACV) 6363 contourMax = wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,size=(150,25),value=int(100*drawingData['contourMax'])) 6364 contourMax.SetRange(1,100) 6365 contourMax.Bind(wx.EVT_SLIDER, OnContourMax) 6366 line3Sizer.Add(contourMax,1,wx.EXPAND|wx.RIGHT) 6354 6367 6355 6368 showSizer.Add(line3Sizer) -
trunk/GSASIIplot.py
r3899 r3900 7983 7983 G2frame.G2plotNB.status.SetStatusText('New quaternion: %.2f+, %.2fi+ ,%.2fj+, %.2fk'%(Q[0],Q[1],Q[2],Q[3]),1) 7984 7984 Draw('move') 7985 elif drawingData['showSlice']: 7986 View = GL.glGetIntegerv(GL.GL_VIEWPORT) 7987 Tx,Ty,Tz = drawingData['viewPoint'][0] 7988 tx,ty,tz = GLU.gluProject(Tx,Ty,Tz) 7989 Cx,Cy,Cz = GLU.gluUnProject(newxy[0],View[3]-newxy[1],tz) 7990 rho = G2mth.getRho([Cx,Cy,Cz],mapData) 7991 G2frame.G2plotNB.status.SetStatusText('Cursor position: %.4f, %.4f, %.4f; density: %.4f'%(Cx,Cy,Cz,rho),1) 7992 7985 7993 7986 7994 def OnMouseWheel(event): … … 8782 8790 for plane in Planes: 8783 8791 RenderPlane(plane,color) 8784 if drawingData['showSlice']: 8785 if len(D4mapData.get('rho',[])): #preferentially select 4D map if there 8786 rho = D4mapData['rho'][:,:,:,int(G2frame.tau*10)] #pick current tau 3D slice 8787 elif len(mapData['rho']): #ordinary 3D map 8788 rho = mapData['rho'] 8789 else: 8790 return 8791 from matplotlib.backends.backend_agg import FigureCanvasAgg 8792 import matplotlib.pyplot as plt 8793 Model = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX) 8794 invModel = nl.inv(Model) 8795 msize = 5. #-5A - 5A slice 8796 npts = int(2*msize/0.25) 8797 VP = np.array(drawingData['viewPoint'][0]) 8798 SX,SY = np.meshgrid(np.linspace(-1.,1.,npts),np.linspace(-1.,1.,npts)) 8799 SXYZ = msize*np.dstack((SX,SY,np.zeros_like(SX))) 8800 SXYZ = np.reshape(np.inner(SXYZ,invModel[:3,:3].T)+VP[nxs,nxs,:],(-1,3)) 8801 Z = np.reshape(G2mth.getRhos(SXYZ,rho),(npts,npts)) 8802 plt.rcParams['figure.facecolor'] = (1.,1.,1.,.5) 8803 plt.cla() 8804 plt.contour(Z,colors='k',linewidths=1) 8805 plt.axis("off") 8806 plt.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.) 8807 canvas = plt.get_current_fig_manager().canvas 8808 agg = canvas.switch_backends(FigureCanvasAgg) 8809 agg.draw() 8810 img, (width, height) = agg.print_to_buffer() 8811 Zimg = np.frombuffer(img, np.uint8).reshape((height, width, 4)) 8812 RenderViewPlane(msize*eplane,Zimg,width,height) 8792 if drawingData['showSlice']: 8793 if len(D4mapData.get('rho',[])): #preferentially select 4D map if there 8794 rho = D4mapData['rho'][:,:,:,int(G2frame.tau*10)] #pick current tau 3D slice 8795 elif len(mapData['rho']): #ordinary 3D map 8796 rho = mapData['rho'] 8797 else: 8798 return 8799 Rmax = np.max(rho)*drawingData['contourMax'] 8800 from matplotlib.backends.backend_agg import FigureCanvasAgg 8801 import matplotlib.pyplot as plt 8802 Model = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX) 8803 invModel = nl.inv(Model) 8804 msize = 5. #-5A - 5A slice 8805 mRes = generalData['Map']['Resolution']/2. 8806 npts = int(2*msize/mRes) 8807 VP = np.array(drawingData['viewPoint'][0]) 8808 SX,SY = np.meshgrid(np.linspace(-1.,1.,npts),np.linspace(-1.,1.,npts)) 8809 SXYZ = msize*np.dstack((SX,SY,np.zeros_like(SX))) 8810 SXYZ = np.reshape(np.inner(SXYZ,invModel[:3,:3].T)+VP[nxs,nxs,:],(-1,3)) 8811 Z = np.reshape(G2mth.getRhos(SXYZ,rho),(npts,npts)) 8812 Z = np.where(Z<=Rmax,Z,Rmax) 8813 plt.rcParams['figure.facecolor'] = (1.,1.,1.,.5) 8814 plt.rcParams['figure.figsize'] = [6.0,6.0] 8815 plt.cla() 8816 plt.contour(Z,colors='k',linewidths=1) 8817 plt.axis("off") 8818 plt.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.) 8819 canvas = plt.get_current_fig_manager().canvas 8820 agg = canvas.switch_backends(FigureCanvasAgg) 8821 agg.draw() 8822 img, (width, height) = agg.print_to_buffer() 8823 Zimg = np.frombuffer(img, np.uint8).reshape((height, width, 4)) 8824 RenderViewPlane(msize*eplane,Zimg,width,height) 8813 8825 8814 8826 try:
Note: See TracChangeset
for help on using the changeset viewer.