@@ -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
516516def 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
574574def 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
0 commit comments