Ignore:
Timestamp:
Apr 21, 2019 10:05:23 PM (3 years ago)
Author:
toby
Message:

Update Rietveld cycle-by-cycle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrMain.py

    r3855 r3913  
    4848
    4949def RefineCore(Controls,Histograms,Phases,restraintDict,rigidbodyDict,parmDict,varyList,
    50     calcControls,pawleyLookup,ifSeq,printFile,dlg):
     50    calcControls,pawleyLookup,ifSeq,printFile,dlg,refPlotUpdate=None):
    5151    '''Core optimization routines, shared between SeqRefine and Refine
    5252
     
    8080                args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
    8181            ncyc = int(result[2]['nfev']/2)
     82            if refPlotUpdate is not None: refPlotUpdate(Histograms)   # update plot after completion
    8283        elif 'analytic Hessian' in Controls['deriv type']:
    8384            Lamda = Controls.get('Marquardt',-3)
    8485            maxCyc = Controls['max cyc']
    8586            result = G2mth.HessianLSQ(G2stMth.errRefine,values,Hess=G2stMth.HessRefine,ftol=Ftol,xtol=Xtol,maxcyc=maxCyc,Print=ifPrint,lamda=Lamda,
    86                 args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
     87                args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg),
     88                refPlotUpdate=refPlotUpdate)
    8789            ncyc = result[2]['num cyc']+1
    8890            Rvals['lamMax'] = result[2]['lamMax']
     
    9193            maxCyc = Controls['max cyc']
    9294            result = G2mth.HessianSVD(G2stMth.errRefine,values,Hess=G2stMth.HessRefine,ftol=Ftol,xtol=Xtol,maxcyc=maxCyc,Print=ifPrint,
    93                 args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg))
     95                args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg),
     96                refPlotUpdate=refPlotUpdate)
    9497            if result[1] is None:
    9598                IfOK = False
     
    104107            if len(varyList):
    105108                ncyc = int(result[2]['nfev']/len(varyList))
     109            if refPlotUpdate is not None: refPlotUpdate(Histograms)   # update plot
    106110#        table = dict(zip(varyList,zip(values,result[0],(result[0]-values))))
    107111#        for item in table: print item,table[item]               #useful debug - are things shifting?
     
    173177    return IfOK,Rvals,result,covMatrix,sig
    174178
    175 def Refine(GPXfile,dlg=None,makeBack=True):
     179def Refine(GPXfile,dlg=None,makeBack=True,refPlotUpdate=None):
    176180    'Global refinement -- refines to minimize against all histograms'
    177181    import GSASIImpsubs as G2mp
     
    249253        covData = {}
    250254        IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histograms,Phases,restraintDict,
    251             rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg)
     255            rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg,
     256            refPlotUpdate=refPlotUpdate)
    252257        if IfOK:
    253258            sigDict = dict(zip(varyList,sig))
     
    315320    return NewVary
    316321
    317 def SeqRefine(GPXfile,dlg,PlotFunction=None,G2frame=None):
     322def SeqRefine(GPXfile,dlg,refPlotUpdate=None):
    318323    '''Perform a sequential refinement -- cycles through all selected histgrams,
    319324    one at a time
     
    480485#        try:
    481486            IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histo,Phases,restraintDict,
    482                 rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg)
    483             if PlotFunction:
    484                 PlotFunction(G2frame,Histo[histogram]['Data'],histogram)
     487                rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg,
     488                refPlotUpdate=refPlotUpdate)
    485489            print ('  wR = %7.2f%%, chi**2 = %12.6g, reduced chi**2 = %6.2f, last delta chi = %.4f'%(
    486490                Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']**2,Rvals['DelChi2']))
Note: See TracChangeset for help on using the changeset viewer.