Changeset 4582 for trunk/GSASIIimage.py
- Timestamp:
- Oct 4, 2020 2:51:27 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimage.py
r4572 r4582 73 73 return Inside 74 74 75 def peneCorr(tth,dep,dist ,tilt=0.,azm=0.):75 def peneCorr(tth,dep,dist): 76 76 'Needs a doc string' 77 # return dep*(1.-npcosd(abs(tilt*npsind(azm))-tth*npcosd(azm))) #something wrong here78 77 return dep*(1.-npcosd(tth))*dist**2/1000. #best one 79 # return dep*npsind(tth) #not as good as 1-cos2Q80 78 81 79 def makeMat(Angle,Axis): … … 182 180 tth = 2.0*npasind(parms['wave']/(2.*dsp)) 183 181 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']) 185 183 stth = npsind(tth) 186 184 cosb = npcosd(parms['tilt']) … … 323 321 tth = 2.0*npasind(parms['wavelength']/(2.*dsp)) 324 322 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) 326 324 stth = npsind(tth) 327 325 cosb = npcosd(parms['tilt']) … … 469 467 tth = 2.0*asind(data['wavelength']/(2.*dsp)) 470 468 dist = data['distance'] 471 dxy = peneCorr(tth,dep,dist ,tilt)469 dxy = peneCorr(tth,dep,dist) 472 470 return GetEllipse2(tth,dxy,dist,cent,tilt,phi) 473 471 … … 546 544 Z = np.dot(X,makeMat(tilt,0)).T[2] 547 545 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) 549 547 DX = dist-Z+dxy 550 548 DY = np.sqrt(dx**2+dy**2-Z**2) … … 565 563 def GetTthAzmG(x,y,data): 566 564 '''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 568 566 ''' 569 567 'Needs a doc string - checked OK for ellipses & hyperbola' 570 568 tilt = data['tilt'] 571 569 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 572 581 x0 = data['distance']*nptand(tilt) 573 582 x0x = x0*npcosd(data['rotation']) 574 583 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 587 def 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 577 598 dx = x-data['center'][0] 578 599 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 579 623 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**2582 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.586 624 return tth,azm,G 587 625 … … 1242 1280 if 'SASD' not in data['type']: 1243 1281 H0 *= np.array(G2pwd.Polarization(data['PolaVal'][0],H2[:-1],0.)[0]) 1244 H0 /= np cosd(H2[:-1]) #**2? I don't think so, **1 is right for powders1282 H0 /= np.abs(npcosd(H2[:-1]-np.abs(data['det2theta']))) #parallax correction 1245 1283 if 'SASD' in data['type']: 1246 1284 H0 /= npcosd(H2[:-1]) #one more for small angle scattering data?
Note: See TracChangeset
for help on using the changeset viewer.