Changeset 2695 for trunk/GSASIIpwdGUI.py


Ignore:
Timestamp:
Feb 8, 2017 12:31:24 PM (5 years ago)
Author:
vondreele
Message:

use min(intensity) as default for PDF Flat Bkg - gives better start for optimize PDF
refactor sequential refinements so that old results are updated (not erased)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r2694 r2695  
    521521       
    522522    def OnSeqPeakFit(event):
    523         hst = G2frame.PatternTree.GetItemText(G2frame.PatternId)
    524         histList = GetHistsLikeSelected(G2frame)
    525         if not histList:
    526             G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame)
    527             return
    528         sel = []
     523        histList = G2gd.GetPatternTreeDataNames(G2frame,['PWDR',])
    529524        dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Sequential peak fits',
    530525             'Select dataset to include',histList)
    531         dlg.SetSelections(sel)
    532526        names = []
    533527        if dlg.ShowModal() == wx.ID_OK:
     
    537531        if not names:
    538532            return
    539         SeqResult = {}
     533        Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential peak fit results')
     534        if Id:
     535            SeqResult = G2frame.PatternTree.GetItemPyData(Id)
     536        else:
     537            SeqResult = {}
     538            Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential peak fit results')
     539            G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    540540        Reverse = False
    541541        CopyForward = False
     
    558558        FitPgm = 'LSQ'
    559559        prevVaryList = []
    560         Names = []
    561560        peaks = None
    562561        varyList = None
     
    579578                inst,inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Instrument Parameters'))
    580579                data = G2frame.PatternTree.GetItemPyData(PatternId)[1]
    581                 dlg2 = wx.ProgressDialog('Residual','Peak fit Rwp = ',101.0,
    582                     style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME|wx.PD_CAN_ABORT)
    583                 screenSize = wx.ClientDisplayRect()
    584                 Size = dlg.GetSize()
    585                 if 50 < Size[0] < 500: # sanity check on size, since this fails w/Win & wx3.0
    586                     dlg2.SetSize((int(Size[0]*1.2),Size[1])) # increase size a bit along x
    587                     dlg2.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
    588                 try:
    589                     peaks['sigDict'],result,sig,Rvals,varyList,parmDict,fullvaryList,badVary = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],
    590                         background,limits,inst,inst2,data,prevVaryList,oneCycle,controls,dlg2)
    591                 finally:
    592                     dlg2.Destroy()
     580                peaks['sigDict'],result,sig,Rvals,varyList,parmDict,fullvaryList,badVary = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],
     581                    background,limits,inst,inst2,data,prevVaryList,oneCycle,controls)
    593582                if len(result[0]) != len(fullvaryList):
    594583                    dlg.Destroy()
     
    596585                    break
    597586                else:
    598                     Names.append(name)   
    599587                    G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'),copy.deepcopy(peaks))
    600588                    SeqResult[name] = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals,
     
    604592        finally:
    605593            dlg.Destroy()
    606         if Reverse:
    607             Names.reverse()
    608         SeqResult['histNames'] = Names
    609         Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential peak fit results')
    610         if Id:
    611             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    612             G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    613         else:
    614             Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential peak fit results')
    615             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
     594        SeqResult['histNames'] = histList
     595        G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    616596        G2frame.PatternTree.SelectItem(Id)
    617597       
     
    40424022    def OnFitModelAll(event):
    40434023        choices = G2gd.GetPatternTreeDataNames(G2frame,['SASD',])
    4044         sel = []
    40454024        dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Sequential SASD refinement',
    40464025             'Select dataset to include',choices)
    4047         dlg.SetSelections(sel)
    40484026        names = []
    40494027        if dlg.ShowModal() == wx.ID_OK:
    40504028            for sel in dlg.GetSelections():
    40514029                names.append(choices[sel])
     4030            Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential SASD results')
     4031            if Id:
     4032                SeqResult = G2frame.PatternTree.GetItemPyData(Id)
     4033            else:
     4034                SeqResult = {}
     4035                Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential SASD results')
     4036                G2frame.PatternTree.SetItemPyData(Id,SeqResult)
     4037            SeqResult['histNames'] = choices
     4038        else:
     4039            dlg.Destroy()
     4040            return
    40524041        dlg.Destroy()
    4053         SeqResult = {}
    40544042        Reverse = False
    40554043        CopyForward = False
     
    41024090        finally:
    41034091            wx.EndBusyCursor()   
    4104         if Reverse:
    4105             names.reverse()
    4106         SeqResult['histNames'] = names
    4107         Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential SASD results')
    4108         if Id:
    4109             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    4110             G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    4111         else:
    4112             Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential SASD results')
    4113             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    41144092        G2frame.PatternTree.SelectItem(Id)
    41154093       
     
    53425320       
    53435321        atms = ','.join(data['ElList'].keys())
    5344         colLabels = ['position','magnitude','sig','refine','Atom A','Atom B','Cooord. No.']
     5322        colLabels = ['position','magnitude','sig','refine','Atom A','Atom B','Bond No.']
    53455323        Types = 3*[wg.GRID_VALUE_FLOAT+':10,3',]+[wg.GRID_VALUE_CHOICE+': ,P,M,S,PM,PS,MS,PMS',]+     \
    53465324            2*[wg.GRID_VALUE_CHOICE+':'+atms,]+[wg.GRID_VALUE_FLOAT+':10,3',]
     
    53985376        try:
    53995377            if dlg.ShowModal() == wx.ID_OK:
    5400                 SeqResult = {}
     5378                Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential PDF peak fit results')
     5379                if Id:
     5380                    SeqResult = G2frame.PatternTree.GetItemPyData(Id)
     5381                else:
     5382                    SeqResult = {}
     5383                    Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential PDF peak fit results')
     5384                    G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    54015385                items = dlg.GetSelections()
    54025386                G2frame.EnablePlot = False
    5403                 names = []
    54045387                for item in items:
    54055388                    name = Names[item]
    5406                     names.append(name)
    54075389                    pId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name)
    54085390                    data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,pId, 'PDF Controls'))
     
    54125394                        'covMatrix':np.eye(len(varyList)),'title':name,'parmDict':parmDict}
    54135395                    G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,pId, 'PDF Peaks'),newpeaks)
    5414                 SeqResult['histNames'] = names
    5415                 Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential PDF peak fit results')
    5416                 if Id:
    5417                     G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    5418                     G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    5419                 else:
    5420                     Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential PDF peak fit results')
    5421                     G2frame.PatternTree.SetItemPyData(Id,SeqResult)
     5396                SeqResult['histNames'] = Names
     5397                G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    54225398        finally:
    54235399            dlg.Destroy()
    54245400        G2plt.PlotISFG(G2frame,data,peaks=newpeaks,newPlot=False)
    5425         wx.CallAfter(UpdatePDFPeaks,G2frame,newpeaks,data)
     5401        G2frame.PatternTree.SelectItem(Id)
    54265402        print 'All PDFs peak fitted - results in Sequential PDF peak fit results'
    54275403       
Note: See TracChangeset for help on using the changeset viewer.