Changeset 1889 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Jun 15, 2015 3:00:17 PM (7 years ago)
Author:
toby
Message:

Add fixed background points; animate dragging points and lines; add fixed bkg fit routine (bkg peaks buggy\!)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r1878 r1889  
    13201320           
    13211321def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,prevVaryList=[],oneCycle=False,controls=None,dlg=None):
    1322     'needs a doc string'
    1323        
     1322    '''Called to perform a peak fit, refining the selected items in the peak
     1323    table as well as selected items in the background.
     1324
     1325    :param str FitPgm: type of fit to perform. At present "LSQ" is the only
     1326      option that works
     1327    :param list Peaks: a list of peaks. Each peak entry is a list with 8 values:
     1328      four values followed by a refine flag where the values are: position, intensity,
     1329      sigma (Gaussian width) and gamma (Lorentzian width). From the Histogram/"Peak List"
     1330      tree entry, dict item "peaks"
     1331    :param list Background: describes the background. List with two items.
     1332      Item 0 specifies a background model and coefficients. Item 1 is a dict.
     1333      From the Histogram/Background tree entry.
     1334    :param list Limits: min and max x-value to use
     1335    :param dict Inst: Instrument parameters
     1336    :param dict Inst2: more Instrument parameters
     1337    :param numpy.array data: a 5xn array. data[0] is the x-values,
     1338      data[1] is the y-values, data[2] are weight values, data[3], [4] and [5] are
     1339      calc, background and difference intensities, respectively.
     1340    :param list prevVaryList: Used in sequential refinements to override the
     1341      variable list. Defaults as an empty list.
     1342    :param bool oneCycle: True if only one cycle of fitting should be performed
     1343    :param dict controls: a dict specifying two values, Ftol = controls['min dM/M']
     1344      and derivType = controls['deriv type']. If None default values are used.
     1345    :param wx.Dialog dlg: A dialog box that is updated with progress from the fit.
     1346      Defaults to None, which means no updates are done.
     1347    '''
    13241348    def GetBackgroundParms(parmList,Background):
    13251349        iBak = 0
     
    15871611                ncyc = int(result[2]['nfev']/2)
    15881612            finally:
    1589                 dlg.Destroy()
     1613                if dlg: dlg.Destroy()
    15901614            runtime = time.time()-begin   
    15911615            chisq = np.sum(result[2]['fvec']**2)
     
    15941618            Rvals['GOF'] = chisq/(xFin-xBeg-len(varyList))       #reduced chi^2
    15951619            print 'Number of function calls:',result[2]['nfev'],' Number of observations: ',xFin-xBeg,' Number of parameters: ',len(varyList)
    1596             print 'fitpeak time = %8.3fs, %8.3fs/cycle'%(runtime,runtime/ncyc)
     1620            if ncyc:
     1621                print 'fitpeak time = %8.3fs, %8.3fs/cycle'%(runtime,runtime/ncyc)
    15971622            print 'Rwp = %7.2f%%, chi**2 = %12.6g, reduced chi**2 = %6.2f'%(Rvals['Rwp'],chisq,Rvals['GOF'])
     1623            sig = [0]*len(varyList)
     1624            if len(varyList) == 0: break  # if nothing was refined
    15981625            try:
    15991626                sig = np.sqrt(np.diag(result[1])*Rvals['GOF'])
     
    16101637                        del(varyList[ipvt-1])
    16111638                        break
     1639                else: # nothing removed
     1640                    break
    16121641        elif FitPgm == 'BFGS':
    16131642            print 'Other program here'
     
    16191648    yd[xBeg:xFin] = y[xBeg:xFin]-yc[xBeg:xFin]
    16201649    GetBackgroundParms(parmDict,Background)
    1621     BackgroundPrint(Background,sigDict)
     1650    if bakVary: BackgroundPrint(Background,sigDict)
    16221651    GetInstParms(parmDict,Inst,varyList,Peaks)
    1623     InstPrint(Inst,sigDict)
     1652    if insVary: InstPrint(Inst,sigDict)
    16241653    GetPeaksParms(Inst,parmDict,Peaks,varyList)   
    1625     PeaksPrint(dataType,parmDict,sigDict,varyList)
     1654    if peakVary: PeaksPrint(dataType,parmDict,sigDict,varyList)
    16261655    return sigDict,result,sig,Rvals,varyList,parmDict,fullvaryList,badVary
    16271656
Note: See TracChangeset for help on using the changeset viewer.