Ignore:
Timestamp:
Feb 16, 2018 3:22:26 PM (5 years ago)
Author:
toby
Message:

Add plot magnification; misc plot fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3285 r3288  
    26772677        self.ifX20 = True   #use M20 /= (1+X20) in powder indexing, etc.
    26782678        self.HKL = []
    2679         self.Lines = []
     2679        self.Lines = []     # lines used for data limits & excluded regions
     2680        self.MagLines = []  # lines used for plot magnification
    26802681        self.itemPicked = None
    26812682        self.Interpolate = 'nearest'
     
    64756476            textureData = General['SH Texture']   
    64766477            if textureData['Order']:
    6477                 SHtextureSig = {}
     6478#                SHtextureSig = {}
    64786479                for name in ['omega','chi','phi']:
    64796480                    aname = pfx+'SH '+name
     
    64936494                    key = pfx+'PWLref:'+str(i)
    64946495                    refl[ik] = parmDict[key]
    6495                     if key in sigDict:
    6496                         refl[ik+1] = sigDict[key]
    6497                     else:
    6498                         refl[ik+1] = 0
     6496#                    if key in sigDict:  #TODO: error here sigDict not defined. What was intended
     6497#                        refl[ik+1] = sigDict[key]
     6498#                    else:
     6499#                        refl[ik+1] = 0
    64996500                continue
    65006501            General['Mass'] = 0.
     
    72427243        '''
    72437244        G2pdG.CopySelectedHistItems(G2frame)
    7244            
     7245
     7246    def OnAddMag(event):
     7247        'Respond to the request to create a magnification region'
     7248        if not data[0]['Magnification']: data[0]['Magnification'] = [[None,1.0]]
     7249        data[0]['Magnification'] += [[(data[1][0][0]+data[1][0][-1])/2,2.]]
     7250        wx.CallAfter(UpdatePWHKPlot,G2frame,kind,G2frame.PatternId)
     7251    def OnDelMag(event):
     7252        'Respond to the request to delete a magnification region'
     7253        del data[0]['Magnification'][event.EventObject.row]
     7254        if len(data[0]['Magnification']) == 1: data[0]['Magnification'] = []
     7255        wx.CallAfter(UpdatePWHKPlot,G2frame,kind,G2frame.PatternId)
     7256    def OnEditMag(**args):
     7257        'Update to show edits to mag factors in window and plot'
     7258        wx.CallAfter(UpdatePWHKPlot,G2frame,kind,G2frame.PatternId)
     7259
     7260    # Start of UpdatePWHKPlot
    72457261    data = G2frame.GPXtree.GetItemPyData(item)
    72467262    #G2frame.SetLabel(G2frame.GetLabel().split('||')[0]+' || '+G2frame.GPXtree.GetItemText(item))
     
    73347350                        u' Unweighted phase residuals RF\u00b2: %.3f%%, RF: %.3f%% on %d reflections  '% \
    73357351                        (data[0][pfx+'Rf^2'],data[0][pfx+'Rf'],data[0][value])))
    7336                
    7337                    
     7352
     7353    # Draw edit box for Magnification factors/positions
     7354    if kind == 'PWDR':
     7355        if 'Magnification' not in data[0]:
     7356            data[0]['Magnification'] = []
     7357        mainSizer.Add((-1,10))
     7358        lenmag = len(data[0]['Magnification'])
     7359        data[0]['Magnification'].sort(key=lambda x: x[0])
     7360        if lenmag > 1:
     7361            panel = wx.StaticBox(G2frame.dataWindow, wx.ID_ANY, 'Magnification regions',
     7362                                 style=wx.ALIGN_CENTER)
     7363            mSizer = wx.StaticBoxSizer(panel,wx.VERTICAL)
     7364            magSizer = wx.FlexGridSizer(lenmag+1,3,0,0)
     7365            Name = G2frame.GPXtree.GetItemText(G2frame.PatternId)
     7366            Inst = G2frame.GPXtree.GetItemPyData(GetGPXtreeItemId(G2frame,
     7367                G2frame.PatternId,'Instrument Parameters'))
     7368            if 'C' in Inst[0]['Type'][0]:
     7369                magSizer.Add(wx.StaticText(panel,-1,'2Theta'
     7370                                       ),1,wx.ALIGN_CENTER,1)
     7371            else:
     7372                magSizer.Add(wx.StaticText(panel,-1,'TOF'
     7373                                       ),1,wx.ALIGN_CENTER,1)
     7374            magSizer.Add(wx.StaticText(panel,-1,'Magnification\nfactor',
     7375                                       style=wx.ALIGN_CENTRE_HORIZONTAL),1,wx.ALIGN_CENTER,1)
     7376            magSizer.Add(wx.StaticText(panel,-1,'Delete\nbutton',
     7377                                       style=wx.ALIGN_CENTRE_HORIZONTAL
     7378                                       ),1,wx.ALIGN_CENTER,1)
     7379            magSizer.Add(wx.StaticText(panel,-1,'(start)'),1,wx.ALIGN_CENTER,1)
     7380            edit = G2G.ValidatedTxtCtrl(panel,data[0]['Magnification'][0],1,
     7381                                            nDig=(7,2),
     7382                                            min=0.01,max=1000.,
     7383                                            OnLeave=OnEditMag,size=(65,-1))
     7384            magSizer.Add(edit,1,wx.ALIGN_CENTER,5)
     7385            magSizer.Add((1,1))
     7386            for i in range(1,lenmag):
     7387                edit = G2G.ValidatedTxtCtrl(panel,data[0]['Magnification'][i],0,
     7388                                            nDig=(10,3),
     7389                                            min=data[1][0][0],max=data[1][0][-1],
     7390                                            OnLeave=OnEditMag)
     7391                magSizer.Add(edit)
     7392                edit = G2G.ValidatedTxtCtrl(panel,data[0]['Magnification'][i],1,
     7393                                            nDig=(7,2),
     7394                                            min=0.01,max=1000.,
     7395                                            OnLeave=OnEditMag,size=(65,-1))
     7396                magSizer.Add(edit,1,wx.ALIGN_CENTER,5)
     7397                delmag = wx.Button(panel,wx.ID_ANY,label='Del',size=(40,-1))
     7398                delmag.Bind(wx.EVT_BUTTON,OnDelMag)
     7399                delmag.row = i
     7400                magSizer.Add(delmag,1,wx.ALIGN_CENTER,5)
     7401            mSizer.Add(magSizer)
     7402        else:
     7403            panel = G2frame.dataWindow
     7404            mSizer = wx.BoxSizer(wx.VERTICAL)
     7405        addmag = wx.Button(panel,wx.ID_ANY,label='Add a magnification region')
     7406        addmag.Bind(wx.EVT_BUTTON,OnAddMag)
     7407        mSizer.Add(addmag,1,wx.ALIGN_CENTER,1)
     7408        mainSizer.Add(mSizer)
     7409
    73387410    G2frame.GPXtree.SetItemPyData(item,data)
    73397411    G2frame.PatternId = item
Note: See TracChangeset for help on using the changeset viewer.