Changeset 1327


Ignore:
Timestamp:
May 6, 2014 9:23:56 AM (8 years ago)
Author:
vondreele
Message:

Better error trapping for SASD fitting LS.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r1323 r1327  
    27932793                IInst = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Instrument Parameters'))
    27942794#                ISubstances = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Substances'))
    2795                 IfOK,result,varyList,sig,Rvals,covMatrix = G2sasd.ModelFit(IProfile,IProfDict,ILimits,ISample,IModel)
     2795                IfOK,result,varyList,sig,Rvals,covMatrix,Msg = G2sasd.ModelFit(IProfile,IProfDict,ILimits,ISample,IModel)
    27962796                if not IfOK:
    27972797                    G2frame.ErrorDialog('Failed sequential refinement for data '+name,
    2798                         'You need to rethink your selection of parameters\n'+    \
     2798                        ' Msg: '+Msg+'\nYou need to rethink your selection of parameters\n'+    \
    27992799                        ' Model restored to previous version for'+name)
    28002800                    SeqResult['histNames'] = names[:i]
     
    28312831        elif data['Current'] == 'Particle fit':
    28322832            SaveState()
    2833             if not G2sasd.ModelFit(Profile,ProfDict,Limits,Sample,data)[0]:
    2834                 G2frame.ErrorDialog('Failed refinement',
    2835                     'You need to rethink your selection of parameters\n'+    \
    2836                     ' Model restored to previous version')
     2833            Results = G2sasd.ModelFit(Profile,ProfDict,Limits,Sample,data)
     2834            if not Results[0]:
     2835                    G2frame.ErrorDialog('Failed refinement',
     2836                        ' Msg: '+Results[-1]+'\nYou need to rethink your selection of parameters\n'+    \
     2837                        ' Model restored to previous version')
    28372838            G2sasd.ModelFxn(Profile,ProfDict,Limits,Sample,data)
    28382839            RefreshPlots(True)
  • trunk/GSASIIsasd.py

    r1319 r1327  
    12401240    Rvals['GOF'] = chisq/(Ifin-Ibeg-len(varyList))       #reduced chi^2
    12411241    Ic[Ibeg:Ifin] = getSASD(Q[Ibeg:Ifin],levelTypes,parmDict)
     1242    Msg = 'Failed to converge'
    12421243    try:
     1244        Nans = np.isnan(result[0])
     1245        if np.any(Nans):
     1246            name = varyList[Nans.nonzero(True)[0]]
     1247            Msg = 'Nan result for '+name+'!'
     1248            raise ValueError
     1249        Negs = np.less_equal(result[0],0.)
     1250        if np.any(Negs):
     1251            name = varyList[Negs.nonzero(True)[0]]
     1252            Msg = 'negative coefficient for '+name+'!'
     1253            raise ValueError
    12431254        if len(covM):
    12441255            sig = np.sqrt(np.diag(covM)*Rvals['GOF'])
     
    12491260        SetModelParms()
    12501261        covMatrix = covM*Rvals['GOF']
    1251         return True,result,varyList,sig,Rvals,covMatrix
     1262        return True,result,varyList,sig,Rvals,covMatrix,''
    12521263    except (ValueError,TypeError):      #when bad LS refinement; covM missing or with nans
    1253         return False,0,0,0,0,0
     1264        return False,0,0,0,0,0,Msg
    12541265   
    12551266def ModelFxn(Profile,ProfDict,Limits,Sample,sasdData):
Note: See TracChangeset for help on using the changeset viewer.