Changeset 4351
- Timestamp:
- Mar 9, 2020 10:34:48 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r4348 r4351 2553 2553 2554 2554 def OnCompPlots(event): 2555 Bonds = generalData['Compare']['Bonds'] 2556 Tilts = generalData['Compare']['Tilts'] 2557 Vects = generalData['Compare']['Vects'] 2555 pName = generalData['Name'] 2558 2556 Oatoms = generalData['Compare']['Oatoms'] 2559 2557 Tatoms = generalData['Compare']['Tatoms'] 2560 dVects = generalData['Compare']['dVects'] 2558 bName = '%s-%s'%(Oatoms,Tatoms) 2559 try: 2560 Bonds = generalData['Compare']['Bonds'][bName] 2561 except KeyError: 2562 print('need to do Compare first for %s polyhedra plots'%bName) 2563 return 2564 Tilts = generalData['Compare']['Tilts'][bName] 2565 Vects = generalData['Compare']['Vects'][bName] 2566 dVects = generalData['Compare']['dVects'][bName] 2561 2567 if len(Bonds['Obonds']): 2562 2568 print(' Octahedra:') … … 2565 2571 Bstd = np.std(Bonds['Obonds']) 2566 2572 title = '%s-%s Octahedral bond lengths'%(Oatoms,Tatoms) 2567 G2plt.PlotBarGraph(G2frame,Bonds['Obonds'],Xname=r'$Bond, \AA$',Title=title,PlotName='Oct-Bond') 2573 G2plt.PlotBarGraph(G2frame,Bonds['Obonds'],Xname=r'$Bond, \AA$',Title=title, 2574 PlotName='Oct %s Bond for %s'%(bName,pName)) 2568 2575 Tilts['Otilts'] = np.array(Tilts['Otilts']) 2569 2576 Tmean = np.mean(Tilts['Otilts']) 2570 2577 Tstd = np.std(Tilts['Otilts']) 2571 2578 G2plt.PlotBarGraph(G2frame,Tilts['Otilts'],Xname='Tilts, deg', 2572 Title='Octahedral %s tilts'%Oatoms,PlotName='Oct -Tilts')2579 Title='Octahedral %s tilts'%Oatoms,PlotName='Oct %s Tilts for %s'%(bName,pName)) 2573 2580 dVects['Ovec'] = np.reshape(np.array(dVects['Ovec']),(-1,3)) 2574 2581 for ix,aX in enumerate(['X','Y','Z']): 2575 2582 G2plt.PlotBarGraph(G2frame,dVects['Ovec'].T[ix],Xname=r'$%s%s, \AA$'%(GkDelta,aX), 2576 Title='%s Octahedral distortion'%Oatoms,PlotName='Oct %s -Delta'%aX)2583 Title='%s Octahedral distortion'%Oatoms,PlotName='Oct %s %s-Delta for %s'%(bName,aX,pName)) 2577 2584 Vects['Ovec'] = np.array(Vects['Ovec']) #3D plot of tilt vectors 2578 2585 X = Vects['Ovec'].T[0] … … 2580 2587 Z = Vects['Ovec'].T[2] 2581 2588 G2plt.PlotXYZvect(G2frame,X,Y,Z,r'X-axis',r'Y-axis',r'Z-axis', 2582 Title=r'%s Octahedral tilt vectors'%Oatoms,PlotName='Oct tilts')2589 Title=r'%s Octahedral tilt vectors'%Oatoms,PlotName='Oct %s tilts for %s'%(bName,pName)) 2583 2590 print(' %s-%s bond distance: %.3f(%d)'%(Oatoms,Tatoms,Bmean,Bstd*1000)) 2584 2591 print(' %s tilt angle: %.2f(%d)'%(Oatoms,Tmean,Tstd*100)) … … 2589 2596 Bmean = np.mean(Bonds['Tbonds']) 2590 2597 Bstd = np.std(Bonds['Tbonds']) 2591 title = '%s-%s Terahedral bond lengths'%(Oatoms,Tatoms) 2592 G2plt.PlotBarGraph(G2frame,Bonds['Tbonds'],Xname=r'$Bond, \AA$',Title=title,PlotName='Tet-Bond') 2598 title = '%s-%s Tetrahedral bond lengths'%(Oatoms,Tatoms) 2599 G2plt.PlotBarGraph(G2frame,Bonds['Tbonds'],Xname=r'$Bond, \AA$',Title=title, 2600 PlotName='Tet %s Bond for %s'%(bName,pName)) 2593 2601 Tilts['Ttilts'] = np.array(Tilts['Ttilts']) 2594 2602 Tmean = np.mean(Tilts['Ttilts']) 2595 2603 Tstd = np.std(Tilts['Ttilts']) 2596 2604 G2plt.PlotBarGraph(G2frame,Tilts['Ttilts'],Xname='Tilts, deg', 2597 Title='Tetrahedral %s tilts'%Oatoms,PlotName='Tet -Tilts')2605 Title='Tetrahedral %s tilts'%Oatoms,PlotName='Tet %s Tilts for %s'%(bName,pName)) 2598 2606 dVects['Tvec'] = np.reshape(np.array(dVects['Tvec']),(-1,3)) 2599 2607 for ix,aX in enumerate(['X','Y','Z']): 2600 2608 G2plt.PlotBarGraph(G2frame,dVects['Tvec'].T[ix],Xname=r'$%s%s, \AA$'%(GkDelta,aX), 2601 Title='%s Tetrahedral distortion'%Oatoms,PlotName='Tet %s -Delta'%aX)2609 Title='%s Tetrahedral distortion'%Oatoms,PlotName='Tet %s %s-Delta for %s'%(bName,aX,pName)) 2602 2610 Vects['Tvec'] = np.array(Vects['Tvec']) 2603 2611 X = Vects['Tvec'].T[0] … … 2605 2613 Z = Vects['Tvec'].T[2] 2606 2614 G2plt.PlotXYZvect(G2frame,X,Y,Z,r'X-axis',r'Y-axis',r'Z-axis', 2607 Title=r'%s Tetrahedral tilt vectors'%Oatoms,PlotName='Tet tilts')2615 Title=r'%s Tetrahedral tilt vectors'%Oatoms,PlotName='Tet %s tilts for %s'%(bName,pName)) 2608 2616 print(' %s-%s bond distance: %.3f(%d)'%(Oatoms,Tatoms,Bmean,Bstd*1000)) 2609 2617 print(' %s tilt angle: %.2f(%d)'%(Oatoms,Tmean,Tstd*100)) 2610 2618 2611 2619 2620 Oatoms = generalData['Compare']['Oatoms'] 2621 Tatoms = generalData['Compare']['Tatoms'] 2622 bName = '%s-%s'%(Oatoms,Tatoms) 2612 2623 atTypes = generalData['AtomTypes'] 2613 2624 compSizer = wx.BoxSizer(wx.VERTICAL) … … 2627 2638 atmselSizer.Add(tatmsel,0,WACV) 2628 2639 2629 if len(generalData['Compare']['Bonds']['Obonds']) or len(generalData['Compare']['Bonds']['Tbonds']): 2630 plotBtn = wx.Button(General,label='Show plots?') 2631 plotBtn.Bind(wx.EVT_BUTTON,OnCompPlots) 2632 atmselSizer.Add(plotBtn) 2640 try: 2641 if len(generalData['Compare']['Bonds'][bName]['Obonds']) or len(generalData['Compare']['Bonds'][bName]['Tbonds']): 2642 plotBtn = wx.Button(General,label='Show plots?') 2643 plotBtn.Bind(wx.EVT_BUTTON,OnCompPlots) 2644 atmselSizer.Add(plotBtn) 2645 except KeyError: 2646 pass 2633 2647 compSizer.Add(atmselSizer,0,WACV) 2634 2648 return compSizer … … 2809 2823 cx,ct,cs,cia = generalData['AtomPtrs'] 2810 2824 atNames = [atm[ct-1] for atm in data['Atoms']] 2811 if not generalData['Compare']['Oatoms'] :2825 if not generalData['Compare']['Oatoms'] or not generalData['Compare']['Tatoms']: 2812 2826 G2frame.ErrorDialog('Compare atom selection error','Select atoms for polygon comparison first') 2813 2827 return 2828 bName = '%s-%s'%(generalData['Compare']['Oatoms'],generalData['Compare']['Tatoms']) 2814 2829 DisAglCtls = generalData.get('DisAglCtls',{}) 2815 2830 dlg = G2G.DisAglDialog(G2frame,DisAglCtls,generalData) … … 2822 2837 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT) 2823 2838 Tilts = generalData['Compare']['Tilts'] 2824 Tilts.update({ 'Otilts':[],'Ttilts':[]})2839 Tilts.update({bName:{'Otilts':[],'Ttilts':[]}}) 2825 2840 Bonds = generalData['Compare']['Bonds'] 2826 Bonds.update({ 'Obonds':[],'Tbonds':[]})2841 Bonds.update({bName:{'Obonds':[],'Tbonds':[]}}) 2827 2842 Vects = generalData['Compare']['Vects'] 2828 Vects.update({ 'Ovec':[],'Tvec':[]})2843 Vects.update({bName:{'Ovec':[],'Tvec':[]}}) 2829 2844 dVects = generalData['Compare']['dVects'] 2830 dVects.update({ 'Ovec':[],'Tvec':[]})2845 dVects.update({bName:{'Ovec':[],'Tvec':[]}}) 2831 2846 Oatoms = generalData['Compare']['Oatoms'] 2832 2847 nOct = 0 … … 2838 2853 if len(results) == 4: 2839 2854 bond,std,meanDisp,stdDisp,A,V,dVec = G2mth.FindTetrahedron(results) 2840 Bonds[ 'Tbonds'].append(bond)2841 Tilts[ 'Ttilts'].append(A)2842 Vects[ 'Tvec'].append(V)2843 dVects[ 'Tvec'].append(dVec)2855 Bonds[bName]['Tbonds'].append(bond) 2856 Tilts[bName]['Ttilts'].append(A) 2857 Vects[bName]['Tvec'].append(V) 2858 dVects[bName]['Tvec'].append(dVec) 2844 2859 nTet += 1 2845 2860 elif len(results) == 6: 2846 2861 bond,std,meanDisp,stdDisp,A,V,dVec = G2mth.FindOctahedron(results) 2847 Bonds[ 'Obonds'].append(bond)2848 Tilts[ 'Otilts'].append(A)2849 Vects[ 'Ovec'].append(V)2850 dVects[ 'Ovec'].append(dVec)2862 Bonds[bName]['Obonds'].append(bond) 2863 Tilts[bName]['Otilts'].append(A) 2864 Vects[bName]['Ovec'].append(V) 2865 dVects[bName]['Ovec'].append(dVec) 2851 2866 nOct += 1 2852 2867 else:
Note: See TracChangeset
for help on using the changeset viewer.