Changeset 4587 for trunk


Ignore:
Timestamp:
Oct 8, 2020 9:59:00 AM (3 years ago)
Author:
vondreele
Message:

New version of GetTthAzmDsp? to use det2theta

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r4586 r4587  
    522522    return GetDetectorXY(dsp,Azm,data)
    523523                   
    524 def GetTthAzmDsp(x,y,data): #expensive
     524def GetTthAzmDsp2(x,y,data): #expensive
    525525    '''Computes a 2theta, etc. from a detector position and calibration constants - checked
    526526    OK for ellipses & hyperbola.
     
    553553    return np.array([tth,azm,G,dsp])
    554554   
     555def GetTthAzmDsp(x,y,data): #expensive
     556    '''Computes a 2theta, etc. from a detector position and calibration constants - checked
     557    OK for ellipses & hyperbola.
     558
     559    :returns: np.array(tth,azm,G,dsp) where tth is 2theta, azm is the azimutal angle,
     560       G is ? and dsp is the d-space
     561    '''
     562   
     563    def costth(xyz):
     564        u = xyz/nl.norm(xyz,axis=-1)[:,:,nxs]
     565        return np.dot(u,np.array([0.,0.,1.]))
     566       
     567#zero detector 2-theta: tested with tilted images - perfect integrations
     568    wave = data['wavelength']
     569    dx = x-data['center'][0]
     570    dy = y-data['center'][1]
     571    tilt = data['tilt']
     572    dist = data['distance']/npcosd(tilt)    #sample-beam intersection point
     573    T = makeMat(tilt,0)
     574    R = makeMat(data['rotation'],2)
     575    MN = np.inner(R,np.inner(R,T))
     576    dxyz0 = np.inner(np.dstack([dx,dy,np.zeros_like(dx)]),MN)    #correct for 45 deg tilt
     577    dxyz0 += np.array([0.,0.,dist])
     578    if data['DetDepth']:
     579        ctth0 = costth(dxyz0)
     580        tth0 = npacosd(ctth0)
     581        dzp = peneCorr(tth0,data['DetDepth'],dist)
     582        dxyz0[:,:,2] += dzp
     583#non zero detector 2-theta:
     584    if data['det2theta']:       
     585        tthMat = makeMat(data['det2theta'],1)
     586        dxyz = np.inner(dxyz0,tthMat.T)
     587    else:
     588        dxyz = dxyz0
     589    ctth = costth(dxyz)
     590    tth = npacosd(ctth)
     591    dsp = wave/(2.*npsind(tth/2.))
     592    azm = (npatan2d(dxyz[:,:,1],dxyz[:,:,0])+data['azmthOff']+720.)%360.       
     593# G-calculation       
     594    x0 = data['distance']*nptand(tilt)
     595    x0x = x0*npcosd(data['rotation'])
     596    x0y = x0*npsind(data['rotation'])
     597    distsq = data['distance']**2
     598    G = ((dx-x0x)**2+(dy-x0y)**2+distsq)/distsq       #for geometric correction = 1/cos(2theta)^2 if tilt=0.
     599    return np.array([tth,azm,G,dsp])
     600   
    555601def GetTth(x,y,data):
    556602    'Give 2-theta value for detector x,y position; calibration info in data'
     
    589635     calibration info in data - only used in integration
    590636     checked OK for ellipses & hyperbola
    591      '''
    592      
     637     This is the slow step in image integration
     638     '''     
    593639    def costth(xyz):
    594640        u = xyz/nl.norm(xyz,axis=-1)[:,:,nxs]
     
    610656        dzp = peneCorr(tth0,data['DetDepth'],dist)
    611657        dxyz0[:,:,2] += dzp
    612 #non zero detector 2-theta:   
    613     tthMat = makeMat(data['det2theta'],1)
    614     dxyz = np.inner(dxyz0,tthMat.T)
     658#non zero detector 2-theta:
     659    if data['det2theta']:       
     660        tthMat = makeMat(data['det2theta'],1)
     661        dxyz = np.inner(dxyz0,tthMat.T)
     662    else:
     663        dxyz = dxyz0
    615664    ctth = costth(dxyz)
    616665    tth = npacosd(ctth)
    617     azm = (npatan2d(dxyz[:,:,1],dxyz[:,:,0])+data['azmthOff']+720.)%360.
     666    azm = (npatan2d(dxyz[:,:,1],dxyz[:,:,0])+data['azmthOff']+720.)%360.       
    618667# G-calculation       
    619668    x0 = data['distance']*nptand(tilt)
Note: See TracChangeset for help on using the changeset viewer.