Skip to content

Commit 4f9ca85

Browse files
committed
revise spinRB GUI to include options for shading shells in plot & plot colors for spinning RB
1 parent a741546 commit 4f9ca85

File tree

3 files changed

+46
-14
lines changed

3 files changed

+46
-14
lines changed

GSASII/GSASIIphsGUI.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13504,9 +13504,9 @@ def OnDelShell(event):
1350413504
if not RBObj['nSH'][iSh]:
1350513505
shSizer.Add(wx.StaticText(RigidBodies,
1350613506
label=' Select harmonic order or try different equivalent position'))
13507-
elif len(RBObj['SHC'][iSh]) > 12:
13507+
elif len(RBObj['SHC'][iSh]) > 24:
1350813508
shSizer.Add(wx.StaticText(RigidBodies,
13509-
label=' WARNING: More than 12 terms found; use lower harmonic order'))
13509+
label=' WARNING: More than 24 terms found; use lower harmonic order'))
1351013510
else:
1351113511
shcSizer = wx.FlexGridSizer(0,9,5,5)
1351213512
for item in RBObj['SHC'][iSh]:
@@ -13526,6 +13526,14 @@ def OnHideSh(event):
1352613526
iSh = Indx[Obj.GetId()]
1352713527
RBObj['hide'][iSh] = not RBObj['hide'][iSh]
1352813528
G2plt.PlotStructure(G2frame,data)
13529+
13530+
def OnAtColor(event):
13531+
RBObj['useAtColor'] = not RBObj['useAtColor']
13532+
G2plt.PlotStructure(G2frame,data)
13533+
13534+
def OnFadeShell(event):
13535+
RBObj['fadeSh'] = not RBObj['fadeSh']
13536+
G2plt.PlotStructure(G2frame,data)
1352913537

1353013538
RBObj['hide'] = RBObj.get('hide',[False for i in range(len(RBObj['atType']))])
1353113539
rbId = RBObj['RBId'][0]
@@ -13552,7 +13560,7 @@ def OnHideSh(event):
1355213560
hidesh.Bind(wx.EVT_CHECKBOX,OnHideSh)
1355313561
Indx[hidesh.GetId()] = 0
1355413562
topLine.Add(hidesh,0,WACV)
13555-
sprbSizer.Add(topLine)
13563+
sprbSizer.Add(wx.StaticText(RigidBodies,label='Spinning RB orientation parameters for %s:'%RBObj['RBname'][0]))
1355613564
sprbSizer.Add(LocationSizer(RBObj,'Spin'))
1355713565
choices = [' x ',' y ',' z ','x+y','x+y+z']
1355813566
RBObj['symAxis'] = RBObj.get('symAxis',[0,0,1]) #set default as 'z'
@@ -13562,6 +13570,20 @@ def OnHideSh(event):
1356213570
symRadioSet.Bind(wx.EVT_RADIOBOX, OnSymRadioSet)
1356313571
Indx[symRadioSet.GetId()] = rbId
1356413572
sprbSizer.Add(symRadioSet)
13573+
plotLine = wx.BoxSizer(wx.HORIZONTAL)
13574+
RBObj['useAtColor'] = RBObj.get('useAtColor',True)
13575+
atColor = wx.CheckBox(RigidBodies,label='Use atom color?')
13576+
atColor.SetValue(RBObj['useAtColor'])
13577+
atColor.Bind(wx.EVT_CHECKBOX,OnAtColor)
13578+
plotLine.Add(atColor,0,WACV)
13579+
RBObj['fadeSh'] = RBObj.get('fadeSh',True)
13580+
fadeShell = wx.CheckBox(RigidBodies,label='Fade shells?')
13581+
fadeShell.SetValue(RBObj['fadeSh'])
13582+
fadeShell.Bind(wx.EVT_CHECKBOX,OnFadeShell)
13583+
plotLine.Add(fadeShell,0,WACV)
13584+
sprbSizer.Add(plotLine)
13585+
G2G.HorizontalLine(sprbSizer,RigidBodies)
13586+
sprbSizer.Add(topLine)
1356513587
sprbSizer.Add(SHsizer())
1356613588
return sprbSizer
1356713589

@@ -13901,7 +13923,7 @@ def RepaintRBInfo(rbType,rbIndx,Scroll=0):
1390113923
rbObj = data['RBModels']['Residue'][resId]
1390213924
data['Drawing']['viewPoint'][0] = rbObj['Orig'][0]
1390313925
data['Drawing']['Quaternion'] = rbObj['Orient'][0]
13904-
resSelect = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,120))
13926+
resSelect = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,80))
1390513927
if resId:
1390613928
resSelect.SetSelection(resId)
1390713929
OnResSelect(None)
@@ -13930,7 +13952,7 @@ def RepaintRBInfo(rbType,rbIndx,Scroll=0):
1393013952
rbObj = data['RBModels']['Vector'][vecId]
1393113953
data['Drawing']['viewPoint'][0] = rbObj['Orig'][0]
1393213954
data['Drawing']['Quaternion'] = rbObj['Orient'][0]
13933-
vecSelect = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,120))
13955+
vecSelect = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,80))
1393413956
if vecId is not None:
1393513957
vecSelect.SetSelection(vecId)
1393613958
OnVecSelect(None)
@@ -13955,7 +13977,7 @@ def RepaintRBInfo(rbType,rbIndx,Scroll=0):
1395513977
rbObj = data['RBModels']['Spin'][spnId]
1395613978
data['Drawing']['viewPoint'][0] = data['Atoms'][AtLookUp[RBObj['Ids'][0]]][cx:cx+3]
1395713979
data['Drawing']['Quaternion'] = rbObj['Orient'][0]
13958-
spnSelect = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,120))
13980+
spnSelect = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,80))
1395913981
if spnId != -1:
1396013982
spnSelect.SetSelection(spnId)
1396113983
OnSpnSelect(None)

GSASII/GSASIIplot.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6707,10 +6707,15 @@ def RenderViewPlane(plane,Z,width,height):
67076707
GL.glDisable(GL.GL_BLEND)
67086708
GL.glShadeModel(GL.GL_SMOOTH)
67096709

6710-
def RenderTextureSphere(x,y,z,radius,color,shape=[20,10],Fade=None):
6711-
SpFade = np.zeros(list(Fade.shape)+[4,],dtype=np.dtype('B'))
6712-
SpFade[:,:,:3] = Fade[:,:,nxs]*list(color)
6713-
SpFade[:,:,3] = 60
6710+
def RenderTextureSphere(x,y,z,radius,ATcolor=None,shape=[20,10],Texture=None,ifFade=True):
6711+
SpFade = np.zeros(list(Texture.shape)+[4,],dtype=np.dtype('B'))
6712+
if ATcolor is None:
6713+
acolor = GetColorMap('RdYlGn')
6714+
SpFade = acolor(Texture)*255
6715+
else:
6716+
SpFade[:,:,:3] = Texture[:,:,nxs]*list(ATcolor)
6717+
if ifFade:
6718+
SpFade[:,:,3] = 60
67146719
spID = GL.glGenTextures(1)
67156720
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
67166721
GL.glEnable(GL.GL_BLEND)
@@ -7220,8 +7225,10 @@ def Draw(caller='',Fade=[],NPkey=False):
72207225
SytSym = G2spc.SytSym(atom[cx:cx+3],SGData)[0]
72217226
radius = SpnData.get('Radius',[[1.0,False],]) #patch for missing Radius
72227227
atColor = SpnData['atColor']
7228+
ifFade = SpnData.get('fadeSh',True)
7229+
useAtColor = SpnData.get('useAtColor',True)
72237230
symAxis = np.array(SpnData.get('symAxis',[0,0,1]))
7224-
Npsi,Ngam = 60,30 #seems acceptable - don't use smaller!
7231+
Npsi,Ngam = 360,180
72257232
QA = G2mth.invQ(SpnData['Orient'][0]) #rotate about chosen axis
72267233
QB = G2mth.make2Quat(symAxis,np.array([0,0,1.]))[0] #position obj polar axis
72277234
QP = G2mth.AVdeg2Q(360./Npsi,np.array([0,0,1.])) #this shifts by 1 azimuth pixel
@@ -7236,10 +7243,13 @@ def Draw(caller='',Fade=[],NPkey=False):
72367243
if not SpnData['hide'][ish]:
72377244
if nSH > 0:
72387245
SHC = SpnData['SHC'][ish]
7246+
atcolor = None
7247+
if useAtColor:
7248+
atcolor = atColor[ish]
72397249
P = G2lat.SHarmcal(SytSym,SHC,PSIp,GAMp).reshape((Npsi,Ngam))
72407250
if np.min(P) < np.max(P):
72417251
P = (P-np.min(P))/(np.max(P)-np.min(P))
7242-
RenderTextureSphere(x,y,z,radius[ish][0],atColor[ish],shape=[Npsi,Ngam],Fade=P.T)
7252+
RenderTextureSphere(x,y,z,radius[ish][0],atcolor,shape=[Npsi,Ngam],Texture=P.T,ifFade=ifFade)
72437253
else:
72447254
RenderSphere(x,y,z,radius[ish][0],atColor[ish],True,shape=[60,30])
72457255
else:
@@ -7431,7 +7441,7 @@ def Draw(caller='',Fade=[],NPkey=False):
74317441
if drawingData.get('showSlice') in [1,]:
74327442
contourSet = ax0.contour(Z,colors='k',linewidths=1)
74337443
if drawingData.get('showSlice') in [2,3]:
7434-
acolor = GetColorMap(drawingData.get('contourColor','Paired'))
7444+
acolor = GetColorMap(drawingData.get('contourColor','GSPaired'))
74357445
ax0.imshow(ZU,aspect='equal',cmap=acolor,alpha=0.7,interpolation='bilinear')
74367446
if drawingData.get('showSlice') in [3,]:
74377447
contourSet = ax0.contour(ZU,colors='k',linewidths=1)

GSASII/GSASIIstrMath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def MakeSpHarmFF(HKL,Amat,Bmat,SHCdict,Tdata,hType,FFtables,ORBtables,BLtables,F
447447

448448
def MakePolar(Orient,QB):
449449
QA = G2mth.invQ(Orient) #rotates about chosen axis
450-
Q = G2mth.prodQQ(QB,QA) #might be switched? QB,QA is order for plotting
450+
Q = G2mth.prodQQ(QA,QB) #might be switched? QB,QA is order for plotting
451451
M = np.inner(G2mth.Q2Mat(Q),Bmat)
452452
return G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),M)[1:]
453453

0 commit comments

Comments
 (0)