Changeset 4291
- Timestamp:
- Feb 10, 2020 10:06:35 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r4289 r4291 5643 5643 self.GeneralCalc.Append(G2G.wxID_MULTIMCSA,'Multi MC/SA','Run Monte Carlo - Simulated Annealing on multiprocessors') 5644 5644 self.GeneralCalc.Append(G2G.wxID_TRANSFORMSTRUCTURE,'Transform','Transform crystal structure') 5645 self.GeneralCalc.Append(G2G.wxID_COMPARESTRUCTURE,'Compare','Compare polyhedra in two structures')5645 self.GeneralCalc.Append(G2G.wxID_COMPARESTRUCTURE,'Compare','Compare polyhedra to ideal octahedra/tetrahedra') 5646 5646 self.GeneralCalc.Append(G2G.wxID_USEBILBAOMAG,'Select magnetic/subgroup phase','If disabled, make in PWDR/Unit Cells') 5647 5647 self.GeneralCalc.Append(G2G.wxID_VALIDPROTEIN,'Protein quality','Protein quality analysis') -
trunk/GSASIImath.py
r4289 r4291 639 639 Ids.append(Atoms[j][cia+8]) 640 640 return Neigh,[OId,Ids] 641 642 def FindOctahedron(results): 643 Octahedron = np.array([[1.,0,0],[0,1.,0],[0,0,1.],[-1.,0,0],[0,-1.,0],[0,0,-1.]]) 644 Polygon = np.array([result[3] for result in results]) 645 Dists = np.array([np.sqrt(np.sum(axis**2)) for axis in Polygon]) 646 bond = np.mean(Dists) 647 std = np.std(Dists) 648 Norms = Polygon/Dists[:,nxs] 649 Tilts = acosd(np.dot(Norms,Octahedron[0])) 650 iAng = np.argmin(Tilts) 651 Qavec = np.cross(Norms[iAng],Octahedron[0]) 652 QA = AVdeg2Q(Tilts[iAng],Qavec) 653 newNorms = prodQVQ(QA,Norms) 654 Rots = acosd(np.dot(newNorms,Octahedron[1])) 655 jAng = np.argmin(Rots) 656 Qbvec = np.cross(Norms[jAng],Octahedron[1]) 657 QB = AVdeg2Q(Rots[jAng],Qbvec) 658 QQ = prodQQ(QA,QB) 659 newNorms = prodQVQ(QQ,Norms) 660 dispVecs = np.array([norm[:,nxs]-Octahedron.T for norm in newNorms]) 661 disp = np.sqrt(np.sum(dispVecs**2,axis=1)) 662 dispids = np.argmin(disp,axis=1) 663 vecDisp = np.array([dispVecs[i,:,dispid] for i,dispid in enumerate(dispids)]) 664 Disps = np.array([disp[i,dispid] for i,dispid in enumerate(dispids)]) 665 meanDisp = np.mean(Disps) 666 stdDisp = np.std(Disps) 667 A,V = Q2AVdeg(QQ) 668 return bond,std,meanDisp,stdDisp,A,V,vecDisp 669 670 def FindTetrahedron(results): 671 Tetrahedron = np.array([[1.,1,1],[1,-1,-1],[-1,1,-1],[-1,-1,1]])/np.sqrt(3.) 672 Polygon = np.array([result[3] for result in results]) 673 Dists = np.array([np.sqrt(np.sum(axis**2)) for axis in Polygon]) 674 bond = np.mean(Dists) 675 std = np.std(Dists) 676 Norms = Polygon/Dists[:,nxs] 677 Tilts = acosd(np.dot(Norms,Tetrahedron[0])) 678 iAng = np.argmin(Tilts) 679 Qavec = np.cross(Norms[iAng],Tetrahedron[0]) 680 QA = AVdeg2Q(Tilts[iAng],Qavec) 681 newNorms = prodQVQ(QA,Norms) 682 Rots = acosd(np.dot(newNorms,Tetrahedron[1])) 683 jAng = np.argmin(Rots) 684 Qbvec = np.cross(Norms[jAng],Tetrahedron[1]) 685 QB = AVdeg2Q(Rots[jAng],Qbvec) 686 QQ = prodQQ(QA,QB) 687 newNorms = prodQVQ(QQ,Norms) 688 dispVecs = np.array([norm[:,nxs]-Tetrahedron.T for norm in newNorms]) 689 disp = np.sqrt(np.sum(dispVecs**2,axis=1)) 690 dispids = np.argmin(disp,axis=1) 691 vecDisp = np.array([dispVecs[i,:,dispid] for i,dispid in enumerate(dispids)]) 692 Disps = np.array([disp[i,dispid] for i,dispid in enumerate(dispids)]) 693 meanDisp = np.mean(Disps) 694 stdDisp = np.std(Disps) 695 A,V = Q2AVdeg(QQ) 696 return bond,std,meanDisp,stdDisp,A,V,vecDisp 641 697 642 698 def FindAllNeighbors(phase,FrstName,AtNames,notName=''): … … 645 701 Atoms = phase['Atoms'] 646 702 atNames = [atom[ct-1] for atom in Atoms] 703 atTypes = [atom[ct] for atom in Atoms] 647 704 Cell = General['Cell'][1:7] 648 705 Amat,Bmat = G2lat.cell2AB(Cell) … … 650 707 indices = (-1,0,1) 651 708 Units = np.array([[h,k,l] for h in indices for k in indices for l in indices]) 652 atTypes = General['AtomTypes']709 AtTypes = General['AtomTypes'] 653 710 Radii = np.array(General['BondRadii']) 654 711 DisAglCtls = General['DisAglCtls'] 655 712 radiusFactor = DisAglCtls['Factors'][0] 656 AtInfo = dict(zip( atTypes,Radii)) #or General['BondRadii']713 AtInfo = dict(zip(AtTypes,Radii)) #or General['BondRadii'] 657 714 Orig = atNames.index(FrstName) 658 715 OId = Atoms[Orig][cia+8] … … 681 738 else: 682 739 Topstr = ' +(%4d)'%(Top) 683 Neigh.append([AtNames[iA]+Topstr, dist[iU]])740 Neigh.append([AtNames[iA]+Topstr,atTypes[iA],dist[iU],dx[iU]]) 684 741 Ids.append(Atoms[iA][cia+8]) 685 742 return Neigh,[OId,Ids] -
trunk/GSASIIphsGUI.py
r4290 r4291 30 30 ''' 31 31 from __future__ import division, print_function 32 import platform 32 33 import os 33 34 import os.path … … 87 88 atan2d = lambda x,y: 180.*np.arctan2(y,x)/np.pi 88 89 90 if '2' in platform.python_version_tuple()[0]: 91 GkDelta = unichr(0x0394) 92 else: 93 GkDelta = chr(0x0394) 89 94 ################################################################################ 90 95 #### phase class definitions … … 284 289 self.EndModal(wx.ID_CANCEL) 285 290 286 ################################################################################287 class CompareDialog(wx.Dialog):288 def __init__(self,parent,phase):289 wx.Dialog.__init__(self,parent,wx.ID_ANY,'Setup polyhedron comparison',290 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)291 self.parent = parent292 self.panel = wxscroll.ScrolledPanel(self) #just a dummy - gets destroyed in Draw!293 self.OPhase = copy.deepcopy(phase) #will be a new phase!294 self.OName = self.OPhase['General']['Name']295 self.TPhase = copy.deepcopy(phase)296 self.TName = self.OName297 self.PhaseNames = parent.GetPhaseNames()298 self.PhaseData = parent.GetPhaseData()299 self.Oatoms = ['','']300 self.Tatoms = ['','']301 self.ONeighbors = []302 self.Tneighbors = []303 self.Draw()304 305 def Draw(self):306 307 def OnPhaseSel(event):308 self.TName = phasesel.GetStringSelection()309 self.Tphase = self.PhaseData[self.TName]310 wx.CallAfter(self.Draw)311 312 def OnOatmOsel(event):313 self.Oatoms[0] = oatmosel.GetStringSelection()314 315 def OnTatmOsel(event):316 self.Tatoms[0] = tatmosel.GetStringSelection()317 generalData = self.OPhase['General']318 DisAglCtls = generalData['DisAglCtls']319 dlg = G2G.DisAglDialog(self.parent,DisAglCtls,generalData)320 if dlg.ShowModal() == wx.ID_OK:321 generalData['DisAglCtls'] = dlg.GetData()322 dlg.Destroy()323 print(G2mth.FindNeighbors(self.OPhase,self.Oatoms[0],self.Tatoms[0])[0])324 325 self.panel.Destroy()326 self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE)327 OgeneralData = self.OPhase['General']328 OatTypes = OgeneralData['AtomTypes']329 TgeneralData = self.OPhase['General']330 TatTypes = TgeneralData['AtomTypes']331 332 mainSizer = wx.BoxSizer(wx.VERTICAL)333 mainSizer.Add(wx.StaticText(self.panel,label='Compare polyhedra in %s to target phase %s:(TBD)'%(self.OName,self.TName)),0,WACV)334 335 Pchoice = self.PhaseNames336 phaseselSizer = wx.BoxSizer(wx.HORIZONTAL)337 phaseselSizer.Add(wx.StaticText(self.panel,label=' Select target phase: '),0,WACV)338 phasesel = wx.ComboBox(self.panel,choices=Pchoice,value=self.OName,339 style=wx.CB_READONLY|wx.CB_DROPDOWN)340 phasesel.Bind(wx.EVT_COMBOBOX,OnPhaseSel)341 phaseselSizer.Add(phasesel,0,WACV)342 mainSizer.Add(phaseselSizer,0,WACV)343 344 mainSizer.Add(wx.StaticText(self.panel,label=' For origin phase %s:'%self.OName),0,WACV)345 oatmoselSizer = wx.BoxSizer(wx.HORIZONTAL)346 oatmoselSizer.Add(wx.StaticText(self.panel,label=' Select origin atom type: '),0,WACV)347 oatmosel = wx.ComboBox(self.panel,choices=OatTypes,style=wx.CB_READONLY|wx.CB_DROPDOWN)348 oatmosel.Bind(wx.EVT_COMBOBOX,OnOatmOsel)349 oatmoselSizer.Add(oatmosel,0,WACV)350 mainSizer.Add(oatmoselSizer,0,WACV)351 352 tatmoselSizer = wx.BoxSizer(wx.HORIZONTAL)353 tatmoselSizer.Add(wx.StaticText(self.panel,label=' Select target atom type: '),0,WACV)354 tatmosel = wx.ComboBox(self.panel,choices=OatTypes,style=wx.CB_READONLY|wx.CB_DROPDOWN)355 tatmosel.Bind(wx.EVT_COMBOBOX,OnTatmOsel)356 tatmoselSizer.Add(tatmosel,0,WACV)357 mainSizer.Add(tatmoselSizer,0,WACV)358 359 mainSizer.Add(wx.StaticText(self.panel,label=' For target phase %s:'%self.TName),0,WACV)360 361 362 OkBtn = wx.Button(self.panel,-1,"Ok")363 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)364 cancelBtn = wx.Button(self.panel,-1,"Cancel")365 cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)366 btnSizer = wx.BoxSizer(wx.HORIZONTAL)367 btnSizer.Add((20,20),1)368 btnSizer.Add(OkBtn)369 btnSizer.Add((20,20),1)370 btnSizer.Add(cancelBtn)371 btnSizer.Add((20,20),1)372 373 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)374 375 self.panel.SetSizer(mainSizer)376 self.panel.SetAutoLayout(1)377 self.panel.SetScrollRate(10,10)378 size = np.array(self.GetSize())379 size = [size[0]-5,size[1]-20] #this fiddling is needed for older wx!380 self.panel.SetSize(size)381 382 def GetSelection(self):383 return None384 385 def OnOk(self,event):386 parent = self.GetParent()387 parent.Raise()388 self.EndModal(wx.ID_OK)389 390 def OnCancel(self,event):391 parent = self.GetParent()392 parent.Raise()393 self.EndModal(wx.ID_CANCEL)394 395 396 291 ################################################################################ 397 292 class TransformDialog(wx.Dialog): … … 1560 1455 del generalData['Map']['Resolution'] 1561 1456 del generalData['Flip']['Resolution'] 1457 if 'Compare' not in generalData: 1458 generalData['Compare'] = {'Oatoms':'','Tatoms':'','Tilts':{'Otilts':[],'Ttilts':[]}, 1459 'Bonds':{'Obonds':[],'Tbonds':[]},'Vects':{'Ovec':[],'Tvec':[]}, 1460 'dVects':{'Ovec':[],'Tvec':[]}} 1562 1461 1563 1462 # end of patches … … 2644 2543 mcsaSizer.Add(line3Sizer) 2645 2544 return mcsaSizer 2545 2546 def compareSizer(): 2547 2548 # generalData['Compare'] = {'Oatom':'','Tatom':'','Tilts':{'Otilts':[],'Ttilts':[]}, 2549 # 'Bonds':{'Obonds':[],'Tbonds':[]},'Vects':{'Ovec':[],'Tvec':[]}, 2550 # 'dVects':{'Ovec':[],'Tvec':[]}} 2551 def OnOatmOsel(event): 2552 generalData['Compare']['Oatoms'] = oatmsel.GetStringSelection() 2553 2554 def OnTatmOsel(event): 2555 generalData['Compare']['Tatoms'] = tatmsel.GetStringSelection() 2556 2557 def OnCompPlots(event): 2558 Bonds = generalData['Compare']['Bonds'] 2559 Tilts = generalData['Compare']['Tilts'] 2560 Vects = generalData['Compare']['Vects'] 2561 Oatoms = generalData['Compare']['Oatoms'] 2562 Tatoms = generalData['Compare']['Tatoms'] 2563 dVects = generalData['Compare']['dVects'] 2564 if len(Bonds['Obonds']): 2565 print(' Octahedra:') 2566 Bonds['Obonds'] = np.array(Bonds['Obonds']) 2567 Bmean = np.mean(Bonds['Obonds']) 2568 Bstd = np.std(Bonds['Obonds']) 2569 title = '%s-%s Octahedral bond lengths'%(Oatoms,Tatoms) 2570 G2plt.PlotBarGraph(G2frame,Bonds['Obonds'],Xname=r'$Bond, \AA$',Title=title,PlotName='Bond') 2571 Tilts['Otilts'] = np.array(Tilts['Otilts']) 2572 Tmean = np.mean(Tilts['Otilts']) 2573 Tstd = np.std(Tilts['Otilts']) 2574 G2plt.PlotBarGraph(G2frame,Tilts['Otilts'],Xname='Tilts, deg', 2575 Title='Octahedral %s tilts'%Oatoms,PlotName='Tilts') 2576 dVects['Ovec'] = np.reshape(np.array(dVects['Ovec']),(-1,3)) 2577 for ix,aX in enumerate(['X','Y','Z']): 2578 G2plt.PlotBarGraph(G2frame,dVects['Ovec'].T[ix],Xname=r'$%s%s, \AA$'%(GkDelta,aX), 2579 Title='%s Octahedral distortion'%Oatoms,PlotName='%s-Delta'%aX) 2580 Vects['Ovec'] = np.array(Vects['Ovec']) #3D plot of tilt vectors 2581 X = Vects['Ovec'].T[0] 2582 Y = Vects['Ovec'].T[1] 2583 Z = Vects['Ovec'].T[2] 2584 G2plt.PlotXYZvect(G2frame,X,Y,Z,r'X-axis',r'Y-axis',r'Z-axis', 2585 Title=r'%s Octahedral tilt vectors'%Oatoms,PlotName='Oct tilts') 2586 print(' %s-%s bond distance: %.3f(%d)'%(Oatoms,Tatoms,Bmean,Bstd*1000)) 2587 print(' %s tilt angle: %.2f(%d)'%(Oatoms,Tmean,Tstd*100)) 2588 2589 if len(Bonds['Tbonds']): 2590 print('Tetrahedra:') 2591 Bonds['Tbonds'] = np.array(Bonds['Tbonds']) 2592 Bmean = np.mean(Bonds['Tbonds']) 2593 Bstd = np.std(Bonds['Tbonds']) 2594 title = '%s-%s Terahedral bond lengths'%(Oatoms,Tatoms) 2595 G2plt.PlotBarGraph(G2frame,Bonds['Tbonds'],Xname=r'$Bond, \AA$',Title=title,PlotName='Bond') 2596 Tilts['Ttilts'] = np.array(Tilts['Ttilts']) 2597 Tmean = np.mean(Tilts['Ttilts']) 2598 Tstd = np.std(Tilts['Ttilts']) 2599 G2plt.PlotBarGraph(G2frame,Tilts['Ttilts'],Xname='Tilts, deg', 2600 Title='Tetrahedral %s tilts'%Oatoms,PlotName='Tilts') 2601 dVects['Tvec'] = np.reshape(np.array(dVects['Tvec']),(-1,3)) 2602 for ix,aX in enumerate(['X','Y','Z']): 2603 G2plt.PlotBarGraph(G2frame,dVects['Tvec'].T[ix],Xname=r'$%s%s, \AA$'%(GkDelta,aX), 2604 Title='%s Tetrahedral distortion'%Oatoms,PlotName='%s-Delta'%aX) 2605 Vects['Tvec'] = np.array(Vects['Ovec']) 2606 X = Vects['Tvec'].T[0] 2607 Y = Vects['Tvec'].T[1] 2608 Z = Vects['Tvec'].T[2] 2609 G2plt.PlotXYZvect(G2frame,X,Y,Z,r'X-axis',r'Y-axis',r'Z-axis', 2610 Title=r'%s Tetrahedral tilt vectors'%Oatoms,PlotName='Tet tilts') 2611 print(' %s-%s bond distance: %.3f(%d)'%(Oatoms,Tatoms,Bmean,Bstd*1000)) 2612 print(' %s tilt angle: %.2f(%d)'%(Oatoms,Tmean,Tstd*100)) 2613 2614 2615 atTypes = generalData['AtomTypes'] 2616 compSizer = wx.BoxSizer(wx.VERTICAL) 2617 compSizer.Add(wx.StaticText(General,label=' Compare polyhedra to ideal octahedra/tetrahedra:'),0,WACV) 2618 2619 atmselSizer = wx.BoxSizer(wx.HORIZONTAL) 2620 atmselSizer.Add(wx.StaticText(General,label=' Select origin atom type: '),0,WACV) 2621 oatmsel = wx.ComboBox(General,choices=atTypes,style=wx.CB_READONLY|wx.CB_DROPDOWN) 2622 oatmsel.SetStringSelection(generalData['Compare']['Oatoms']) 2623 oatmsel.Bind(wx.EVT_COMBOBOX,OnOatmOsel) 2624 atmselSizer.Add(oatmsel,0,WACV) 2625 2626 atmselSizer.Add(wx.StaticText(General,label=' Select target atom type: '),0,WACV) 2627 tatmsel = wx.ComboBox(General,choices=atTypes,style=wx.CB_READONLY|wx.CB_DROPDOWN) 2628 tatmsel.SetStringSelection(generalData['Compare']['Tatoms']) 2629 tatmsel.Bind(wx.EVT_COMBOBOX,OnTatmOsel) 2630 atmselSizer.Add(tatmsel,0,WACV) 2631 2632 if len(generalData['Compare']['Bonds']['Obonds']) or len(generalData['Compare']['Bonds']['Tbonds']): 2633 plotBtn = wx.Button(General,label='Show plots?') 2634 plotBtn.Bind(wx.EVT_BUTTON,OnCompPlots) 2635 atmselSizer.Add(plotBtn) 2636 compSizer.Add(atmselSizer,0,WACV) 2637 return compSizer 2638 2646 2639 2647 2640 # UpdateGeneral execution starts here … … 2713 2706 G2G.HorizontalLine(mainSizer,General) 2714 2707 mainSizer.Add(MCSASizer()) 2708 if generalData['SGData']['SpGrp'] == 'P 1': 2709 G2G.HorizontalLine(mainSizer,General) 2710 mainSizer.Add(compareSizer()) 2715 2711 if SkipDraw: 2716 2712 mainSizer.Clear(True) … … 2810 2806 2811 2807 def OnCompare(event): 2812 while True: 2813 dlg = CompareDialog(G2frame,data) 2814 try: 2815 if dlg.ShowModal() == wx.ID_OK: 2816 print('Compare polyhedra in structures - TBD') 2817 return 2808 generalData = data['General'] 2809 cx,ct,cs,cia = generalData['AtomPtrs'] 2810 atNames = [atm[ct-1] for atm in data['Atoms']] 2811 if not generalData['Compare']['Oatoms']: 2812 G2frame.ErrorDialog('Compare atom selection error','Select atoms for polygon comparison first') 2813 return 2814 DisAglCtls = generalData.get('DisAglCtls',{}) 2815 dlg = G2G.DisAglDialog(G2frame,DisAglCtls,generalData) 2816 if dlg.ShowModal() == wx.ID_OK: 2817 generalData['DisAglCtls'] = dlg.GetData() 2818 dlg.Destroy() 2819 Natm = len(data['Atoms']) 2820 iAtm= 0 2821 pgbar = wx.ProgressDialog('Process polyhedron compare for %d atoms'%Natm,'Atoms done=',Natm+1, 2822 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT) 2823 Tilts = generalData['Compare']['Tilts'] 2824 Tilts.update({'Otilts':[],'Ttilts':[]}) 2825 Bonds = generalData['Compare']['Bonds'] 2826 Bonds.update({'Obonds':[],'Tbonds':[]}) 2827 Vects = generalData['Compare']['Vects'] 2828 Vects.update({'Ovec':[],'Tvec':[]}) 2829 dVects = generalData['Compare']['dVects'] 2830 dVects.update({'Ovec':[],'Tvec':[]}) 2831 Oatoms = generalData['Compare']['Oatoms'] 2832 for atom in data['Atoms']: 2833 if atom[ct] == Oatoms: 2834 results = G2mth.FindAllNeighbors(data,atom[ct-1],atNames)[0] #slow step 2835 if len(results) == 4: 2836 bond,std,meanDisp,stdDisp,A,V,dVec = G2mth.FindTetrahedron(results) 2837 Bonds['Tbonds'].append(bond) 2838 Tilts['Ttilts'].append(A) 2839 Vects['Tvec'].append(V) 2840 dVects['Tvec'].append(dVec) 2841 elif len(results) == 6: 2842 bond,std,meanDisp,stdDisp,A,V,dVec = G2mth.FindOctahedron(results) 2843 Bonds['Obonds'].append(bond) 2844 Tilts['Otilts'].append(A) 2845 Vects['Ovec'].append(V) 2846 dVects['Ovec'].append(dVec) 2818 2847 else: 2819 return 2820 finally: 2821 dlg.Destroy() 2822 2848 print('%s is something else with %d vertices'%(atom[ct-1],len(results))) 2849 GoOn = pgbar.Update(iAtm,newmsg='Atoms done=%d'%(iAtm)) 2850 iAtm += 1 2851 if not GoOn[0]: 2852 break 2853 pgbar.Destroy() 2854 wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL)) 2823 2855 2824 2856 def OnUseBilbao(event): … … 4191 4223 subSizer2.Add(wx.StaticText(panel2,wx.ID_ANY,'Mode name ')) 4192 4224 subSizer2.Add(wx.StaticText(panel2,wx.ID_ANY,' value'),0,wx.ALIGN_RIGHT) 4193 4194 4225 if 'G2VarList' in ISO: 4195 4226 deltaList = [] -
trunk/GSASIIplot.py
r4290 r4291 442 442 return self.canvas.SetToolTipString(text) 443 443 444 445 444 class G2PlotOgl(_tabPlotWin): 446 445 'Creates an OpenGL plot in the GSAS-II graphics window' … … 538 537 page = self.panelList[self.plotList.index(name)] 539 538 page.plotRequiresRedraw = False # plot should not be deleted even if not redrawn 540 541 539 542 540 def RegisterRedrawRoutine(self,name,routine=None,args=(),kwargs={}): … … 5117 5115 5118 5116 ################################################################################ 5117 ##### PlotXYZvect 5118 ################################################################################ 5119 5120 def PlotXYZvect(G2frame,X,Y,Z,labelX=r'X',labelY=r'Y',labelZ=r'Z',Title='',PlotName=None): 5121 5122 # def OnPageChanged(event): 5123 # PlotText = G2frame.G2plotNB.nb.GetPageText(G2frame.G2plotNB.nb.GetSelection()) 5124 # if PlotText == PlotName: 5125 # PlotXYZvect(G2frame,X,Y,Z,labelX,labelY,labelZ,Title,PlotText) 5126 5127 def OnMotion(event): 5128 G2frame.G2plotNB.status.SetStatusText('',1) 5129 5130 if PlotName is None or not len(X): 5131 return 5132 G2frame.G2plotNB.Delete(PlotName) #A cluge: to avoid AccessExceptions on replot 5133 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(PlotName,'3d') 5134 if new: 5135 # G2frame.G2plotNB.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,OnPageChanged) 5136 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 5137 G2frame.G2plotNB.status.SetStatusText('',1) 5138 Page.Choice = None 5139 np.seterr(all='ignore') 5140 Plot.scatter(X,Y,Z,marker='x') 5141 xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T 5142 XYZlim = [min(xyzlim[0]),max(xyzlim[1])] 5143 Plot.set_xlim3d(XYZlim) 5144 Plot.set_ylim3d(XYZlim) 5145 Plot.set_zlim3d(XYZlim) 5146 Plot.set_aspect('equal') 5147 Plot.set_xlabel(labelX,fontsize=14) 5148 Plot.set_ylabel(labelY,fontsize=14) 5149 Plot.set_zlabel(labelZ,fontsize=14) 5150 Plot.set_title(Title) 5151 Page.canvas.draw() 5152 5153 ################################################################################ 5119 5154 ##### Plot3dXYZ 5120 5155 ################################################################################ 5121 5156 5122 def Plot3dXYZ(G2frame,nX,nY,Zdat,labelX= 'X',labelY='Y',labelZ='Z',newPlot=False,Title='',Centro=False):5157 def Plot3dXYZ(G2frame,nX,nY,Zdat,labelX=r'X',labelY=r'Y',labelZ=r'Z',newPlot=False,Title='',Centro=False): 5123 5158 5124 5159 def OnMotion(event): … … 5154 5189 xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T 5155 5190 XYZlim = [min(xyzlim[0]),max(xyzlim[1])] 5156 Plot.contour(X,Y,Z,10,zdir='x',offset=XYZlim[0])5157 Plot.contour(X,Y,Z,10,zdir='y',offset=XYZlim[1])5158 Plot.contour(X,Y,Z,10,zdir='z',offset=XYZlim[0])5191 # Plot.contour(X,Y,Z,10,zdir='x',offset=XYZlim[0]) 5192 # Plot.contour(X,Y,Z,10,zdir='y',offset=XYZlim[1]) 5193 # Plot.contour(X,Y,Z,10,zdir='z',offset=XYZlim[0]) 5159 5194 Plot.set_xlim3d(XYZlim) 5160 5195 Plot.set_ylim3d(XYZlim) … … 5171 5206 5172 5207 ################################################################################ 5173 ##### Plot Hist5208 ##### PlotAAProb 5174 5209 ################################################################################ 5175 5210 def PlotAAProb(G2frame,resNames,Probs1,Probs2,Title='',thresh=None,pickHandler=None): … … 5277 5312 Page.canvas.draw() 5278 5313 5314 ################################################################################ 5315 ##### PlotBarGraph 5316 ################################################################################ 5317 5318 def PlotBarGraph(G2frame,Xarray,Xname='',Title='',PlotName=None): 5319 'Needs a description' 5320 5321 def OnPageChanged(event): 5322 PlotText = G2frame.G2plotNB.nb.GetPageText(G2frame.G2plotNB.nb.GetSelection()) 5323 if PlotText == PlotName: 5324 PlotBarGraph(G2frame,Xarray,Xname,Title,PlotText) 5325 5326 def OnMotion(event): 5327 xpos = event.xdata 5328 if xpos: #avoid out of frame mouse position 5329 ypos = event.ydata 5330 SetCursor(Page) 5331 try: 5332 G2frame.G2plotNB.status.SetStatusText('X =%9.3f Number =%9.3g'%(xpos,ypos),1) 5333 except TypeError: 5334 G2frame.G2plotNB.status.SetStatusText('Select %s first'%PlotName,1) 5335 5336 if PlotName is None or not len(Xarray): 5337 return 5338 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(PlotName,'mpl') 5339 if new: 5340 G2frame.G2plotNB.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,OnPageChanged) 5341 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 5342 Page.Choice = None 5343 nBins= max(10,len(Xarray)//25) 5344 Bins,Dbins = np.histogram(Xarray,nBins) 5345 wid = Dbins[1]-Dbins[0] 5346 Plot.set_title(Title) 5347 Plot.set_xlabel(Xname,fontsize=14) 5348 Plot.set_ylabel(r'$Number$',fontsize=14) 5349 Plot.bar(Dbins[:-1],Bins,width=wid,align='edge',facecolor='red',edgecolor='black') 5350 Page.canvas.draw() 5351 5279 5352 ################################################################################ 5280 5353 ##### PlotSASDSizeDist
Note: See TracChangeset
for help on using the changeset viewer.