Changeset 1498


Ignore:
Timestamp:
Sep 16, 2014 4:20:57 PM (7 years ago)
Author:
vondreele
Message:

try to implement drag/drop of tree items - commented out as it doesn't work
add 'ShowCell?' to Controls to avoid cell errors for sequential single peak fitting when normal sequential refinement has been done
fix a neg. peak width error

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1492 r1498  
    18661866        self.PatternTree.Bind(wx.EVT_TREE_KEY_DOWN,
    18671867            self.OnPatternTreeKeyDown, id=wxID_PATTERNTREE)
     1868#Can't get drag/drop of tree items to work except in simple cases (e.g. Controls)
     1869#        self.PatternTree.Bind(wx.EVT_TREE_BEGIN_RDRAG,
     1870#            self.OnPatternTreeBeginRDrag, id=wxID_PATTERNTREE)       
     1871#        self.PatternTree.Bind(wx.EVT_TREE_END_DRAG,
     1872#            self.OnPatternTreeEndDrag, id=wxID_PATTERNTREE)       
    18681873        self.root = self.PatternTree.AddRoot('Loaded Data: ')
    18691874       
     
    19891994        event.Skip()
    19901995       
     1996    def OnPatternTreeBeginRDrag(self,event):
     1997        # testing this - doesn't work! Binds commented out above
     1998        event.Allow()
     1999        self.BeginDragId = event.GetItem()
     2000        print 'start',self.PatternTree.GetItemText(self.BeginDragId)
     2001        self.ParentId = self.PatternTree.GetItemParent(self.BeginDragId)
     2002        self.DragData = self.PatternTree.GetItemPyData(self.BeginDragId)
     2003       
     2004    def OnPatternTreeEndDrag(self,event):
     2005        # testing this - doesn't work! Binds commented out above
     2006        event.Allow()
     2007        self.EndDragId = event.GetItem()
     2008        if self.ParentId != self.PatternTree.GetItemParent(self.EndDragId):
     2009            print 'drag not allowed - wrong parent'
     2010        else:
     2011            Name = self.PatternTree.GetItemText(self.BeginDragId)
     2012            self.PatternTree.InsertItem(self.ParentId,self.EndDragId,Name,data=None)
     2013            Id = G2gd.GetPatternTreeItemId(self, self.ParentId,Name)
     2014            self.PatternTree.SetItemPyData(Id,self.DragData)
     2015            self.PatternTree.Delete(self.BeginDragId)
     2016        print 'end',self.PatternTree.GetItemText(self.EndDragId)
     2017       
    19912018    def OnPatternTreeKeyDown(self,event):
    1992         'Not sure what this does'
     2019        'Allows stepping through the tree with the up/down arrow keys'
    19932020        key = event.GetKeyCode()
    19942021        item = self.PickId
     
    32753302            Id = self.PatternTree.AppendItem(self.root,text='Sequential results')
    32763303            self.PatternTree.SetItemPyData(Id,{})           
     3304        Controls = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,self.root, 'Controls'))
     3305        Controls['ShowCell'] = True
    32773306        self.OnFileSave(event)
    32783307        # check that constraints are OK here
  • trunk/GSASIIgrid.py

    r1496 r1498  
    29212921        self.AutoSearch = self.PeakEdit.Append(help='Automatic peak search',
    29222922            id=wxID_AUTOSEARCH, kind=wx.ITEM_NORMAL,text='Auto search')
    2923         self.PeakCopy = self.PeakEdit.Append(help='Copy peaks to other histograms',
    2924             id=wxID_PEAKSCOPY, kind=wx.ITEM_NORMAL,text='Peak copy')
    29252923        self.UnDo = self.PeakEdit.Append(help='Undo last least squares refinement',
    29262924            id=wxID_UNDO, kind=wx.ITEM_NORMAL,text='UnDo')
     
    29292927        self.PFOneCycle = self.PeakEdit.Append(id=wxID_LSQONECYCLE, kind=wx.ITEM_NORMAL,text='Peakfit one cycle',
    29302928            help='One cycle of Peak fitting' )
     2929        self.PeakEdit.Append(id=wxID_RESETSIGGAM, kind=wx.ITEM_NORMAL,
     2930            text='Reset sig and gam',help='Reset sigma and gamma to global fit' )
     2931        self.PeakCopy = self.PeakEdit.Append(help='Copy peaks to other histograms',
     2932            id=wxID_PEAKSCOPY, kind=wx.ITEM_NORMAL,text='Peak copy')
    29312933        self.SeqPeakFit = self.PeakEdit.Append(id=wxID_SEQPEAKFIT, kind=wx.ITEM_NORMAL,text='Seq PeakFit',
    29322934            help='Sequential Peak fitting for all histograms' )
    2933         wxID_PEAKSCOPY
    2934         self.PeakEdit.Append(id=wxID_RESETSIGGAM, kind=wx.ITEM_NORMAL,
    2935             text='Reset sig and gam',help='Reset sigma and gamma to global fit' )
    29362935        self.PeakEdit.Append(id=wxID_CLEARPEAKS, kind=wx.ITEM_NORMAL,text='Clear peaks',
    29372936            help='Clear the peak list' )
     
    32843283        self.TextureEdit = wx.Menu(title='')
    32853284        self.TextureMenu.Append(menu=self.TextureEdit, title='Texture')
    3286         self.TextureEdit.Append(id=wxID_REFINETEXTURE, kind=wx.ITEM_NORMAL,text='Refine texture',
    3287             help='Refine the texture coefficients from sequential Pawley results')
     3285#        self.TextureEdit.Append(id=wxID_REFINETEXTURE, kind=wx.ITEM_NORMAL,text='Refine texture',
     3286#            help='Refine the texture coefficients from sequential Pawley results')
    32883287        self.TextureEdit.Append(id=wxID_CLEARTEXTURE, kind=wx.ITEM_NORMAL,text='Clear texture',
    32893288            help='Clear the texture coefficients' )
     
    47314730        Types += [wg.GRID_VALUE_FLOAT+':10,3',]
    47324731    # add % change in Chi^2 in last cycle
    4733     if histNames[0][:4] not in ['SASD','IMG ']:
     4732    if histNames[0][:4] not in ['SASD','IMG '] and Controls['ShowCell']:
    47344733        colList += [[100.*data[name]['Rvals'].get('DelChi2',-1) for name in histNames]]
    47354734        colSigs += [None]
     
    47444743        Types += [wg.GRID_VALUE_FLOAT,]
    47454744    # add unique cell parameters
    4746     for pId in sorted(RecpCellTerms):
    4747         pfx = str(pId)+'::' # prefix for A values from phase
    4748         cells = []
    4749         cellESDs = []
    4750         colLabels += [pfx+cellUlbl[i] for i in uniqCellIndx[pId]]
    4751         colLabels += [pfx+'Vol']
    4752         Types += (1+len(uniqCellIndx[pId]))*[wg.GRID_VALUE_FLOAT,]
    4753         for name in histNames:
    4754             covData = {
    4755                 'varyList': [Dlookup.get(striphist(v),v) for v in data[name]['varyList']],
    4756                 'covMatrix': data[name]['covMatrix']
    4757                 }
    4758             A = RecpCellTerms[pId][:] # make copy of starting A values
    4759             # update with refined values
    4760             for i in range(6):
    4761                 var = str(pId)+'::A'+str(i)
    4762                 if var in ESDlookup:
    4763                     val = data[name]['newCellDict'][ESDlookup[var]][1] # get refined value
    4764                     A[i] = val # override with updated value
    4765             # apply symmetry
    4766             Albls = [pfx+'A'+str(i) for i in range(6)]
    4767             cellDict = dict(zip(Albls,A))
    4768             A,zeros = G2stIO.cellFill(pfx,SGdata[pId],cellDict,zeroDict[pId])
    4769             # convert to direct cell & add only unique values to table
    4770             c = G2lat.A2cell(A)
    4771             vol = G2lat.calc_V(A)
    4772             cE = G2stIO.getCellEsd(pfx,SGdata[pId],A,covData)
    4773             cells += [[c[i] for i in uniqCellIndx[pId]]+[vol]]
    4774             cellESDs += [[cE[i] for i in uniqCellIndx[pId]]+[cE[-1]]]
    4775         colList += zip(*cells)
    4776         colSigs += zip(*cellESDs)
     4745    if Controls['ShowCell']:
     4746        for pId in sorted(RecpCellTerms):
     4747            pfx = str(pId)+'::' # prefix for A values from phase
     4748            cells = []
     4749            cellESDs = []
     4750            colLabels += [pfx+cellUlbl[i] for i in uniqCellIndx[pId]]
     4751            colLabels += [pfx+'Vol']
     4752            Types += (1+len(uniqCellIndx[pId]))*[wg.GRID_VALUE_FLOAT,]
     4753            for name in histNames:
     4754                covData = {
     4755                    'varyList': [Dlookup.get(striphist(v),v) for v in data[name]['varyList']],
     4756                    'covMatrix': data[name]['covMatrix']
     4757                    }
     4758                A = RecpCellTerms[pId][:] # make copy of starting A values
     4759                # update with refined values
     4760                for i in range(6):
     4761                    var = str(pId)+'::A'+str(i)
     4762                    if var in ESDlookup:
     4763                        val = data[name]['newCellDict'][ESDlookup[var]][1] # get refined value
     4764                        A[i] = val # override with updated value
     4765                # apply symmetry
     4766                Albls = [pfx+'A'+str(i) for i in range(6)]
     4767                cellDict = dict(zip(Albls,A))
     4768                A,zeros = G2stIO.cellFill(pfx,SGdata[pId],cellDict,zeroDict[pId])
     4769                # convert to direct cell & add only unique values to table
     4770                c = G2lat.A2cell(A)
     4771                vol = G2lat.calc_V(A)
     4772                cE = G2stIO.getCellEsd(pfx,SGdata[pId],A,covData)
     4773                cells += [[c[i] for i in uniqCellIndx[pId]]+[vol]]
     4774                cellESDs += [[cE[i] for i in uniqCellIndx[pId]]+[cE[-1]]]
     4775            colList += zip(*cells)
     4776            colSigs += zip(*cellESDs)
    47774777    # add the variables that were refined; change from rows to columns
    47784778    colList += zip(*[data[name]['variables'] for name in histNames])
     
    48234823            G2mv.InitVars()
    48244824            parmDict = data[name].get('parmDict')
    4825             if parmDict:
     4825            if parmDict and Controls['ShowCell']:
    48264826                constraintInfo = data[name].get('constraintInfo',[[],[],{},[],seqnum])
    48274827                groups,parmlist,constrDict,fixedList,ihst = constraintInfo
     
    51595159            data = G2frame.PatternTree.GetItemPyData(item)
    51605160            UpdateSeqResults(G2frame,data)
    5161         elif G2frame.PatternTree.GetItemText(item) == 'Small Angle Sequential results':
    5162             data = G2frame.PatternTree.GetItemPyData(item)
    5163             UpdateSASDSeqResults(G2frame,data)
    51645161        elif G2frame.PatternTree.GetItemText(item) == 'Covariance':
    51655162            data = G2frame.PatternTree.GetItemPyData(item)
  • trunk/GSASIIpwdGUI.py

    r1496 r1498  
    407407        dlg.Destroy()
    408408        SeqResult = {'histNames':names}
     409        Reverse = False
     410        CopyForward = False
     411        choice = ['Copy from prev.',]       #'Reverse sequence',
     412        dlg = wx.MultiChoiceDialog(G2frame.dataFrame,'Sequential controls','Select controls',choice)
     413        if dlg.ShowModal() == wx.ID_OK:
     414            for sel in dlg.GetSelections():
     415                if sel:
     416                    CopyForward = True
     417                else:
     418                    Reverse = True
    409419        dlg.Destroy()
    410420        dlg = wx.ProgressDialog('Sequential peak fit','Data set name = '+names[0],len(names),
    411421            style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME|wx.PD_CAN_ABORT)
     422        Controls = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls'))
    412423        controls = {'deriv type':'analytic','min dM/M':0.0001,}
     424        Controls['ShowCell'] = False
    413425        print 'Peak Fitting with '+controls['deriv type']+' derivatives:'
    414426        oneCycle = False
     
    421433                    break
    422434                PatternId =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name)
     435                if i and CopyForward:
     436                    G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'),peaks)
    423437                peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'))
    424438                background = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Background'))
     
    444458                print ' ***** Sequential peak fit successful *****'
    445459        finally:
    446             wx.EndBusyCursor()   
     460            wx.EndBusyCursor()
    447461        Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential results')
    448462        if Id:
  • trunk/GSASIIstrMath.py

    r1496 r1498  
    15311531                        iFin = max(xB,min(np.searchsorted(x,refl[5]+fmax),xF))
    15321532                        iFin2 = iFin
    1533                         yp[iBeg:iFin] = refl[11]*refl[9]*G2pwd.getFCJVoigt3(refl[5],refl[6],refl[7],shl,ma.getdata(x[iBeg:iFin]))    #>90% of time spent here
    1534                         if Ka2:
    1535                             pos2 = refl[5]+lamRatio*tand(refl[5]/2.0)       # + 360/pi * Dlam/lam * tan(th)
    1536                             Wd,fmin,fmax = G2pwd.getWidthsCW(pos2,refl[6],refl[7],shl)
    1537                             iBeg2 = max(xB,np.searchsorted(x,pos2-fmin))
    1538                             iFin2 = min(np.searchsorted(x,pos2+fmax),xF)
    1539                             if not iBeg2+iFin2:       #peak below low limit - skip peak
    1540                                 continue
    1541                             elif not iBeg2-iFin2:     #peak above high limit - done
    1542                                 break
    1543                             yp[iBeg2:iFin2] += refl[11]*refl[9]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6],refl[7],shl,ma.getdata(x[iBeg2:iFin2]))        #and here
    1544                         refl[8] = np.sum(np.where(ratio[iBeg:iFin2]>0.,yp[iBeg:iFin2]*ratio[iBeg:iFin2]/(refl[11]*(1.+kRatio)),0.0))
     1533                        if not iBeg+iFin:       #peak below low limit - skip peak
     1534                            continue
     1535                        elif not iBeg-iFin:     #peak above high limit - done
     1536                            break
     1537                        elif iBeg < iFin:
     1538                            yp[iBeg:iFin] = refl[11]*refl[9]*G2pwd.getFCJVoigt3(refl[5],refl[6],refl[7],shl,ma.getdata(x[iBeg:iFin]))    #>90% of time spent here
     1539                            if Ka2:
     1540                                pos2 = refl[5]+lamRatio*tand(refl[5]/2.0)       # + 360/pi * Dlam/lam * tan(th)
     1541                                Wd,fmin,fmax = G2pwd.getWidthsCW(pos2,refl[6],refl[7],shl)
     1542                                iBeg2 = max(xB,np.searchsorted(x,pos2-fmin))
     1543                                iFin2 = min(np.searchsorted(x,pos2+fmax),xF)
     1544                                yp[iBeg2:iFin2] += refl[11]*refl[9]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6],refl[7],shl,ma.getdata(x[iBeg2:iFin2]))        #and here
     1545                            refl[8] = np.sum(np.where(ratio[iBeg:iFin2]>0.,yp[iBeg:iFin2]*ratio[iBeg:iFin2]/(refl[11]*(1.+kRatio)),0.0))
    15451546                    elif 'T' in calcControls[hfx+'histType']:
    15461547                        yp = np.zeros_like(yb)
Note: See TracChangeset for help on using the changeset viewer.