Skip to content

Commit 4008519

Browse files
committed
comment out unused OnPlot3DHKL in G2dataGUI - it is actually in G2pwdGUI
introduce new plotting of "experiment and tilt for microED data in 3DHKL plots.
1 parent e8b13cc commit 4008519

3 files changed

Lines changed: 80 additions & 38 deletions

File tree

GSASII/GSASIIdataGUI.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5570,15 +5570,15 @@ def OnRefine(self,event):
55705570
txt = G2obj.fmtVarDescr(i)
55715571
tbl.append((i,Rvals['parmDictBeforeFit'][i],Rvals['parmDictAfterFit'][i],txt))
55725572
lbl = f'Refinement results, Rw={Rw:.3f}'
5573-
#ans = G2G.G2AfterFit(self,text,lbl,tbl) # this replaces the next 8 lines
5574-
text += '\nLoad new result?'
5575-
dlg2 = wx.MessageDialog(self,text,lbl,wx.OK|wx.CANCEL)
5576-
dlg2.CenterOnParent()
5577-
ans = False
5578-
try:
5579-
ans = dlg2.ShowModal()
5580-
finally:
5581-
dlg2.Destroy()
5573+
ans = G2G.G2AfterFit(self,text,lbl,tbl) # this replaces the next 8 lines
5574+
# text += '\nLoad new result?'
5575+
# dlg2 = wx.MessageDialog(self,text,lbl,wx.OK|wx.CANCEL)
5576+
# dlg2.CenterOnParent()
5577+
# ans = False
5578+
# try:
5579+
# ans = dlg2.ShowModal()
5580+
# finally:
5581+
# dlg2.Destroy()
55825582
# replace above with G2G.G2AfterFit line
55835583
if ans == wx.ID_OK: # refinement has been accepted save, log & display
55845584
self.reloadFromGPX(rtext,Rvals)
@@ -8178,18 +8178,19 @@ def OnPlot1DHKL(event):
81788178
refList = data[1]['RefList']
81798179
G2plt.Plot1DSngl(G2frame,newPlot=True,hklRef=refList,Super=Super,Title=phaseName)
81808180

8181-
def OnPlot3DHKL(event):
8182-
'''Plots in 3D reciprocal space with green dots proportional to F^2, etc. from single histogram'''
8183-
refList = data[1]['RefList']
8184-
FoMax = np.max(refList.T[8+Super])
8185-
Hmin = np.array([int(np.min(refList.T[0])),int(np.min(refList.T[1])),int(np.min(refList.T[2]))])
8186-
Hmax = np.array([int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))])
8187-
Vpoint = np.array([int(np.mean(refList.T[0])),int(np.mean(refList.T[1])),int(np.mean(refList.T[2]))])
8188-
controls = {'Type' : 'Fosq','Iscale' : False,'HKLmax' : Hmax,'HKLmin' : Hmin,'Zone':False,'viewKey':'L',
8189-
'FoMax' : FoMax,'Scale' : 1.0,'Drawing':{'viewPoint':[Vpoint,[]],'default':Vpoint[:],
8190-
'backColor':[0,0,0],'depthFog':False,'Zclip':10.0,'cameraPos':10.,'Zstep':0.05,'viewUp':[0,1,0],
8191-
'Scale':1.0,'oldxy':[],'viewDir':[0,0,1]},'Super':Super,'SuperVec':SuperVec}
8192-
G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName)
8181+
# def OnPlot3DHKL(event):
8182+
# '''Plots in 3D reciprocal space with green dots proportional to F^2, etc. from single histogram'''
8183+
# refList = data[1]['RefList']
8184+
# FoMax = np.max(refList.T[8+Super])
8185+
# Hmin = np.array([int(np.min(refList.T[0])),int(np.min(refList.T[1])),int(np.min(refList.T[2]))])
8186+
# Hmax = np.array([int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))])
8187+
# Vpoint = np.array([int(np.mean(refList.T[0])),int(np.mean(refList.T[1])),int(np.mean(refList.T[2]))])
8188+
# controls = {'Type' : 'Fosq','Iscale' : False,'HKLmax' : Hmax,'HKLmin' : Hmin,'Zone':False,'viewKey':'L',
8189+
# 'FoMax' : FoMax,'Scale' : 1.0,'Drawing':{'viewPoint':[Vpoint,[]],'default':Vpoint[:],
8190+
# 'microED':{'Nexp':[False,0],'Ztilt':[False,0]},
8191+
# 'backColor':[0,0,0],'depthFog':False,'Zclip':10.0,'cameraPos':10.,'Zstep':0.05,'viewUp':[0,1,0],
8192+
# 'Scale':1.0,'oldxy':[],'viewDir':[0,0,1]},'Super':Super,'SuperVec':SuperVec}
8193+
# G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName)
81938194

81948195
def OnPlotAll3DHKL(event):
81958196
'''Plots in 3D reciprocal space with green dots proportional to F^2, etc. from all SHKL histograms'''
@@ -8478,7 +8479,7 @@ def OnEditMag(**args):
84788479
G2frame.Bind(wx.EVT_MENU, OnErrorAnalysis, id=G2G.wxID_PWDANALYSIS)
84798480
G2frame.Bind(wx.EVT_MENU, OnMergeHKL, id=G2G.wxID_MERGEHKL)
84808481
G2frame.Bind(wx.EVT_MENU, OnPlot1DHKL, id=G2G.wxID_1DHKLSTICKPLOT)
8481-
G2frame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=G2G.wxID_PWD3DHKLPLOT)
8482+
# G2frame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=G2G.wxID_PWD3DHKLPLOT)
84828483
G2frame.Bind(wx.EVT_MENU, OnPlotAll3DHKL, id=G2G.wxID_3DALLHKLPLOT)
84838484
# G2frame.Bind(wx.EVT_MENU, OnPlotFoVsFc, id=G2G.wxID_FOVSFCPLOT)
84848485
G2frame.Bind(wx.EVT_MENU, OnFixFsqFsq, id=G2G.wxID_FIXFSQSQDATA)
@@ -8679,6 +8680,7 @@ def OnEditMag(**args):
86798680
controls = {'Type' : 'Fo','ifFc' : True,'dType':data[1]['Type'],
86808681
'HKLmax' : [int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))],
86818682
'HKLmin' : [int(np.min(refList.T[0])),int(np.min(refList.T[1])),int(np.min(refList.T[2]))],
8683+
'microED':{'Nexp':[False,0],'Ztilt':[False,0]},
86828684
'FoMax' : FoMax,'Zone' : '001','Layer' : 0,'Scale' : 1.0,'Super':Super,'SuperVec':SuperVec}
86838685
G2plt.PlotSngl(G2frame,newPlot=True,Data=controls,hklRef=refList)
86848686
G2frame.dataWindow.SetDataSize()

GSASII/GSASIIplot.py

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,27 +1448,49 @@ def OnKey(event): #on key UP!!
14481448
elif key in 'R':
14491449
Data['Shell'][1] = not Data['Shell'][1]
14501450
elif key in ['+','=']:
1451-
if Data['Shell'][1]:
1452-
Data['Shell'][0] += 0.1
1451+
if 'microED' in Data and Data['microED']['Ztilt'][0]:
1452+
Data['microED']['Ztilt'][1] += 1
14531453
else:
1454-
Data['Scale'] *= 1.25
1454+
if Data['Shell'][1]:
1455+
Data['Shell'][0] += 0.1
1456+
else:
1457+
Data['Scale'] *= 1.25
14551458
elif key == '-':
1456-
if Data['Shell'][1]:
1457-
Data['Shell'][0] = max(Data['Shell'][0]-0.1,0.0)
1459+
if 'microED' in Data and Data['microED']['Ztilt'][0]:
1460+
Data['microED']['Ztilt'][1] -= 1
14581461
else:
1459-
Data['Scale'] /= 1.25
1462+
if Data['Shell'][1]:
1463+
Data['Shell'][0] = max(Data['Shell'][0]-0.1,0.0)
1464+
else:
1465+
Data['Scale'] /= 1.25
14601466
elif key == 'P':
1461-
vec = viewChoice[Data['viewKey']][0]
1462-
drawingData['viewPoint'][0] += vec
1467+
if 'microED' in Data and Data['microED']['Nexp'][0]:
1468+
Data['microED']['Nexp'][1] += 1
1469+
Data['microED']['Nexp'][1] = min(Data['microED']['Nexp'][1],np.max(hklRef.T[12]))
1470+
Data['Scale'] = 1.0
1471+
else:
1472+
vec = viewChoice[Data['viewKey']][0]
1473+
drawingData['viewPoint'][0] += vec
14631474
elif key == 'M':
1464-
vec = viewChoice[Data['viewKey']][0]
1465-
drawingData['viewPoint'][0] -= vec
1475+
if 'microED' in Data and Data['microED']['Nexp'][0]:
1476+
Data['microED']['Nexp'][1] -= 1
1477+
Data['microED']['Nexp'][1] = max(Data['microED']['Nexp'][1],0)
1478+
Data['Scale'] = 1.0
1479+
else:
1480+
vec = viewChoice[Data['viewKey']][0]
1481+
drawingData['viewPoint'][0] -= vec
14661482
elif key == '0':
14671483
drawingData['viewPoint'][0] = np.array([0,0,0])
14681484
Data['Scale'] = 1.0
14691485
Data['Shell'][0] = 0.0
14701486
elif key == 'I':
14711487
Data['Iscale'] = not Data['Iscale']
1488+
elif key == 'E':
1489+
if 'microED' in Data:
1490+
Data['microED']['Nexp'][0] = not Data['microED']['Nexp'][0]
1491+
elif key == 'T':
1492+
if 'microED' in Data:
1493+
Data['microED']['Ztilt'][0] = not Data['microED']['Ztilt'][0]
14721494
elif key in Choice:
14731495
Data['Type'] = Choice[key]
14741496
Draw('key')
@@ -1513,6 +1535,12 @@ def FillHKLRC():
15131535
C = []
15141536
HKL = []
15151537
for i,refl in enumerate(hklRef):
1538+
if Data.get('dType','') == 'SEC' and hklRef.shape[1] > 12:
1539+
Nexp = Data['microED']['Nexp']
1540+
Ztilt = Data['microED']['Ztilt']
1541+
if Nexp[0]:
1542+
if refl[12] != Nexp[1]:
1543+
continue
15161544
if Data['Shell'][1]:
15171545
if not (Data['Shell'][0] <= 0.5/refl[4+Super] <= Data['Shell'][0]+.1):
15181546
continue
@@ -1790,13 +1818,20 @@ def Draw(caller=''):
17901818

17911819
HKL,RC,RF,RF2 = FillHKLRC()
17921820
if Data['Zone']:
1821+
vX,vY,vZ = list(drawingData['viewPoint'][0])
17931822
G2frame.G2plotNB.status.SetStatusText \
1794-
('Plot type = %s for %s; N = %d, RF = %6.2f%%, RF%s = %6.2f%% layer %s'% \
1795-
(Data['Type'],Name,len(HKL),RF,super2,RF2,str(list(drawingData['viewPoint'][0]))),1)
1823+
('Plot type = %s for %s; N = %d, RF = %6.2f%%, RF%s = %6.2f%% layer %d %d %d'% \
1824+
(Data['Type'],Name,len(HKL),RF,super2,RF2,vX,vY,vZ),1)
17961825
elif Data['Shell'][1]:
17971826
G2frame.G2plotNB.status.SetStatusText \
17981827
('Plot type = %s for %s; N = %d, RF = %6.2f%%, RF%s = %6.2f%% shell %.1f'% \
17991828
(Data['Type'],Name,len(HKL),RF,super2,RF2,Data['Shell'][0]),1)
1829+
elif 'microED' in Data and Data['microED']['Nexp'][0]:
1830+
Nexp = Data['microED']['Nexp'][1]
1831+
Ztilt = Data['microED']['Ztilt'][1]
1832+
G2frame.G2plotNB.status.SetStatusText \
1833+
('Plot type = %s for %s; N = %d, RF = %6.2f%%, RF%s = %6.2f%% Nexp %d Ztilt %d'% \
1834+
(Data['Type'],Name,len(HKL),RF,super2,RF2,Nexp,Ztilt),1)
18001835
else:
18011836
G2frame.G2plotNB.status.SetStatusText \
18021837
('Plot type = %s for %s; N = %d, RF = %6.2f%%, RF%s = %6.2f%%'% \
@@ -1848,6 +1883,8 @@ def Draw(caller=''):
18481883
choice = [' save as/key:','jpeg','tiff','bmp','h: view down h','k: view down k','l: view down l','r: plot radial shell',
18491884
'z: zero zone toggle','p: increment layer','m: decrement layer','c: reset to default','o: set view point = 0,0,0','b: toggle box ','+: increase scale','-: decrease scale',
18501885
'f: Fobs','s: Fobs**2','u: unit','d: Fo-Fc','w: DF/sig','i: toggle intensity scaling']
1886+
if Data.get('dType','') == 'SEC' and hklRef.shape[1] > 12:
1887+
choice += ['e: toggle Nexp','t: toggle Ztilt']
18511888
cb = wx.ComboBox(G2frame.G2plotNB.status,style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=choice,
18521889
size=(G2frame.G2plotNB.status.firstLen,-1))
18531890
cb.Bind(wx.EVT_COMBOBOX, OnKeyBox)

GSASII/GSASIIpwdGUI.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,7 +2926,7 @@ def OnLamPick(event):
29262926
data['Type'][0] = 'SXC'
29272927
insVal['Type'] = 'SXC'
29282928
elif 'micro' in lamType:
2929-
insVal['Lam'] = 0.025079 # @200keV
2929+
insVal['Lam'] = insVal.get('Lam',0.025079) # @200keV
29302930
data['Type'][0] = 'SEC' #change to electron diffraction
29312931
insVal['Type'] = 'SEC' # in 3 places!
29322932
Pattern = G2frame.GPXtree.GetItemPyData(G2frame.PatternId)
@@ -7304,6 +7304,7 @@ def OnPlot3DHKL(event):
73047304
Hmax = np.array([int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))])
73057305
Vpoint = np.array([int(np.mean(refList.T[0])),int(np.mean(refList.T[1])),int(np.mean(refList.T[2]))])
73067306
controls = {'Type':'Fosq','Iscale':False,'HKLmax':Hmax,'HKLmin':Hmin,'Zone':False,'viewKey':'L',
7307+
'microED':{'Nexp':[False,0],'Ztilt':[False,0]},'dType':data[1]['Type'],
73077308
'FoMax' : FoMax,'Scale' : 1.0,'Drawing':{'viewPoint':[Vpoint,[]],'default':Vpoint[:],
73087309
'backColor':[0,0,0],'depthFog':False,'Zclip':10.0,'cameraPos':10.,'Zstep':0.05,'viewUp':[0,1,0],
73097310
'Scale':1.0,'oldxy':[],'viewDir':[0,0,1]},'Super':Super,'SuperVec':SuperVec}
@@ -7431,9 +7432,11 @@ def MakeReflectionTable(phaseName):
74317432
if 'T' in Inst['Type'][0]:
74327433
colLabels = ['H','K','L','flag','d','Fosq','sig','Fcsq','FoTsq','FcTsq','phase','ExtC','wave','tbar']
74337434
Types += 2*[wg.GRID_VALUE_FLOAT+':10,3',]
7434-
elif 'E' in Inst['Type'][0]:
7435-
colLabels = ['H','K','L','flag','d','Fosq','sig','Fcsq','FoTsq','FcTsq','phase','ExtC','Nexp','Zpos']
7436-
Types += [wg.GRID_VALUE_LONG,wg.GRID_VALUE_FLOAT+':10,3',]
7435+
elif 'E' in Inst['Type'][0]:
7436+
colLabels = ['H','K','L','flag','d','Fosq','sig','Fcsq','FoTsq','FcTsq','phase','ExtC']
7437+
if refs.shape[1] > 12:
7438+
colLabels += ['Nexp','Zpos']
7439+
Types += [wg.GRID_VALUE_LONG,wg.GRID_VALUE_FLOAT+':10,3',]
74377440
if Super:
74387441
colLabels.insert(3,'M')
74397442
else:

0 commit comments

Comments
 (0)