Skip to content

Commit d198d1a

Browse files
committed
resolve inconsistent use of dist in peneCorr. Now always sample to detector surface.
1 parent e10fb4b commit d198d1a

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

GSASII/GSASIIimage.py

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,41 @@
4545
debug = False
4646

4747
def peneCorr(tth,dep,dist):
48-
'Compute empirical position correction due to detector absorption'
48+
''' Compute empirical position correction due to detector absorption
49+
:param float/array tth: angle between detector normal & scattered ray vector
50+
:param float dep: coefficient
51+
:param float dist: sample to detector surface in mm
52+
:returns: float/array distance: correction for penetration'''
53+
4954
return dep*(1.-npcosd(tth))*dist**2/1000. #best one
5055

56+
def GetTthP(x,y,parmDict):
57+
''' Compute angle between detector normal & sample scattering ray vector
58+
:param float/array x: detector x-position in mm
59+
:param float/array y: detector y-position in mm
60+
:param dict parmDict: dictionary of detector orientation parameters in fitting routine
61+
names are: det-X, det-Y, tilt, dist & phi
62+
:returns: float/array angle: = 2-theta if tilt is zero
63+
'''
64+
def costth(xyz,d0):
65+
''' compute cos of angle between vectors; xyz not normalized, d0 normalized'''
66+
u = xyz/nl.norm(xyz,axis=-1)[:,:,nxs]
67+
return np.dot(u,d0)
68+
69+
dx = x-parmDict['det-X']
70+
dy = y-parmDict['det-Y']
71+
tilt = parmDict['tilt']
72+
dist = parmDict['dist']/npcosd(tilt) #sample-beam intersection point on detector plane
73+
T = makeMat(tilt,0) #detector tilt matrix
74+
R = makeMat(parmDict['phi'],2) #rotation of tilt axis matrix
75+
MN = np.inner(R,np.inner(R,T)) #should be detector transformation matrix; why not np.inner(R,T)
76+
d001 = np.array([0.,0.,1.]) #vector along z (beam direction); normal to untilted detector plane
77+
r001 = np.inner(d001,MN) #should rotate vector same as detector
78+
dxyz0 = np.inner(np.dstack([dx,dy,np.zeros_like(dx)]),MN) #transform detector pixel x,y by tilt/rotate
79+
dxyz0 += np.array([0.,0.,dist]) #shift away from sample
80+
ctth0 = costth(dxyz0,r001) #cos of angle between detector normal & sample-pixel vector
81+
return npacosd(ctth0)[0]
82+
5183
def SamAbs(data,tax,tay,muT):
5284
'Compute sample absorption correction for images'
5385
if 'Cylind' in data['SampleShape']:
@@ -148,7 +180,7 @@ def CalibPrint(ValSig,chisq,Npts):
148180
print (ptlbls)
149181
print (ptstr)
150182
print (sigstr)
151-
183+
152184
def ellipseCalcD(B,xyd,varyList,parmDict):
153185

154186
x,y,dsp = xyd
@@ -160,9 +192,10 @@ def ellipseCalcD(B,xyd,varyList,parmDict):
160192
else:
161193
parms[parm] = parmDict[parm]
162194
phi = parms['phi']-90. #get rotation of major axis from tilt axis
195+
dtth = GetTthP(x,y,parmDict) #sample-detector ray wrt detector plane != 2-theta if tilted
163196
tth = 2.0*npasind(parms['wave']/(2.*dsp))
164197
phi0 = npatan2d(y-parms['det-Y'],x-parms['det-X'])
165-
dxy = peneCorr(tth,parms['dep'],parms['dist'])
198+
dxy = peneCorr(dtth,parms['dep'],parms['dist'])
166199
stth = npsind(tth)
167200
cosb = npcosd(parms['tilt'])
168201
tanb = nptand(parms['tilt'])
@@ -302,8 +335,9 @@ def ellipseCalcD(B,xyd,varyList,parmDict):
302335

303336
phi = parms['phi']-90. #get rotation of major axis from tilt axis
304337
tth = 2.0*npasind(parms['wavelength']/(2.*dsp))
338+
dtth = GetTthP(x,y,parmDict)
305339
phi0 = npatan2d(y-detY,x-detX)
306-
dxy = peneCorr(tth,parms['dep'],dist-deltaDist)
340+
dxy = peneCorr(dtth,parms['dep'],dist-deltaDist)
307341
stth = npsind(tth)
308342
cosb = npcosd(parms['tilt'])
309343
tanb = nptand(parms['tilt'])
@@ -519,7 +553,7 @@ def GetTthAzmDsp2(x,y,data): #expensive
519553
OK for ellipses & hyperbola.
520554
Use only for detector 2-theta = 0
521555
522-
:returns: np.array(tth,azm,G,dsp) where tth is 2theta, azm is the azimutal angle,
556+
:returns: np.array(tth,azm,dsp) where tth is 2theta, azm is the azimutal angle,
523557
and dsp is the d-space - not used in integration
524558
'''
525559
wave = data['wavelength']
@@ -535,7 +569,7 @@ def GetTthAzmDsp2(x,y,data): #expensive
535569
X = np.dot(X,makeMat(phi,2))
536570
Z = np.dot(X,makeMat(tilt,0)).T[2]
537571
tth = npatand(np.sqrt(dx**2+dy**2-Z**2)/(dist-Z))
538-
dxy = peneCorr(tth,dep,dist)
572+
dxy = peneCorr(tth,dep,data['distance'])
539573
DX = dist-Z+dxy
540574
DY = np.sqrt(dx**2+dy**2-Z**2)
541575
tth = npatan2d(DY,DX)
@@ -548,7 +582,7 @@ def GetTthAzmDsp(x,y,data): #expensive
548582
OK for ellipses & hyperbola.
549583
Use for detector 2-theta != 0.
550584
551-
:returns: np.array(tth,azm,G,dsp) where tth is 2theta, azm is the azimutal angle,
585+
:returns: np.array(tth,azm,dsp) where tth is 2theta, azm is the azimutal angle,
552586
and dsp is the d-space - only used for non-zero detector 2-thetas
553587
'''
554588

@@ -570,7 +604,7 @@ def costth(xyz):
570604
if data['DetDepth']:
571605
ctth0 = costth(dxyz0)
572606
tth0 = npacosd(ctth0)
573-
dzp = peneCorr(tth0,data['DetDepth'],dist)
607+
dzp = peneCorr(tth0,data['DetDepth'],data['distance'])
574608
dxyz0[:,:,2] += dzp
575609
#non zero detector 2-theta:
576610
if data['det2theta']:
@@ -638,7 +672,7 @@ def costth(xyz,d0):
638672
ctth0 = costth(dxyz0,r001) #cos of angle between detector normal & sample-pixel vector
639673
if data['DetDepth']:
640674
tth0 = npacosd(ctth0)
641-
dzp = peneCorr(tth0,data['DetDepth'],dist)
675+
dzp = peneCorr(tth0,data['DetDepth'],data['distance'])
642676
dxyz0[:,:,2] += dzp
643677
#non zero detector 2-theta:
644678
if data.get('det2theta',0):

GSASII/ImageCalibrants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
'CeO2 SRM674b':([0,],[''],[(5.411651,5.411651,5.411651,90,90,90),],0,(1.0,2,1.)),
6868
'Al2O3 SRM676a':([3,],['R -3 c'],[(4.759091,4.759091,12.991779,90,90,120),],0,(1.0,5,5.)),
6969
'Ni @ 298K':([0,],[''],[(3.52475,3.52475,3.52475,90,90,90),],0,(1.0,10,10.)),
70+
'Ni @ 80K':([0,],[''],[(3.5190,3.5190,3.5190,90,90,90),],0,(1.0,10,10.)),
7071
'NaCl @ 298K':([0,],[''],[(5.6402,5.6402,5.6402,90,90,90),],0,(1.0,10,10.)),
7172
'NaCl even hkl only':([2,],[''],[(2.8201,2.8201,2.8201,90,90,90),],0,(1.0,10,10.)),
7273
'Ag behenate':([6,],[''],[(1.0,1.0,58.380,90,90,90),],0,(7.0,5,1.)),

0 commit comments

Comments
 (0)