Changeset 4903 for trunk/GSASIIimage.py
 Timestamp:
 May 17, 2021 11:23:03 AM (19 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIimage.py
r4832 r4903 595 595 return np.array([tth,azm,G,dsp]) 596 596 597 def GetTthAzmDsp(x,y,data): #expensive598 '''Computes a 2theta, etc. from a detector position and calibration constants  checked599 OK for ellipses & hyperbola.600 601 :returns: np.array(tth,azm,G,dsp) where tth is 2theta, azm is the azimutal angle,602 G is ? and dsp is the dspace603 '''604 605 def costth(xyz):606 u = xyz/nl.norm(xyz,axis=1)[:,:,nxs]607 return np.dot(u,np.array([0.,0.,1.]))597 # def GetTthAzmDsp(x,y,data): #expensive 598 # '''Computes a 2theta, etc. from a detector position and calibration constants  checked 599 # OK for ellipses & hyperbola. 600 601 # :returns: np.array(tth,azm,G,dsp) where tth is 2theta, azm is the azimutal angle, 602 # G is ? and dsp is the dspace 603 # ''' 604 605 # def costth(xyz): 606 # u = xyz/nl.norm(xyz,axis=1)[:,:,nxs] 607 # return np.dot(u,np.array([0.,0.,1.])) 608 608 609 # zero detector 2theta: tested with tilted images  perfect integrations610 wave = data['wavelength']611 dx = xdata['center'][0]612 dy = ydata['center'][1]613 tilt = data['tilt']614 dist = data['distance']/npcosd(tilt) #samplebeam intersection point615 T = makeMat(tilt,0)616 R = makeMat(data['rotation'],2)617 MN = np.inner(R,np.inner(R,T))618 dxyz0 = np.inner(np.dstack([dx,dy,np.zeros_like(dx)]),MN) #correct for 45 deg tilt619 dxyz0 += np.array([0.,0.,dist])620 if data['DetDepth']:621 ctth0 = costth(dxyz0)622 tth0 = npacosd(ctth0)623 dzp = peneCorr(tth0,data['DetDepth'],dist)624 dxyz0[:,:,2] += dzp625 # non zero detector 2theta:626 if data['det2theta']:627 tthMat = makeMat(data['det2theta'],1)628 dxyz = np.inner(dxyz0,tthMat.T)629 else:630 dxyz = dxyz0631 ctth = costth(dxyz)632 tth = npacosd(ctth)633 dsp = wave/(2.*npsind(tth/2.))634 azm = (npatan2d(dxyz[:,:,1],dxyz[:,:,0])+data['azmthOff']+720.)%360.635 # Gcalculation636 x0 = data['distance']*nptand(tilt)637 x0x = x0*npcosd(data['rotation'])638 x0y = x0*npsind(data['rotation'])639 distsq = data['distance']**2640 G = ((dxx0x)**2+(dyx0y)**2+distsq)/distsq #for geometric correction = 1/cos(2theta)^2 if tilt=0.641 return [tth,azm,G,dsp]609 # #zero detector 2theta: tested with tilted images  perfect integrations 610 # wave = data['wavelength'] 611 # dx = xdata['center'][0] 612 # dy = ydata['center'][1] 613 # tilt = data['tilt'] 614 # dist = data['distance']/npcosd(tilt) #samplebeam intersection point 615 # T = makeMat(tilt,0) 616 # R = makeMat(data['rotation'],2) 617 # MN = np.inner(R,np.inner(R,T)) 618 # dxyz0 = np.inner(np.dstack([dx,dy,np.zeros_like(dx)]),MN) #correct for 45 deg tilt 619 # dxyz0 += np.array([0.,0.,dist]) 620 # if data['DetDepth']: 621 # ctth0 = costth(dxyz0) 622 # tth0 = npacosd(ctth0) 623 # dzp = peneCorr(tth0,data['DetDepth'],dist) 624 # dxyz0[:,:,2] += dzp 625 # #non zero detector 2theta: 626 # if data['det2theta']: 627 # tthMat = makeMat(data['det2theta'],1) 628 # dxyz = np.inner(dxyz0,tthMat.T) 629 # else: 630 # dxyz = dxyz0 631 # ctth = costth(dxyz) 632 # tth = npacosd(ctth) 633 # dsp = wave/(2.*npsind(tth/2.)) 634 # azm = (npatan2d(dxyz[:,:,1],dxyz[:,:,0])+data['azmthOff']+720.)%360. 635 # # Gcalculation 636 # x0 = data['distance']*nptand(tilt) 637 # x0x = x0*npcosd(data['rotation']) 638 # x0y = x0*npsind(data['rotation']) 639 # distsq = data['distance']**2 640 # G = ((dxx0x)**2+(dyx0y)**2+distsq)/distsq #for geometric correction = 1/cos(2theta)^2 if tilt=0. 641 # return [tth,azm,G,dsp] 642 642 643 643 def GetTth(x,y,data): 644 644 'Give 2theta value for detector x,y position; calibration info in data' 645 return GetTthAzmDsp (x,y,data)[0]645 return GetTthAzmDsp2(x,y,data)[0] 646 646 647 647 def GetTthAzm(x,y,data): 648 648 'Give 2theta, azimuth values for detector x,y position; calibration info in data' 649 return GetTthAzmDsp (x,y,data)[0:2]649 return GetTthAzmDsp2(x,y,data)[0:2] 650 650 651 651 def GetTthAzmG2(x,y,data): … … 717 717 def GetDsp(x,y,data): 718 718 'Give dspacing value for detector x,y position; calibration info in data' 719 return GetTthAzmDsp (x,y,data)[3]719 return GetTthAzmDsp2(x,y,data)[3] 720 720 721 721 def GetAzm(x,y,data): 722 722 'Give azimuth value for detector x,y position; calibration info in data' 723 return GetTthAzmDsp (x,y,data)[1]723 return GetTthAzmDsp2(x,y,data)[1] 724 724 725 725 def meanAzm(a,b): … … 1158 1158 nJ = jLim[1]jLim[0] 1159 1159 TA = np.empty((4,nI,nJ)) 1160 TA[:3] = np.array(GetTthAzmG (np.reshape(tax,(nI,nJ)),np.reshape(tay,(nI,nJ)),data)) #includes geom. corr. as dist**2/d0**2  most expensive step1160 TA[:3] = np.array(GetTthAzmG2(np.reshape(tax,(nI,nJ)),np.reshape(tay,(nI,nJ)),data)) #includes geom. corr. as dist**2/d0**2  most expensive step 1161 1161 TA[1] = np.where(TA[1]<0,TA[1]+360,TA[1]) 1162 1162 TA[3] = G2pwd.Polarization(data['PolaVal'][0],TA[0],TA[1]90.)[0]
Note: See TracChangeset
for help on using the changeset viewer.