Changeset 5254


Ignore:
Timestamp:
Mar 29, 2022 3:39:01 PM (12 months ago)
Author:
vondreele
Message:

fix image integration for 2-theta stepped images
fix issues with unnecessary menu items for SASD/REFD data types

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r5245 r5254  
    63186318        self.PostfillDataMenu()
    63196319       
     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           
    63206329        # SASD / Instrument Parameters
    63216330        G2G.Define_wxId('wxID_SASDINSTCOPY',)
  • trunk/GSASIIimage.py

    r5175 r5254  
    596596    return np.array([tth,azm,G,dsp])
    597597   
    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.]))
     598def 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.]))
    609609       
    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]
     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]
    643643   
    644644def GetTth(x,y,data):
    645645    '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]
    647650   
    648651def GetTthAzm(x,y,data):
    649652    '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]
    651657   
    652658def GetTthAzmG2(x,y,data):
     
    718724def GetDsp(x,y,data):
    719725    '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]
    721730       
    722731def GetAzm(x,y,data):
    723732    '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]
    725737   
    726738def meanAzm(a,b):
     
    12101222    nJ = jLim[1]-jLim[0]
    12111223    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
    12131228    TA[1] = np.where(TA[1]<0,TA[1]+360,TA[1])
    12141229    TA[3] = G2pwd.Polarization(data['PolaVal'][0],TA[0],TA[1]-90.)[0]
  • trunk/GSASIIpwdGUI.py

    r5253 r5254  
    18111811################################################################################           
    18121812       
    1813 def UpdateLimitsGrid(G2frame, data,plottype):
     1813def UpdateLimitsGrid(G2frame, data,datatype):
    18141814    '''respond to selection of PWDR Limits data tree item.
    18151815    Allows setting of limits and excluded regions in a PWDR data set
     
    18171817    def AfterChange(invalid,value,tc):
    18181818        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 width
     1819        datatype = G2frame.GPXtree.GetItemText(G2frame.PatternId)[:4]
     1820        wx.CallAfter(G2plt.PlotPatterns,G2frame,newPlot=False,plotType=datatype)  #unfortunately this resets the plot width
    18211821
    18221822    def LimitSizer():
     
    18371837            item = Indx[Obj.GetId()]
    18381838            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)
    18411841       
    18421842        Indx = {}
     
    18981898
    18991899    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)
    19041907    Draw()
    19051908   
     
    26012604    #end of patch
    26022605    if 'P' in insVal['Type']:                   #powder data menu commands
     2606        G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.LimitMenu)
    26032607        G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.InstMenu)
    26042608        G2frame.GetStatusBar().SetStatusText('NB: Azimuth is used for polarization only',1)
     
    26112615        G2frame.Bind(wx.EVT_MENU,OnInstFlagCopy,id=G2G.wxID_INSTFLAGCOPY)
    26122616        G2frame.Bind(wx.EVT_MENU,OnCopy1Val,id=G2G.wxID_INST1VAL)
    2613     elif 'L' in insVal['Type'] or 'R' in insVal['Type']:                   #SASD data menu commands
     2617    elif 'L' in insVal['Type'] or 'R' in insVal['Type']:                   #SASD & REFD data menu commands
    26142618        G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.SASDInstMenu)
    26152619        G2frame.Bind(wx.EVT_MENU,OnInstCopy,id=G2G.wxID_SASDINSTCOPY)
Note: See TracChangeset for help on using the changeset viewer.