Changeset 5261


Ignore:
Timestamp:
Apr 13, 2022 2:38:43 PM (11 months ago)
Author:
toby
Message:

cleanups in peak fitting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r5253 r5261  
    10131013            if 'C' in dataType:
    10141014                ybi = pkI*getFCJVoigt3(pkP,pkS,pkG,0.002,xdata[iBeg:iFin])[0]
    1015                 yb[iBeg:iFin] += ybi
    10161015            elif 'T' in dataType:
    10171016                ybi = pkI*getEpsVoigt(pkP,1.,1.,pkS,pkG,xdata[iBeg:iFin])[0]
    1018                 yb[iBeg:iFin] += ybi
    10191017            elif 'B' in dataType:
    10201018                ybi = pkI*getEpsVoigt(pkP,1.,1.,pkS/100.,pkG/1.e4,xdata[iBeg:iFin])[0]
    1021                 yb[iBeg:iFin] += ybi
    10221019            elif 'E' in dataType:
    10231020                ybi = pkI*getPsVoigt(pkP,pkS*10.**4,pkG*100.,xdata[iBeg:iFin])[0]
    1024                 yb[iBeg:iFin] += ybi
     1021            else:
     1022                raise Exception('dataType of {:} should not happen!'.format(dataType))
     1023            yb[iBeg:iFin] += ybi
    10251024            sumBk[2] += np.sum(ybi)
    10261025            iD += 1       
     
    20652064    lnames = ['position','intensity']
    20662065    if FitPgm == 'LaueFringe':
    2067         names += ['sig','gam','cells']
    2068         lnames += ['sigma','gamma','cells']
    2069         fmt = ["%10.5f","%10.3f","%10.3f","%10.3f","%10.3f"]
     2066        names += ['damp','asym','sig','gam']
     2067        lnames += ['satellite\ndamping','satellite\nasym','sigma','gamma']
     2068        fmt = ["%10.5f","%10.2f","%10.3f","%10.3f","%10.3f","%10.3f"]
    20702069    elif 'C' in dataType:
    20712070        names += ['sig','gam']
     
    20862085    return names, fmt, lnames
    20872086
    2088 def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,fixback=None,prevVaryList=[],oneCycle=False,controls=None,wtFactor=1.0,dlg=None,noFit=False):
     2087def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,fixback=None,prevVaryList=[],
     2088                  oneCycle=False,controls=None,wtFactor=1.0,dlg=None,noFit=False):
    20892089    '''Called to perform a peak fit, refining the selected items in the peak
    20902090    table as well as selected items in the background.
    20912091
    20922092    :param str FitPgm: type of fit to perform. At present this is ignored.
    2093     :param list Peaks: a list of peaks. Each peak entry is a list with 8 values:
    2094       four values followed by a refine flag where the values are: position, intensity,
     2093    :param list Peaks: a list of peaks. Each peak entry is a list with paired values:
     2094      The number of pairs depends on the data type (see :func:`getHeaderInfo`).
     2095      For CW data there are 
     2096      four values each followed by a refine flag where the values are: position, intensity,
    20952097      sigma (Gaussian width) and gamma (Lorentzian width). From the Histogram/"Peak List"
    2096       tree entry, dict item "peaks"
     2098      tree entry, dict item "peaks". For some types of fits, overall parameters are placed
     2099      in a dict entry.
    20972100    :param list Background: describes the background. List with two items.
    20982101      Item 0 specifies a background model and coefficients. Item 1 is a dict.
     
    22232226        return dataType,instDict,insVary
    22242227       
    2225     def GetInstParms(parmDict,Inst,varyList,Peaks):
     2228    def GetPkInstParms(parmDict,Inst,varyList):
    22262229        for name in Inst:
    22272230            Inst[name][1] = parmDict[name]
     
    22702273
    22712274    def SetPeaksParms(dataType,Peaks):
    2272         peakNames = []
     2275        peakDict = {}
    22732276        peakVary = []
    2274         peakVals = []
    22752277        names,_,_ = getHeaderInfo(FitPgm,dataType)
    22762278        for i,peak in enumerate(Peaks):
     2279            if type(peak) is dict:
     2280                peakDict.update(peak)
     2281                continue
    22772282            for j,name in enumerate(names):
    2278                 peakVals.append(peak[2*j])
    22792283                parName = name+str(i)
    2280                 peakNames.append(parName)
     2284                peakDict[parName] = peak[2*j]
    22812285                if peak[2*j+1]:
    22822286                    peakVary.append(parName)
    2283         return dict(zip(peakNames,peakVals)),peakVary
     2287        return peakDict,peakVary
    22842288               
    22852289    def GetPeaksParms(Inst,parmDict,Peaks,varyList):
    22862290        names,_,_ = getHeaderInfo(FitPgm,Inst['Type'][0])
    22872291        for i,peak in enumerate(Peaks):
     2292            if type(peak) is dict:
     2293                continue
    22882294            pos = parmDict['pos'+str(i)]
    22892295            if 'difC' in Inst:
     
    23292335        ptfmt = dict(zip(names,fmt))
    23302336        for i,peak in enumerate(Peaks):
     2337            if type(peak) is dict:
     2338                continue
    23312339            ptstr =  ':'
    23322340            for j in range(len(names)):
     
    24452453    GetBackgroundParms(parmDict,Background)
    24462454    if bakVary: BackgroundPrint(Background,sigDict)
    2447     GetInstParms(parmDict,Inst,varyList,Peaks)
     2455    GetPkInstParms(parmDict,Inst,varyList)
    24482456    if insVary: InstPrint(Inst,sigDict)
    24492457    GetPeaksParms(Inst,parmDict,Peaks,varyList)
    24502458    binsperFWHM = []
    24512459    for peak in Peaks:
     2460        if type(peak) is dict:
     2461            continue
    24522462        FWHM = getFWHM(peak[0],Inst)
    24532463        try:
Note: See TracChangeset for help on using the changeset viewer.