@@ -2786,15 +2786,52 @@ def OnCompPlots(event):
2786
2786
Title=r'%s Tetrahedral tilt vectors'%Oatoms,PlotName='Tet %s tilts for %s'%(bName,pName))
2787
2787
print(' %s-%s bond distance: %.3f(%d)'%(Oatoms,Tatoms,Bmean,Bstd*1000))
2788
2788
print(' %s tilt angle: %.2f(%d)'%(Oatoms,Tmean,Tstd*100))
2789
-
2790
-
2789
+
2790
+ def OnSaveDist(event):
2791
+ pName = generalData['Name']
2792
+ fName = os.path.abspath(os.path.splitext(G2frame.GSASprojectfile)[0]+'_TOdist.csv')
2793
+ fp = open(fName,'w')
2794
+ fp.write('Phase name: %s\n'%pName)
2795
+ Oatoms = generalData['Compare']['Oatoms']
2796
+ Tatoms = generalData['Compare']['Tatoms']
2797
+ bName = '%s-%s'%(Oatoms,Tatoms)
2798
+ Bonds = generalData['Compare']['Bonds'][bName]
2799
+ Vects = generalData['Compare']['Vects'][bName]
2800
+ dVects = generalData['Compare']['dVects'][bName]
2801
+ if len(Bonds['Obonds']):
2802
+ fp.write('%s-%s Octahedral bond lengths'%(Oatoms,Tatoms))
2803
+ for ib,bond in enumerate(Bonds['Obonds']):
2804
+ fp.write('%7.4f,'%bond)
2805
+ if not (ib+1)%10: fp.write('\n')
2806
+
2807
+ if len(Bonds['Tbonds']):
2808
+ fp.write('%s-%s Tetrahedral bond lengths\n'%(Oatoms,Tatoms))
2809
+ for ib,bond in enumerate(Bonds['Tbonds']):
2810
+ fp.write('%7.4f,'%bond)
2811
+ if not (ib+1)%10: fp.write('\n')
2812
+
2813
+ fp.close()
2814
+ print(' %s written'%fName)
2815
+
2791
2816
Oatoms = generalData['Compare']['Oatoms']
2792
2817
Tatoms = generalData['Compare']['Tatoms']
2793
2818
bName = '%s-%s'%(Oatoms,Tatoms)
2794
2819
atTypes = generalData['AtomTypes']
2795
2820
compSizer = wx.BoxSizer(wx.VERTICAL)
2796
- compSizer.Add(wx.StaticText(General,label=' Compare polyhedra to ideal octahedra/tetrahedra:'),0)
2821
+ topSizer = wx.BoxSizer(wx.HORIZONTAL)
2822
+ topSizer.Add(wx.StaticText(General,label=' Compare polyhedra to ideal octahedra/tetrahedra:'),0,WACV)
2823
+ try:
2824
+ if len(generalData['Compare']['Bonds'][bName]['Obonds']) or len(generalData['Compare']['Bonds'][bName]['Tbonds']):
2825
+ plotBtn = wx.Button(General,label='Show plots?')
2826
+ plotBtn.Bind(wx.EVT_BUTTON,OnCompPlots)
2827
+ topSizer.Add(plotBtn,0,WACV)
2828
+ saveBtn = wx.Button(General,label='Save distributions?')
2829
+ saveBtn.Bind(wx.EVT_BUTTON,OnSaveDist)
2830
+ topSizer.Add(saveBtn,0,WACV)
2831
+ except KeyError:
2832
+ pass
2797
2833
2834
+ compSizer.Add(topSizer)
2798
2835
atmselSizer = wx.BoxSizer(wx.HORIZONTAL)
2799
2836
atmselSizer.Add(wx.StaticText(General,label=' Select origin atom type: '),0,WACV)
2800
2837
oatmsel = wx.ComboBox(General,choices=atTypes,style=wx.CB_READONLY|wx.CB_DROPDOWN)
@@ -2808,16 +2845,9 @@ def OnCompPlots(event):
2808
2845
tatmsel.Bind(wx.EVT_COMBOBOX,OnTatmOsel)
2809
2846
atmselSizer.Add(tatmsel,0,WACV)
2810
2847
2811
- atmselSizer.Add(wx.StaticText(General,label=' Sampling fraction:: '),0,WACV)
2848
+ atmselSizer.Add(wx.StaticText(General,label=' Sampling fraction: '),0,WACV)
2812
2849
atmselSizer.Add(G2G.ValidatedTxtCtrl(General,generalData['Compare'],'Sampling',nDig=(8,3),xmin=0.0,xmax=1.0,),0,WACV)
2813
2850
2814
- try:
2815
- if len(generalData['Compare']['Bonds'][bName]['Obonds']) or len(generalData['Compare']['Bonds'][bName]['Tbonds']):
2816
- plotBtn = wx.Button(General,label='Show plots?')
2817
- plotBtn.Bind(wx.EVT_BUTTON,OnCompPlots)
2818
- atmselSizer.Add(plotBtn)
2819
- except KeyError:
2820
- pass
2821
2851
compSizer.Add(atmselSizer,0)
2822
2852
return compSizer
2823
2853
@@ -5542,22 +5572,26 @@ def OnDistAngle(event,fp=None,hist=False):
5542
5572
DisAglData['covData'] = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.root, 'Covariance'))
5543
5573
try:
5544
5574
if hist:
5575
+ Bonds = DisAglData['Bonds'] = DisAglData.get('Bonds',{})
5576
+ Angles = DisAglData['Angles'] = DisAglData.get('Angles',{})
5545
5577
pgbar = wx.ProgressDialog('Distance Angle calculation','Atoms done=',len(Oxyz)+1,
5546
5578
style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE)
5547
5579
AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(DisAglCtls,DisAglData,pgbar)
5548
5580
pgbar.Destroy()
5549
- Bonds = []
5581
+ bonds = []
5550
5582
for dists in DistArray:
5551
- Bonds += [item[3] for item in DistArray[dists]]
5552
- G2plt.PlotBarGraph(G2frame,Bonds ,Xname=r'$\mathsf{Bonds,\AA}$',
5583
+ bonds += [item[3] for item in DistArray[dists]]
5584
+ G2plt.PlotBarGraph(G2frame,bonds ,Xname=r'$\mathsf{Bonds,\AA}$',
5553
5585
Title='Bond distances for %s'%Atypes,PlotName='%s Bonds'%Atypes)
5554
- print('Total number of bonds to %s is %d'%(Atypes,len(Bonds)))
5555
- Angles = []
5556
- for angles in AngArray:
5557
- Angles += [item[2][0] for item in AngArray[angles]]
5558
- G2plt.PlotBarGraph(G2frame,Angles,Xname=r'$\mathsf{Angles,{^o}}$',
5586
+ print('Total number of bonds to %s is %d'%(Atypes,len(bonds)))
5587
+ Bonds[Atypes] = bonds
5588
+ angles = []
5589
+ for Item in AngArray:
5590
+ angles += [item[2][0] for item in AngArray[Item]]
5591
+ G2plt.PlotBarGraph(G2frame,angles,Xname=r'$\mathsf{Angles,{^o}}$',
5559
5592
Title='Bond angles about %s'%Atypes,PlotName='%s Angles'%Atypes)
5560
- print('Total number of angles about %s is %d'%(Atypes,len(Angles)))
5593
+ print('Total number of angles about %s is %d'%(Atypes,len(angles)))
5594
+ Angles[Atypes] = angles
5561
5595
5562
5596
elif fp:
5563
5597
#from importlib import reload
0 commit comments