Changeset 4582 for trunk/GSASIIimage.py


Ignore:
Timestamp:
Oct 4, 2020 2:51:27 PM (3 years ago)
Author:
vondreele
Message:

New image calibration/integration routines for 2-theta stepped detectors. Integration now faster
removed unused variables from peneCorr

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r4572 r4582  
    7373    return Inside
    7474   
    75 def peneCorr(tth,dep,dist,tilt=0.,azm=0.):
     75def peneCorr(tth,dep,dist):
    7676    'Needs a doc string'
    77 #    return dep*(1.-npcosd(abs(tilt*npsind(azm))-tth*npcosd(azm)))  #something wrong here
    7877    return dep*(1.-npcosd(tth))*dist**2/1000.         #best one
    79 #    return dep*npsind(tth)             #not as good as 1-cos2Q
    8078       
    8179def makeMat(Angle,Axis):
     
    182180        tth = 2.0*npasind(parms['wave']/(2.*dsp))
    183181        phi0 = npatan2d(y-parms['det-Y'],x-parms['det-X'])
    184         dxy = peneCorr(tth,parms['dep'],parms['dist'],parms['tilt'],phi0)
     182        dxy = peneCorr(tth,parms['dep'],parms['dist'])
    185183        stth = npsind(tth)
    186184        cosb = npcosd(parms['tilt'])
     
    323321        tth = 2.0*npasind(parms['wavelength']/(2.*dsp))
    324322        phi0 = npatan2d(y-detY,x-detX)
    325         dxy = peneCorr(tth,parms['dep'],dist-deltaDist,parms['tilt'],phi0)
     323        dxy = peneCorr(tth,parms['dep'],dist-deltaDist)
    326324        stth = npsind(tth)
    327325        cosb = npcosd(parms['tilt'])
     
    469467    tth = 2.0*asind(data['wavelength']/(2.*dsp))
    470468    dist = data['distance']
    471     dxy = peneCorr(tth,dep,dist,tilt)
     469    dxy = peneCorr(tth,dep,dist)
    472470    return GetEllipse2(tth,dxy,dist,cent,tilt,phi)
    473471       
     
    546544    Z = np.dot(X,makeMat(tilt,0)).T[2]
    547545    tth = npatand(np.sqrt(dx**2+dy**2-Z**2)/(dist-Z))
    548     dxy = peneCorr(tth,dep,dist,tilt,npatan2d(dy,dx))
     546    dxy = peneCorr(tth,dep,dist)
    549547    DX = dist-Z+dxy
    550548    DY = np.sqrt(dx**2+dy**2-Z**2)
     
    565563def GetTthAzmG(x,y,data):
    566564    '''Give 2-theta, azimuth & geometric corr. values for detector x,y position;
    567      calibration info in data - only used in integration
     565     calibration info in data - only used in integration - old version
    568566    '''
    569567    'Needs a doc string - checked OK for ellipses & hyperbola'
    570568    tilt = data['tilt']
    571569    dist = data['distance']/npcosd(tilt)
     570    MN = -np.inner(makeMat(data['rotation'],2),makeMat(tilt,0))
     571    dx = x-data['center'][0]
     572    dy = y-data['center'][1]
     573    dz = np.dot(np.dstack([dx.T,dy.T,np.zeros_like(dx.T)]),MN).T[2]   
     574    xyZ = dx**2+dy**2-dz**2   
     575    tth0 = npatand(np.sqrt(xyZ)/(dist-dz))
     576    dzp = peneCorr(tth0,data['DetDepth'],dist)
     577    tth = npatan2d(np.sqrt(xyZ),dist-dz+dzp)
     578    azm = (npatan2d(dy,dx)+data['azmthOff']+720.)%360.
     579   
     580    distsq = data['distance']**2
    572581    x0 = data['distance']*nptand(tilt)
    573582    x0x = x0*npcosd(data['rotation'])
    574583    x0y = x0*npsind(data['rotation'])
    575     MN = -np.inner(makeMat(data['rotation'],2),makeMat(tilt,0))
    576     distsq = data['distance']**2
     584    G = ((dx-x0x)**2+(dy-x0y)**2+distsq)/distsq       #for geometric correction = 1/cos(2theta)^2 if tilt=0.
     585    return tth,azm,G
     586
     587def GetTthAzmG2(x,y,data):
     588    '''Give 2-theta, azimuth & geometric corr. values for detector x,y position;
     589     calibration info in data - only used in integration
     590     checked OK for ellipses & hyperbola
     591     '''
     592     
     593    def costth(xyz):
     594        u = xyz/nl.norm(xyz,axis=-1)[:,:,nxs]
     595        return np.dot(u,np.array([0.,0.,1.]))
     596       
     597#zero detector 2-theta: tested with tilted images - perfect integrations
    577598    dx = x-data['center'][0]
    578599    dy = y-data['center'][1]
     600    tilt = data['tilt']
     601    dist = data['distance']/npcosd(tilt)    #sample-beam intersection point
     602    T = makeMat(tilt,0)
     603    R = makeMat(data['rotation'],2)
     604    MN = np.inner(R,np.inner(R,T))
     605    dxyz0 = np.inner(np.dstack([dx,dy,np.zeros_like(dx)]),MN)    #correct for 45 deg tilt
     606    dxyz0 += np.array([0.,0.,dist])
     607    if data['DetDepth']:
     608        ctth0 = costth(dxyz0)
     609        tth0 = npacosd(ctth0)
     610        dzp = peneCorr(tth0,data['DetDepth'],dist,tilt)
     611        dxyz0[:,:,2] += dzp
     612#non zero detector 2-theta:   
     613    tthMat = makeMat(data['det2theta'],1)
     614    dxyz = np.inner(dxyz0,tthMat.T)
     615    ctth = costth(dxyz)
     616    tth = npacosd(ctth)
     617    azm = (npatan2d(dxyz[:,:,1],dxyz[:,:,0])+data['azmthOff']+720.)%360.
     618# G-calculation       
     619    x0 = data['distance']*nptand(tilt)
     620    x0x = x0*npcosd(data['rotation'])
     621    x0y = x0*npsind(data['rotation'])
     622    distsq = data['distance']**2
    579623    G = ((dx-x0x)**2+(dy-x0y)**2+distsq)/distsq       #for geometric correction = 1/cos(2theta)^2 if tilt=0.
    580     Z = np.dot(np.dstack([dx.T,dy.T,np.zeros_like(dx.T)]),MN).T[2]
    581     xyZ = dx**2+dy**2-Z**2   
    582     tth = npatand(np.sqrt(xyZ)/(dist-Z))
    583     dxy = peneCorr(tth,data['DetDepth'],dist,tilt,npatan2d(dy,dx))
    584     tth = npatan2d(np.sqrt(xyZ),dist-Z+dxy)
    585     azm = (npatan2d(dy,dx)+data['azmthOff']+720.)%360.
    586624    return tth,azm,G
    587625
     
    12421280    if 'SASD' not in data['type']:
    12431281        H0 *= np.array(G2pwd.Polarization(data['PolaVal'][0],H2[:-1],0.)[0])
    1244     H0 /= npcosd(H2[:-1])           #**2? I don't think so, **1 is right for powders
     1282    H0 /= np.abs(npcosd(H2[:-1]-np.abs(data['det2theta'])))           #parallax correction
    12451283    if 'SASD' in data['type']:
    12461284        H0 /= npcosd(H2[:-1])           #one more for small angle scattering data?
Note: See TracChangeset for help on using the changeset viewer.