Changeset 4582
- Timestamp:
- Oct 4, 2020 2:51:27 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 4 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? -
trunk/GSASIIimgGUI.py
r4571 r4582 183 183 distSizer.Add(polaCalib,0,WACV) 184 184 mainSizer.Add(distSizer,0) 185 #patch 185 186 if 'samplechangerpos' not in data or data['samplechangerpos'] is None: 186 187 data['samplechangerpos'] = 0.0 187 mainSizer.Add(wx.StaticText(G2frame.dataWindow,label='Sample changer position %.2f mm'%data['samplechangerpos']),0,WACV) 188 if 'det2theta' not in data: 189 data['det2theta'] = 0.0 190 #end patch 191 tthSizer = wx.BoxSizer(wx.HORIZONTAL) 192 tthSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Detector 2-theta: '),0,WACV) 193 tthSizer.Add(G2G.ValidatedTxtCtrl(G2frame.dataWindow,data,'det2theta',xmin=-180.,xmax=180.,nDig=(10,2)),0,WACV) 194 tthSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Sample changer position %.2f mm '%data['samplechangerpos']),0,WACV) 195 mainSizer.Add(tthSizer,0) 188 196 G2frame.dataWindow.SetDataSize() 189 197 … … 191 199 ##### Image Controls 192 200 ################################################################################ 193 blkSize = 128 201 blkSize = 128 #128 seems to be optimal; will break in polymask if >1024 194 202 def UpdateImageControls(G2frame,data,masks,useTA=None,useMask=None,IntegrateOnly=False): 195 203 '''Shows and handles the controls on the "Image Controls" … … 221 229 if 'linescan' not in data: 222 230 data['linescan'] = [False,0.0] #includes azimuth to draw line scan 231 if 'det2theta' not in data: 232 data['det2theta'] = 0.0 223 233 #end patch 224 234 … … 489 499 try: 490 500 pId = 0 491 oldData = {'tilt':0.,'distance':0.,'rotation':0.,'center':[0.,0.],'DetDepth':0.,'azmthOff':0. }501 oldData = {'tilt':0.,'distance':0.,'rotation':0.,'center':[0.,0.],'DetDepth':0.,'azmthOff':0.,'det2theta':0.} 492 502 oldMhash = 0 493 503 for icnt,item in enumerate(items): … … 501 511 Data = G2frame.GPXtree.GetItemPyData(CId) 502 512 same = True 503 for item in ['tilt','distance','rotation','DetDepth','azmthOff' ]:513 for item in ['tilt','distance','rotation','DetDepth','azmthOff','det2theta']: 504 514 if Data[item] != oldData[item]: 505 515 same = False … … 551 561 items = dlg.GetSelections() 552 562 G2frame.EnablePlot = False 553 for item in items: 563 for item in items: #preserve some values 554 564 name = Names[item] 555 565 Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,name) … … 561 571 Data['GonioAngles'] = oldData.get('GonioAngles', [0.,0.,0.]) 562 572 Data['samplechangerpos'] = oldData.get('samplechangerpos',0.0) 573 Data['det2theta'] = oldData.get('det2theta',0.0) 563 574 Data['ring'] = [] 564 575 Data['rings'] = [] -
trunk/GSASIIlattice.py
r4531 r4582 744 744 cosP = np.inner(u,np.inner(G,v)) 745 745 return cosP 746 746 747 747 def CosSinAngle(U,V,G): 748 748 """ calculate sin & cos of angle between U & V in generalized coordinates -
trunk/imports/G2img_CBF.py
r4213 r4582 57 57 cent = [0,0] 58 58 wave = 1.54187 #default <CuKa> 59 det2theta = 0.0 59 60 dist = 1000. 60 61 byteOrd = '<' … … 91 92 elif 'Number-of-Elements' in line: 92 93 Npix = int(fields[1]) 94 elif 'Detector_2theta' in line: 95 det2theta = float(fields[2]) 93 96 nxy = sizexy[0]*sizexy[1] 94 97 cent = [cent[0]*pixSize[0]/1000.,cent[1]*pixSize[1]/1000.] … … 105 108 image = np.reshape(image,(sizexy[1],sizexy[0])) 106 109 print ('import time: %.3f'%(time.time()-time0)) 107 data = {'pixelSize':pixSize,'wavelength':wave,'distance':dist,'center':cent,'size':sizexy }110 data = {'pixelSize':pixSize,'wavelength':wave,'distance':dist,'center':cent,'size':sizexy,'det2theta':det2theta} 108 111 Npix = sizexy[0]*sizexy[1] 109 112
Note: See TracChangeset
for help on using the changeset viewer.