Changeset 4903 for trunk/GSASIIimage.py


Ignore:
Timestamp:
May 17, 2021 11:23:03 AM (5 months ago)
Author:
vondreele
Message:

fix 2 issues in HessianLSQ for SVN LinAlgErrors?
fix a typo in G2plot for SASD plot display
change GetTthAzmDsp? --> GeTthAzmDsp2 in G2plot & G2Image
comment old GetTthAzmDsp? code - fails in recent python/numpy versions; replaced by GetTthAzmDsp2
change GetTthAzmG --> GetTthAzm2 in G2image

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r4832 r4903  
    595595    return np.array([tth,azm,G,dsp])
    596596   
    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 d-space
    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.]))
     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 d-space
     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.]))
    608608       
    609 #zero detector 2-theta: tested with tilted images - perfect integrations
    610     wave = data['wavelength']
    611     dx = x-data['center'][0]
    612     dy = y-data['center'][1]
    613     tilt = data['tilt']
    614     dist = data['distance']/npcosd(tilt)    #sample-beam 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 2-theta:
    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 # G-calculation       
    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 = ((dx-x0x)**2+(dy-x0y)**2+distsq)/distsq       #for geometric correction = 1/cos(2theta)^2 if tilt=0.
    641     return [tth,azm,G,dsp]
     609# #zero detector 2-theta: tested with tilted images - perfect integrations
     610#     wave = data['wavelength']
     611#     dx = x-data['center'][0]
     612#     dy = y-data['center'][1]
     613#     tilt = data['tilt']
     614#     dist = data['distance']/npcosd(tilt)    #sample-beam 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 2-theta:
     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# # G-calculation       
     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 = ((dx-x0x)**2+(dy-x0y)**2+distsq)/distsq       #for geometric correction = 1/cos(2theta)^2 if tilt=0.
     641#     return [tth,azm,G,dsp]
    642642   
    643643def GetTth(x,y,data):
    644644    'Give 2-theta value for detector x,y position; calibration info in data'
    645     return GetTthAzmDsp(x,y,data)[0]
     645    return GetTthAzmDsp2(x,y,data)[0]
    646646   
    647647def GetTthAzm(x,y,data):
    648648    'Give 2-theta, 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]
    650650   
    651651def GetTthAzmG2(x,y,data):
     
    717717def GetDsp(x,y,data):
    718718    'Give d-spacing value for detector x,y position; calibration info in data'
    719     return GetTthAzmDsp(x,y,data)[3]
     719    return GetTthAzmDsp2(x,y,data)[3]
    720720       
    721721def GetAzm(x,y,data):
    722722    '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]
    724724   
    725725def meanAzm(a,b):
     
    11581158    nJ = jLim[1]-jLim[0]
    11591159    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 step
     1160    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
    11611161    TA[1] = np.where(TA[1]<0,TA[1]+360,TA[1])
    11621162    TA[3] = G2pwd.Polarization(data['PolaVal'][0],TA[0],TA[1]-90.)[0]
Note: See TracChangeset for help on using the changeset viewer.