Changeset 4903
 Timestamp:
 May 17, 2021 11:23:03 AM (2 years ago)
 Location:
 trunk
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIimage.py
r4832 r4903 595 595 return np.array([tth,azm,G,dsp]) 596 596 597 def GetTthAzmDsp(x,y,data): #expensive598 '''Computes a 2theta, etc. from a detector position and calibration constants  checked599 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 dspace603 '''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 dspace 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.])) 608 608 609 # zero detector 2theta: tested with tilted images  perfect integrations610 wave = data['wavelength']611 dx = xdata['center'][0]612 dy = ydata['center'][1]613 tilt = data['tilt']614 dist = data['distance']/npcosd(tilt) #samplebeam intersection point615 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 tilt619 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] += dzp625 # non zero detector 2theta:626 if data['det2theta']:627 tthMat = makeMat(data['det2theta'],1)628 dxyz = np.inner(dxyz0,tthMat.T)629 else:630 dxyz = dxyz0631 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 # Gcalculation636 x0 = data['distance']*nptand(tilt)637 x0x = x0*npcosd(data['rotation'])638 x0y = x0*npsind(data['rotation'])639 distsq = data['distance']**2640 G = ((dxx0x)**2+(dyx0y)**2+distsq)/distsq #for geometric correction = 1/cos(2theta)^2 if tilt=0.641 return [tth,azm,G,dsp]609 # #zero detector 2theta: tested with tilted images  perfect integrations 610 # wave = data['wavelength'] 611 # dx = xdata['center'][0] 612 # dy = ydata['center'][1] 613 # tilt = data['tilt'] 614 # dist = data['distance']/npcosd(tilt) #samplebeam 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 2theta: 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 # # Gcalculation 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 = ((dxx0x)**2+(dyx0y)**2+distsq)/distsq #for geometric correction = 1/cos(2theta)^2 if tilt=0. 641 # return [tth,azm,G,dsp] 642 642 643 643 def GetTth(x,y,data): 644 644 'Give 2theta value for detector x,y position; calibration info in data' 645 return GetTthAzmDsp (x,y,data)[0]645 return GetTthAzmDsp2(x,y,data)[0] 646 646 647 647 def GetTthAzm(x,y,data): 648 648 'Give 2theta, 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] 650 650 651 651 def GetTthAzmG2(x,y,data): … … 717 717 def GetDsp(x,y,data): 718 718 'Give dspacing value for detector x,y position; calibration info in data' 719 return GetTthAzmDsp (x,y,data)[3]719 return GetTthAzmDsp2(x,y,data)[3] 720 720 721 721 def GetAzm(x,y,data): 722 722 '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] 724 724 725 725 def meanAzm(a,b): … … 1158 1158 nJ = jLim[1]jLim[0] 1159 1159 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 step1160 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 1161 1161 TA[1] = np.where(TA[1]<0,TA[1]+360,TA[1]) 1162 1162 TA[3] = G2pwd.Polarization(data['PolaVal'][0],TA[0],TA[1]90.)[0] 
trunk/GSASIImath.py
r4840 r4903 263 263 Amatlam = Amat*(1.+np.eye(Amat.shape[0])*lam) 264 264 try: 265 Nzeros = 1 265 266 Ainv,Nzeros = pinv(Amatlam,xtol) # MoorePenrose SVD inversion 266 267 except nl.LinAlgError: … … 412 413 psing = list(np.where(np.abs(np.diag(nl.qr(Amat)[1])) < 1.e14)[0]) 413 414 if not len(psing): # make sure at least the worst term is flagged 415 d = np.abs(np.diag(nl.qr(Amat)[1])) 414 416 psing = [np.argmin(d)] 415 417 Amat, indices, Yvec = dropTerms(psing, Amat, indices, Yvec) 
trunk/GSASIIplot.py
r4895 r4903 3591 3591 CalcLine = Plot.plot(X,Z/ymax,colors[1],picker=False,label=incCptn('calc')) #Ic 3592 3592 else: 3593 Plot.plot(X,YB,color=colors[0],mar ler=pP,3593 Plot.plot(X,YB,color=colors[0],marker=pP, 3594 3594 picker=True,pickradius=3.,clip_on=Clip_on,label=incCptn('obs')) 3595 3595 Plot.plot(X,ZB,colors[2],picker=False,label=incCptn('calc')) … … 7335 7335 if (0 <= xpix < sizexy[0]) and (0 <= ypix < sizexy[1]): 7336 7336 Int = G2frame.ImageZ[ypix][xpix] 7337 tth,azm,D,dsp = G2img.GetTthAzmDsp (xpos,ypos,Data)7337 tth,azm,D,dsp = G2img.GetTthAzmDsp2(xpos,ypos,Data) 7338 7338 Q = 2.*math.pi/dsp 7339 7339 if G2frame.StrainKey: … … 7434 7434 xpos = event.xdata 7435 7435 ypos = event.ydata 7436 tth,azm,D,dsp = G2img.GetTthAzmDsp (xpos,ypos,Data)7436 tth,azm,D,dsp = G2img.GetTthAzmDsp2(xpos,ypos,Data) 7437 7437 G2frame.calibDmin.SetValue(dsp) 7438 7438 elif event.key in ['x',]: … … 7479 7479 # for now ignore the movement until it moves back in 7480 7480 return 7481 tth,azm,D,dsp = G2img.GetTthAzmDsp (event.xdata,event.ydata,Data)7481 tth,azm,D,dsp = G2img.GetTthAzmDsp2(event.xdata,event.ydata,Data) 7482 7482 itemPicked = str(G2frame.itemPicked) 7483 7483 if 'Itth' in itemPicked: … … 7613 7613 itemNum = G2frame.itemPicked.itemNumber 7614 7614 tth,azm,thick = Masks['Arcs'][itemNum] 7615 tthN,azmN,D,dsp = G2img.GetTthAzmDsp (Xpos,Ypos,Data)7615 tthN,azmN,D,dsp = G2img.GetTthAzmDsp2(Xpos,Ypos,Data) 7616 7616 if event.button == 1: 7617 7617 if pickType == 'ArcInner': … … 7922 7922 if not Xpos or not Ypos or Page.toolbar.AnyActive(): #got point out of frame or zoom/pan selected 7923 7923 return 7924 tth,azm,dsp = G2img.GetTthAzmDsp (Xpos,Ypos,Data)[:3]7924 tth,azm,dsp = G2img.GetTthAzmDsp2(Xpos,Ypos,Data)[:3] 7925 7925 itemPicked = str(G2frame.itemPicked) 7926 7926 try:
Note: See TracChangeset
for help on using the changeset viewer.