Skip to content

Commit 6808f9d

Browse files
committed
fix line scan issues (for ellipses)
1 parent 5cff9c4 commit 6808f9d

File tree

2 files changed

+49
-51
lines changed

2 files changed

+49
-51
lines changed

GSASII/GSASIIimage.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -474,44 +474,44 @@ def GetEllipse(dsp,data):
474474
dxy = peneCorr(tth,dep,dist)
475475
return GetEllipse2(tth,dxy,dist,cent,tilt,phi)
476476

477-
def GetDetectorXY(dsp,azm,data):
478-
'''Get detector x,y position from d-spacing (dsp), azimuth (azm,deg)
479-
& image controls dictionary (data) - new version
480-
it seems to be only used in plotting & wrong
481-
'''
482-
def LinePlaneCollision(planeNormal, planePoint, rayDirection, rayPoint, epsilon=1e-6):
483-
484-
ndotu = planeNormal.dot(rayDirection)
485-
if ndotu < epsilon:
486-
return None
487-
w = rayPoint - planePoint
488-
si = -planeNormal.dot(w) / ndotu
489-
Psi = w + si * rayDirection + planePoint
490-
return Psi
491-
492-
dist = data['distance']
493-
cent = data['center']
494-
phi = data['rotation']-90. #to give rotation of major axis
495-
T = makeMat(data['tilt'],0) #rotate about X
496-
R = makeMat(phi,2) #rotate about Z
497-
MN = np.inner(R,np.inner(R,T))
498-
iMN= nl.inv(MN)
499-
tth = 2.0*npasind(data['wavelength']/(2.*dsp))
500-
vect = np.array([npsind(tth)*npcosd(azm-phi),npsind(tth)*npsind(azm-phi),npcosd(tth)])
501-
dxyz0 = np.inner(np.array([0.,0.,1.0]),MN) #tilt detector normal
502-
dxyz0 += np.array([0.,0.,dist]) #translate to distance
503-
dxyz0 = np.inner(dxyz0,makeMat(data['det2theta'],1).T) #rotate on 2-theta
504-
dxyz1 = np.inner(np.array([cent[0],cent[1],0.]),MN) #tilt detector cent
505-
dxyz1 += np.array([0.,0.,dist]) #translate to distance
506-
dxyz1 = np.inner(dxyz1,makeMat(data['det2theta'],1).T) #rotate on 2-theta
507-
xyz = LinePlaneCollision(dxyz1,dxyz0,vect,dist*vect)
508-
if xyz is None:
509-
return np.zeros(2)
510-
# return None
511-
xyz = np.inner(xyz,makeMat(data['det2theta'],1).T)
512-
xyz -= np.array([0.,0.,dist]) #translate back
513-
xyz = np.inner(xyz,iMN)
514-
return np.squeeze(xyz)[:2]+cent
477+
# def GetDetectorXY(dsp,azm,data):
478+
# '''Get detector x,y position from d-spacing (dsp), azimuth (azm,deg)
479+
# & image controls dictionary (data) - new version
480+
# it seems to be only used in plotting & wrong
481+
# '''
482+
# def LinePlaneCollision(planeNormal, planePoint, rayDirection, rayPoint, epsilon=1e-6):
483+
484+
# ndotu = planeNormal.dot(rayDirection)
485+
# if ndotu < epsilon:
486+
# return None
487+
# w = rayPoint - planePoint
488+
# si = -planeNormal.dot(w) / ndotu
489+
# Psi = w + si * rayDirection + planePoint
490+
# return Psi
491+
492+
# dist = data['distance']
493+
# cent = data['center']
494+
# phi = data['rotation']-90. #to give rotation of major axis
495+
# T = makeMat(data['tilt'],0) #rotate about X
496+
# R = makeMat(phi,2) #rotate about Z
497+
# MN = np.inner(R,np.inner(R,T))
498+
# iMN= nl.inv(MN)
499+
# tth = 2.0*npasind(data['wavelength']/(2.*dsp))
500+
# vect = np.array([npsind(tth)*npcosd(azm-phi),npsind(tth)*npsind(azm-phi),npcosd(tth)])
501+
# dxyz0 = np.inner(np.array([0.,0.,1.0]),MN) #tilt detector normal
502+
# dxyz0 += np.array([0.,0.,dist]) #translate to distance
503+
# dxyz0 = np.inner(dxyz0,makeMat(data['det2theta'],1).T) #rotate on 2-theta
504+
# dxyz1 = np.inner(np.array([cent[0],cent[1],0.]),MN) #tilt detector cent
505+
# dxyz1 += np.array([0.,0.,dist]) #translate to distance
506+
# dxyz1 = np.inner(dxyz1,makeMat(data['det2theta'],1).T) #rotate on 2-theta
507+
# xyz = LinePlaneCollision(dxyz1,dxyz0,vect,dist*vect)
508+
# if xyz is None:
509+
# return np.zeros(2)
510+
# # return None
511+
# xyz = np.inner(xyz,makeMat(data['det2theta'],1).T)
512+
# xyz -= np.array([0.,0.,dist]) #translate back
513+
# xyz = np.inner(xyz,iMN)
514+
# return np.squeeze(xyz)[:2]+cent
515515

516516
def GetDetectorXY2(dsp,azm,data):
517517
'''Get detector x,y position from d-spacing (dsp), azimuth (azm,deg)
@@ -563,12 +563,12 @@ def GetDetectorXY2(dsp,azm,data):
563563
xy[0] += dist*nptand(data['det2theta']+data['tilt']*npsind(data['rotation']))
564564
return xy
565565

566-
def GetDetXYfromThAzm(Th,Azm,data):
567-
'''Computes a detector position from a 2theta angle and an azimultal
568-
angle (both in degrees) - apparently not used!
569-
'''
570-
dsp = data['wavelength']/(2.0*npsind(Th))
571-
return GetDetectorXY(dsp,Azm,data)
566+
# def GetDetXYfromThAzm(Th,Azm,data):
567+
# '''Computes a detector position from a 2theta angle and an azimultal
568+
# angle (both in degrees) - apparently not used!
569+
# '''
570+
# dsp = data['wavelength']/(2.0*npsind(Th))
571+
# return GetDetectorXY(dsp,Azm,data)
572572

573573
# this suite not used for integration - only image plotting & mask positioning
574574
def GetTthAzmDsp2(x,y,data): #expensive
@@ -781,7 +781,7 @@ def GetLineScan(image,data):
781781
Tx = np.array([tth for tth in np.linspace(LUtth[0],LUtth[1],numChans+1)])
782782
Ty = np.zeros_like(Tx)
783783
dsp = wave/(2.0*npsind(Tx/2.0))
784-
xy = [GetDetectorXY(d,azm,data) for d in dsp]
784+
xy = [GetDetectorXY2(d,azm,data) for d in dsp]
785785
xy = np.array(xy).T
786786
xy[1] *= scalex
787787
xy[0] *= scaley

GSASII/GSASIIplot.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4873,9 +4873,9 @@ def OnDragIntBound(event):
48734873
elif 'linescan' in itemPicked:
48744874
xlim = Plot1.get_xlim()
48754875
azm = Data['linescan'][1]-AzmthOff
4876-
dspI = wave/(2.0*sind(0.1/2.0))
4876+
dspI = wave/(2.0*sind(IOtth[0]/2.0))
48774877
xyI = G2img.GetDetectorXY2(dspI,azm,Data)
4878-
dspO = wave/(2.0*sind(60./2.0))
4878+
dspO = wave/(2.0*sind(IOtth[1]/2.0))
48794879
xyO = G2img.GetDetectorXY2(dspO,azm,Data)
48804880
pick.set_data([[xyI[0],xyO[0]],[xyI[1],xyO[1]]])
48814881
xy = G2img.GetLineScan(G2frame.ImageZ,Data)
@@ -5493,15 +5493,13 @@ def OnImRelease(event):
54935493
Plot.plot([arcxI[ind],arcxO[ind]],[arcyI[ind],arcyO[ind]],color='k',dashes=(5,5))
54945494
if 'linescan' in Data and Data['linescan'][0] and G2frame.GPXtree.GetItemText(G2frame.PickId) in ['Image Controls',]:
54955495
azm = Data['linescan'][1]-Data['azmthOff']
5496-
IOtth = [0.1,60.]
5496+
IOtth = Data['IOtth']
54975497
wave = Data['wavelength']
54985498
dspI = wave/(2.0*sind(IOtth[0]/2.0))
54995499
xyI = G2img.GetDetectorXY2(dspI,azm,Data)
55005500
dspO = wave/(2.0*sind(IOtth[1]/2.0))
55015501
xyO = G2img.GetDetectorXY2(dspO,azm,Data)
5502-
Plot.plot([xyI[0],xyO[0]],[xyI[1],xyO[1]],
5503-
# picker=True,pickradius=3,label='linescan')
5504-
picker=False,label='linescan')
5502+
Plot.plot([xyI[0],xyO[0]],[xyI[1],xyO[1]],picker=False,label='linescan')
55055503

55065504
if G2frame.PickId and G2frame.GPXtree.GetItemText(G2frame.PickId) in ['Image Controls',]:
55075505
for xring,yring in Data['ring']:

0 commit comments

Comments
 (0)