Changeset 1327 for trunk/GSASIIsasd.py


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

Better error trapping for SASD fitting LS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.