Changeset 5254
- Timestamp:
- Mar 29, 2022 3:39:01 PM (12 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r5245 r5254 6318 6318 self.PostfillDataMenu() 6319 6319 6320 # SASD & REFD / Limits 6321 G2G.Define_wxId('wxID_SASDLIMITCOPY', ) 6322 self.SASDLimitMenu = wx.MenuBar() 6323 self.PrefillDataMenu(self.SASDLimitMenu) 6324 self.SASDLimitEdit = wx.Menu(title='') 6325 self.SASDLimitMenu.Append(menu=self.SASDLimitEdit, title='Edit Limits') 6326 self.SASDLimitEdit.Append(G2G.wxID_SASDLIMITCOPY,'Copy','Copy limits to other histograms') 6327 self.PostfillDataMenu() 6328 6320 6329 # SASD / Instrument Parameters 6321 6330 G2G.Define_wxId('wxID_SASDINSTCOPY',) -
trunk/GSASIIimage.py
r5175 r5254 596 596 return np.array([tth,azm,G,dsp]) 597 597 598 #def GetTthAzmDsp(x,y,data): #expensive599 #'''Computes a 2theta, etc. from a detector position and calibration constants - checked600 #OK for ellipses & hyperbola.601 602 #:returns: np.array(tth,azm,G,dsp) where tth is 2theta, azm is the azimutal angle,603 #G is ? and dsp is the d-space604 #'''605 606 #def costth(xyz):607 #u = xyz/nl.norm(xyz,axis=-1)[:,:,nxs]608 #return np.dot(u,np.array([0.,0.,1.]))598 def GetTthAzmDsp(x,y,data): #expensive 599 '''Computes a 2theta, etc. from a detector position and calibration constants - checked 600 OK for ellipses & hyperbola. 601 602 :returns: np.array(tth,azm,G,dsp) where tth is 2theta, azm is the azimutal angle, 603 G is ? and dsp is the d-space 604 ''' 605 606 def costth(xyz): 607 u = xyz/nl.norm(xyz,axis=-1)[:,:,nxs] 608 return np.dot(u,np.array([0.,0.,1.])) 609 609 610 # #zero detector 2-theta: tested with tilted images - perfect integrations611 #wave = data['wavelength']612 #dx = x-data['center'][0]613 #dy = y-data['center'][1]614 #tilt = data['tilt']615 #dist = data['distance']/npcosd(tilt) #sample-beam intersection point616 #T = makeMat(tilt,0)617 #R = makeMat(data['rotation'],2)618 #MN = np.inner(R,np.inner(R,T))619 #dxyz0 = np.inner(np.dstack([dx,dy,np.zeros_like(dx)]),MN) #correct for 45 deg tilt620 #dxyz0 += np.array([0.,0.,dist])621 #if data['DetDepth']:622 #ctth0 = costth(dxyz0)623 #tth0 = npacosd(ctth0)624 #dzp = peneCorr(tth0,data['DetDepth'],dist)625 #dxyz0[:,:,2] += dzp626 # #non zero detector 2-theta:627 #if data['det2theta']:628 #tthMat = makeMat(data['det2theta'],1)629 #dxyz = np.inner(dxyz0,tthMat.T)630 #else:631 #dxyz = dxyz0632 #ctth = costth(dxyz)633 #tth = npacosd(ctth)634 #dsp = wave/(2.*npsind(tth/2.))635 #azm = (npatan2d(dxyz[:,:,1],dxyz[:,:,0])+data['azmthOff']+720.)%360.636 # #G-calculation637 #x0 = data['distance']*nptand(tilt)638 #x0x = x0*npcosd(data['rotation'])639 #x0y = x0*npsind(data['rotation'])640 #distsq = data['distance']**2641 #G = ((dx-x0x)**2+(dy-x0y)**2+distsq)/distsq #for geometric correction = 1/cos(2theta)^2 if tilt=0.642 #return [tth,azm,G,dsp]610 #zero detector 2-theta: tested with tilted images - perfect integrations 611 wave = data['wavelength'] 612 dx = x-data['center'][0] 613 dy = y-data['center'][1] 614 tilt = data['tilt'] 615 dist = data['distance']/npcosd(tilt) #sample-beam intersection point 616 T = makeMat(tilt,0) 617 R = makeMat(data['rotation'],2) 618 MN = np.inner(R,np.inner(R,T)) 619 dxyz0 = np.inner(np.dstack([dx,dy,np.zeros_like(dx)]),MN) #correct for 45 deg tilt 620 dxyz0 += np.array([0.,0.,dist]) 621 if data['DetDepth']: 622 ctth0 = costth(dxyz0) 623 tth0 = npacosd(ctth0) 624 dzp = peneCorr(tth0,data['DetDepth'],dist) 625 dxyz0[:,:,2] += dzp 626 #non zero detector 2-theta: 627 if data['det2theta']: 628 tthMat = makeMat(data['det2theta'],1) 629 dxyz = np.inner(dxyz0,tthMat.T) 630 else: 631 dxyz = dxyz0 632 ctth = costth(dxyz) 633 tth = npacosd(ctth) 634 dsp = wave/(2.*npsind(tth/2.)) 635 azm = (npatan2d(dxyz[:,:,1],dxyz[:,:,0])+data['azmthOff']+720.)%360. 636 # G-calculation 637 x0 = data['distance']*nptand(tilt) 638 x0x = x0*npcosd(data['rotation']) 639 x0y = x0*npsind(data['rotation']) 640 distsq = data['distance']**2 641 G = ((dx-x0x)**2+(dy-x0y)**2+distsq)/distsq #for geometric correction = 1/cos(2theta)^2 if tilt=0. 642 return [tth,azm,G,dsp] 643 643 644 644 def GetTth(x,y,data): 645 645 'Give 2-theta value for detector x,y position; calibration info in data' 646 return GetTthAzmDsp2(x,y,data)[0] 646 if data['det2theta']: 647 return GetTthAzmDsp(x,y,data)[0] 648 else: 649 return GetTthAzmDsp2(x,y,data)[0] 647 650 648 651 def GetTthAzm(x,y,data): 649 652 'Give 2-theta, azimuth values for detector x,y position; calibration info in data' 650 return GetTthAzmDsp2(x,y,data)[0:2] 653 if data['det2theta']: 654 return GetTthAzmDsp(x,y,data)[0:2] 655 else: 656 return GetTthAzmDsp2(x,y,data)[0:2] 651 657 652 658 def GetTthAzmG2(x,y,data): … … 718 724 def GetDsp(x,y,data): 719 725 'Give d-spacing value for detector x,y position; calibration info in data' 720 return GetTthAzmDsp2(x,y,data)[3] 726 if data['det2theta']: 727 return GetTthAzmDsp(x,y,data)[3] 728 else: 729 return GetTthAzmDsp2(x,y,data)[3] 721 730 722 731 def GetAzm(x,y,data): 723 732 'Give azimuth value for detector x,y position; calibration info in data' 724 return GetTthAzmDsp2(x,y,data)[1] 733 if data['det2theta']: 734 return GetTthAzmDsp(x,y,data)[1] 735 else: 736 return GetTthAzmDsp2(x,y,data)[1] 725 737 726 738 def meanAzm(a,b): … … 1210 1222 nJ = jLim[1]-jLim[0] 1211 1223 TA = np.empty((4,nI,nJ)) 1212 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 1224 if data['det2theta']: 1225 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 1226 else: 1227 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 1213 1228 TA[1] = np.where(TA[1]<0,TA[1]+360,TA[1]) 1214 1229 TA[3] = G2pwd.Polarization(data['PolaVal'][0],TA[0],TA[1]-90.)[0] -
trunk/GSASIIpwdGUI.py
r5253 r5254 1811 1811 ################################################################################ 1812 1812 1813 def UpdateLimitsGrid(G2frame, data, plottype):1813 def UpdateLimitsGrid(G2frame, data,datatype): 1814 1814 '''respond to selection of PWDR Limits data tree item. 1815 1815 Allows setting of limits and excluded regions in a PWDR data set … … 1817 1817 def AfterChange(invalid,value,tc): 1818 1818 if invalid: return 1819 plottype = G2frame.GPXtree.GetItemText(G2frame.PatternId)[:4]1820 wx.CallAfter(G2plt.PlotPatterns,G2frame,newPlot=False,plotType= plottype) #unfortunately this resets the plot width1819 datatype = G2frame.GPXtree.GetItemText(G2frame.PatternId)[:4] 1820 wx.CallAfter(G2plt.PlotPatterns,G2frame,newPlot=False,plotType=datatype) #unfortunately this resets the plot width 1821 1821 1822 1822 def LimitSizer(): … … 1837 1837 item = Indx[Obj.GetId()] 1838 1838 del(data[item+2]) 1839 G2plt.PlotPatterns(G2frame,newPlot=False,plotType= plottype)1840 wx.CallAfter(UpdateLimitsGrid,G2frame,data, plottype)1839 G2plt.PlotPatterns(G2frame,newPlot=False,plotType=datatype) 1840 wx.CallAfter(UpdateLimitsGrid,G2frame,data,datatype) 1841 1841 1842 1842 Indx = {} … … 1898 1898 1899 1899 G2frame.ifGetExclude = False 1900 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.LimitMenu) 1901 #G2frame.SetLabel(G2frame.GetLabel().split('||')[0]+' || '+'Limits') 1902 G2frame.Bind(wx.EVT_MENU,OnLimitCopy,id=G2G.wxID_LIMITCOPY) 1903 G2frame.Bind(wx.EVT_MENU,OnAddExcl,id=G2G.wxID_ADDEXCLREGION) 1900 if 'P' in datatype: #powder data menu commands 1901 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.LimitMenu) 1902 G2frame.Bind(wx.EVT_MENU,OnLimitCopy,id=G2G.wxID_LIMITCOPY) 1903 G2frame.Bind(wx.EVT_MENU,OnAddExcl,id=G2G.wxID_ADDEXCLREGION) 1904 elif 'L' in datatype or 'R' in datatype: #SASD & REFD data menu commands 1905 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.SASDLimitMenu) 1906 G2frame.Bind(wx.EVT_MENU,OnLimitCopy,id=G2G.wxID_SASDLIMITCOPY) 1904 1907 Draw() 1905 1908 … … 2601 2604 #end of patch 2602 2605 if 'P' in insVal['Type']: #powder data menu commands 2606 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.LimitMenu) 2603 2607 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.InstMenu) 2604 2608 G2frame.GetStatusBar().SetStatusText('NB: Azimuth is used for polarization only',1) … … 2611 2615 G2frame.Bind(wx.EVT_MENU,OnInstFlagCopy,id=G2G.wxID_INSTFLAGCOPY) 2612 2616 G2frame.Bind(wx.EVT_MENU,OnCopy1Val,id=G2G.wxID_INST1VAL) 2613 elif 'L' in insVal['Type'] or 'R' in insVal['Type']: #SASD data menu commands2617 elif 'L' in insVal['Type'] or 'R' in insVal['Type']: #SASD & REFD data menu commands 2614 2618 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.SASDInstMenu) 2615 2619 G2frame.Bind(wx.EVT_MENU,OnInstCopy,id=G2G.wxID_SASDINSTCOPY)
Note: See TracChangeset
for help on using the changeset viewer.