Skip to content

Commit 2bf22ff

Browse files
committed
modify 3Dhkl plot for extended microED data - can show "experiments" and individual tilt slices.
The dFsq/sig plot now colored by magnitude of dFsq/sig from green - yellow - red. Fix issue in Dysnomia message
1 parent bded0d8 commit 2bf22ff

2 files changed

Lines changed: 50 additions & 31 deletions

File tree

GSASII/GSASIIphsGUI.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5880,13 +5880,14 @@ def OnRunDysnomia(event):
58805880
if is_exe(DYSNOMIA):
58815881
break
58825882
else:
5883+
newline = '\n\t'
58835884
print(f"File {binimage!r} not found."
5884-
f"\nThe following locations were checked:\n\t{'\n\t'.join(locations)}")
5885+
f"\nThe following locations were checked:\n\t{newline.join(locations)}")
58855886
msg = f'''Dysnomia is not installed. Please download it from
58865887
https://jp-minerals.org/dysnomia/en/ and install the
58875888
downloaded directory (which includes file {binimage!r})
58885889
at one of the following locations:
5889-
\t{'\n\t'.join(pathlist)}'''
5890+
\t{newline.join(pathlist)}'''
58905891
G2G.ShowWebPage("https://jp-minerals.org/dysnomia/en/",G2frame)
58915892
G2G.ShowScrolledInfo(G2frame,msg,header='Install Dysnomia',
58925893
width=350,height=150)

GSASII/GSASIIplot.py

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ def Plot3DSngl(G2frame,newPlot=False,Data=None,hklRef=None,Title=False):
13601360
'''3D Structure factor plotting package - displays reflections as spots proportional
13611361
to F, F**2, etc. as requested as 3D array via pyOpenGl
13621362
'''
1363-
global ifBox
1363+
global ifBox,HKL
13641364
ifBox = False
13651365
def OnKeyBox(event):
13661366
mode = cb.GetValue()
@@ -1519,6 +1519,7 @@ def OnKey(event): #on key UP!!
15191519
Rd = np.array([255,0,0])
15201520
Gr = np.array([0,255,0])
15211521
Bl = np.array([0,0,255])
1522+
Yl = np.array([255,255,0])
15221523
uBox = np.array([[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]])
15231524
uEdges = np.array([
15241525
[uBox[0],uBox[1]],[uBox[0],uBox[3]],[uBox[0],uBox[4]],[uBox[1],uBox[2]],
@@ -1527,11 +1528,12 @@ def OnKey(event): #on key UP!!
15271528
uColors = [Rd,Gr,Bl, Wt,Wt,Wt, Wt,Wt,Wt, Wt,Wt,Wt]
15281529

15291530
def FillHKLRC():
1531+
global HKL
15301532
sumFo2 = 0.
15311533
sumDF2 = 0.
15321534
sumFo = 0.
15331535
sumDF = 0.
1534-
R = np.zeros(len(hklRef))
1536+
R = []
15351537
C = []
15361538
HKL = []
15371539
for i,refl in enumerate(hklRef):
@@ -1541,6 +1543,9 @@ def FillHKLRC():
15411543
if Nexp[0]:
15421544
if refl[12] != Nexp[1]:
15431545
continue
1546+
if Ztilt[0]:
1547+
if round(refl[13]) != Ztilt[1]:
1548+
continue
15441549
if Data['Shell'][1]:
15451550
if not (Data['Shell'][0] <= 0.5/refl[4+Super] <= Data['Shell'][0]+.1):
15461551
continue
@@ -1561,60 +1566,73 @@ def FillHKLRC():
15611566
else:
15621567
HKL.append(H)
15631568
if Data['Type'] == 'Unit':
1564-
R[i] = 0.1
1569+
R.append(0.1)
15651570
C.append(Gr)
15661571
elif Data['Type'] == 'Fosq':
15671572
if Fosq > 0:
1568-
R[i] = Fosq
1573+
R.append(Fosq)
15691574
C.append(Gr)
15701575
else:
1571-
R[i] = -Fosq
1576+
R.append(-Fosq)
15721577
C.append(Rd)
15731578
elif Data['Type'] == 'Fo':
15741579
if Fosq > 0:
1575-
R[i] = np.sqrt(Fosq)
1580+
R.append(np.sqrt(Fosq))
15761581
C.append(Gr)
15771582
else:
1578-
R[i] = np.sqrt(-Fosq)
1583+
R.append(np.sqrt(-Fosq))
15791584
C.append(Rd)
15801585
elif Data['Type'] == 'dFsq/sig':
15811586
dFsig = (Fosq-Fcsq)/sig
15821587
if dFsig > 0:
1583-
R[i] = dFsig
1584-
C.append(Gr)
1588+
R.append(dFsig)
1589+
dFsig = min(10.,dFsig)
1590+
dw = int(255.*(1.0-(dFsig/10.)))
1591+
color = np.array([dw,255,0])
15851592
else:
1586-
R[i] = -dFsig
1587-
C.append(Rd)
1593+
R.append(-dFsig)
1594+
dFsig = max(-10.,dFsig)
1595+
dw = int(255.*(1.0+(dFsig/10.)))
1596+
color = np.array([255,dw,0])
1597+
C.append(color)
15881598
elif Data['Type'] == 'dFsq':
15891599
dF = Fosq-Fcsq
15901600
if dF > 0:
1591-
R[i] = dF
1601+
R.append(dF)
15921602
C.append(Gr)
15931603
else:
1594-
R[i] = -dF
1604+
R.append(-dF)
15951605
C.append(Rd)
1596-
R /= np.max(R)
1597-
R *= Data['Scale']
1598-
R = np.where(R<1.e-5,1.e-5,R)
1599-
if Data['Iscale']:
1600-
R = np.where(R<=1.,R,1.)
1601-
C = np.array(C)
1602-
C = (C.T*R).T
1603-
R = np.ones_like(R)*0.05
1604-
RF = 100.
1605-
RF2 = 100.
1606-
if sumFo and sumDF:
1607-
RF = 100.*sumDF/sumFo
1608-
RF2 = 100.*sumDF2/sumFo2
1609-
return HKL,zip(list(R),C),RF,RF2
1606+
if len(R):
1607+
R = np.array(R)
1608+
if Data['Type'] == 'dFsq/sig':
1609+
R /= 10.
1610+
else:
1611+
R /= np.max(np.array(R))
1612+
R *= Data['Scale']
1613+
R = np.where(R<1.e-5,1.e-5,R)
1614+
if Data['Iscale']:
1615+
R = np.where(R<=1.,R,1.)
1616+
C = np.array(C)
1617+
C = (C.T*R).T
1618+
R = np.ones_like(R)*0.05
1619+
RF = 100.
1620+
RF2 = 100.
1621+
if sumFo and sumDF:
1622+
RF = 100.*sumDF/sumFo
1623+
RF2 = 100.*sumDF2/sumFo2
1624+
return HKL,zip(list(R),C),RF,RF2
1625+
else:
1626+
return HKL,[],-100.,-100.
16101627

16111628
def GetTruePosition(xy):
1629+
global HKL
16121630
View = GL.glGetIntegerv(GL.GL_VIEWPORT)
16131631
Proj = GL.glGetDoublev(GL.GL_PROJECTION_MATRIX)
16141632
Model = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)
16151633
Zmax = 1.
16161634
xy = [int(xy[0]),int(View[3]-xy[1])]
1617-
for i,ref in enumerate(hklRef):
1635+
for i,ref in enumerate(HKL):
16181636
h,k,l = ref[:3]
16191637
try:
16201638
X,Y,Z = GLU.gluProject(h,k,l,Model,Proj,View)
@@ -1625,7 +1643,6 @@ def GetTruePosition(xy):
16251643
except ValueError:
16261644
return [int(h),int(k),int(l)]
16271645

1628-
16291646
def SetTranslation(newxy):
16301647
#first get translation vector in screen coords.
16311648
oldxy = drawingData['oldxy']
@@ -1880,6 +1897,7 @@ def Draw(caller=''):
18801897
Page.views = False
18811898
Font = Page.GetFont()
18821899
Page.Choice = None
1900+
18831901
choice = [' save as/key:','jpeg','tiff','bmp','h: view down h','k: view down k','l: view down l','r: plot radial shell',
18841902
'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',
18851903
'f: Fobs','s: Fobs**2','u: unit','d: Fo-Fc','w: DF/sig','i: toggle intensity scaling']

0 commit comments

Comments
 (0)