Ignore:
Timestamp:
Sep 12, 2017 10:54:45 AM (4 years ago)
Author:
vondreele
Message:

fix parameter display to show nan (crashed before)
trap with error if any parameter is nan
skip postprocessing for failed refinements (IfOK=False)
fix Jacobian to use GetProfileDervMP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrMain.py

    r3049 r3068  
    5454        begin = time.time()
    5555        values =  np.array(G2stMth.Dict2Values(parmDict, varyList))
     56        if np.any(np.isnan(values)):
     57            raise G2obj.G2Exception('ERROR - nan found in LS parameters - use Calculate/View LS parms to locate')
    5658        # test code to compute GOF and save for external repeat
    5759        #args = ([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg)
     
    135137                        del(varyList[ipvt-1])
    136138                        break
    137     G2stMth.GetFobsSq(Histograms,Phases,parmDict,calcControls)
     139    if IfOK:
     140        G2stMth.GetFobsSq(Histograms,Phases,parmDict,calcControls)
    138141    return IfOK,Rvals,result,covMatrix,sig
    139142
     
    212215        IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histograms,Phases,restraintDict,
    213216            rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifPrint,printFile,dlg)
    214         sigDict = dict(zip(varyList,sig))
    215         newCellDict = G2stMth.GetNewCellParms(parmDict,varyList)
    216         newAtomDict = G2stMth.ApplyXYZshifts(parmDict,varyList)
    217         covData = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals,
    218                    'varyListStart':varyListStart,
    219                    'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict,
    220                    'newCellDict':newCellDict,'freshCOV':True}
    221         # add the uncertainties into the esd dictionary (sigDict)
    222         sigDict.update(G2mv.ComputeDepESD(covMatrix,varyList,parmDict))
    223         G2mv.PrintIndependentVars(parmDict,varyList,sigDict,pFile=printFile)
    224         G2stMth.ApplyRBModels(parmDict,Phases,rigidbodyDict,True)
    225         G2stIO.SetRigidBodyModels(parmDict,sigDict,rigidbodyDict,printFile)
    226         G2stIO.SetPhaseData(parmDict,sigDict,Phases,rbIds,covData,restraintDict,printFile)
    227         G2stIO.SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms,calcControls['FFtables'],pFile=printFile)
    228         G2stIO.SetHistogramData(parmDict,sigDict,Histograms,calcControls['FFtables'],pFile=printFile)
    229         G2stIO.SetUsedHistogramsAndPhases(GPXfile,Histograms,Phases,rigidbodyDict,covData,makeBack)
    230         printFile.close()
    231         print ' Refinement results are in file: '+ospath.splitext(GPXfile)[0]+'.lst'
    232         print ' ***** Refinement successful *****'
     217        if IfOK:
     218            sigDict = dict(zip(varyList,sig))
     219            newCellDict = G2stMth.GetNewCellParms(parmDict,varyList)
     220            newAtomDict = G2stMth.ApplyXYZshifts(parmDict,varyList)
     221            covData = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals,
     222                       'varyListStart':varyListStart,
     223                       'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict,
     224                       'newCellDict':newCellDict,'freshCOV':True}
     225            # add the uncertainties into the esd dictionary (sigDict)
     226            sigDict.update(G2mv.ComputeDepESD(covMatrix,varyList,parmDict))
     227            G2mv.PrintIndependentVars(parmDict,varyList,sigDict,pFile=printFile)
     228            G2stMth.ApplyRBModels(parmDict,Phases,rigidbodyDict,True)
     229            G2stIO.SetRigidBodyModels(parmDict,sigDict,rigidbodyDict,printFile)
     230            G2stIO.SetPhaseData(parmDict,sigDict,Phases,rbIds,covData,restraintDict,printFile)
     231            G2stIO.SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms,calcControls['FFtables'],pFile=printFile)
     232            G2stIO.SetHistogramData(parmDict,sigDict,Histograms,calcControls['FFtables'],pFile=printFile)
     233            G2stIO.SetUsedHistogramsAndPhases(GPXfile,Histograms,Phases,rigidbodyDict,covData,makeBack)
     234            printFile.close()
     235            print ' Refinement results are in file: '+ospath.splitext(GPXfile)[0]+'.lst'
     236            print ' ***** Refinement successful *****'
     237        else:
     238            print '****ERROR - Refinement failed'
     239            raise G2obj.G2Exception('****ERROR - Refinement failed')
    233240    except G2obj.G2Exception,Msg:
    234241        printFile.close()
     
    236243
    237244#for testing purposes!!!
    238     if DEBUG:
     245    if DEBUG and IfOK:
    239246#needs: values,HistoPhases,parmDict,varylist,calcControls,pawleyLookup
    240247        import cPickle
Note: See TracChangeset for help on using the changeset viewer.