Changeset 3070 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Sep 13, 2017 8:53:49 AM (4 years ago)
Author:
vondreele
Message:

implement use of background pattern for PWDR data.
Used for plot & peak fitting; not Rietveld refinement
fix background parm copy issue - needed deepcopy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r3000 r3070  
    15011501    return True
    15021502           
    1503 def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,prevVaryList=[],oneCycle=False,controls=None,dlg=None):
     1503def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,fixback,prevVaryList=[],oneCycle=False,controls=None,dlg=None):
    15041504    '''Called to perform a peak fit, refining the selected items in the peak
    15051505    table as well as selected items in the background.
     
    15191519      data[1] is the y-values, data[2] are weight values, data[3], [4] and [5] are
    15201520      calc, background and difference intensities, respectively.
     1521    :param array fixback: fixed background values
    15211522    :param list prevVaryList: Used in sequential refinements to override the
    15221523      variable list. Defaults as an empty list.
     
    18011802        badVary = []
    18021803        result = so.leastsq(errPeakProfile,values,Dfun=devPeakProfile,full_output=True,ftol=Ftol,col_deriv=True,
    1803                args=(x[xBeg:xFin],y[xBeg:xFin],w[xBeg:xFin],dataType,parmDict,varyList,bakType,dlg))
     1804               args=(x[xBeg:xFin],(y+fixback)[xBeg:xFin],w[xBeg:xFin],dataType,parmDict,varyList,bakType,dlg))
    18041805        ncyc = int(result[2]['nfev']/2)
    18051806        runtime = time.time()-begin   
    18061807        chisq = np.sum(result[2]['fvec']**2)
    18071808        Values2Dict(parmDict, varyList, result[0])
    1808         Rvals['Rwp'] = np.sqrt(chisq/np.sum(w[xBeg:xFin]*y[xBeg:xFin]**2))*100.      #to %
     1809        Rvals['Rwp'] = np.sqrt(chisq/np.sum(w[xBeg:xFin]*(y+fixback)[xBeg:xFin]**2))*100.      #to %
    18091810        Rvals['GOF'] = chisq/(xFin-xBeg-len(varyList))       #reduced chi^2
    18101811        print 'Number of function calls:',result[2]['nfev'],' Number of observations: ',xFin-xBeg,' Number of parameters: ',len(varyList)
     
    18341835    yb[xBeg:xFin] = getBackground('',parmDict,bakType,dataType,x[xBeg:xFin])[0]
    18351836    yc[xBeg:xFin] = getPeakProfile(dataType,parmDict,x[xBeg:xFin],varyList,bakType)
    1836     yd[xBeg:xFin] = y[xBeg:xFin]-yc[xBeg:xFin]
     1837    yd[xBeg:xFin] = (y+fixback)[xBeg:xFin]-yc[xBeg:xFin]
    18371838    GetBackgroundParms(parmDict,Background)
    18381839    if bakVary: BackgroundPrint(Background,sigDict)
Note: See TracChangeset for help on using the changeset viewer.