Peakfit()

Fits various peaks to data supplied in arrays.

PEAKFIT() x=Realarray y=Realarray e=Realarray
[pars=Realarray] [ipropt=Integerarray]
Fits a selction of peaks to supplied data.
[:GAUSS] Gaussian
[:GEXP] Gaussian convolved with exponential
[:LOREN] Lorentzian
[:LEXP] Lorentzian convolved with exponential
[:VOIGT] Voigt
[:VEXP] Voigt convolved with exponential
[:POLY] Polynomial of a specified degree

example:

	# Read some data and fit a peak to it
	# remembering to convert from histogram
	# to point data.
	>> w=s(1)
	>> res = Peakfit:Lexp(centre_bins(w.x), w.y, w.e)

Note: Centre_bins() reduces X-array length by one and picks bin centres.

 

Peakfit

The peakfit command is designed to give full access to a good selection of peak fitting routines. It is designed so that it can be used in conjunction with the Peakgen() command which allows a regeneration of the fitted peak, usually to allow a graphical comparison of the goodness of the fit.

Parameters:

X, Y, E (Realarray)

One dimensional X, Y, and error data arrays of the same length. Note that a lot of data in Open GENIE is in histogram format so it is important to ensure that the X-array is converted before attempting to fit a peak. The Centre_bins() function is provided for this purpose.

Pars (Realarray) [ default = best guess line fit ]

Optional input parameter that allows an initial guess or fixing of one or more of the peak parameters. This operates in conjunction with the corresponding values in "Ipropt". The length of the pars array differs depending on the number of peak parameters required for a particular fit (see below for descriptions of the individual fitting routines).

Ipropt (Integerarray) [ default = no initial estimates ]

Controls the treatment of the corresponding parameter in "Pars". This array consists of a set of integer flags.

0 = no initial estimate
1 = use parameter as a guess
2 = fix parameter value as given

By using these two parameter arrays, it is possible to completely control the operation of the peak fitting routines, However, for simple fitting it is not necessary to supply a "Pars" or "Ipropt" array.

RESULT = (Workspace)

The result of the Peakfit() command is returned as a workspace containing the following fields:

Field name Type Description
IGOOD Integer Status value for goodness of fit:
< -1 Terrible
-1 Maybe OK
>= 0 Good
PARS Realarray Best estimates of the parameters
SIGPAR Realarray 1-sigma error-bars for PARS (may be negative if IGOOD < 0)

Peakfit:Gauss

Estimates the parameters of a Gaussian-peak sitting on a straight-line background, given a pertinent set of data:

    y(x) = Mx + C + A*gaus(X0,SIGMA) ,

where

                           1             [ - (x-X0)**2  ]  
    gaus(X0,SIGMA) = ---------------- exp|--------------| .
                     SIGMA*sqrt(2*pi)    [ 2 * SIGMA**2 ]

Parameters:

Pars (Realarray)

Pars[1] = M
Pars[2] = C
Pars[3] = A
Pars[4] = X0
Pars[5] = SIGMA

Peakfit:Gexp

Estimates the parameters of a peak, consisting of a Gaussian convolved with a sharp-edged exponential, sitting on a straight-line background, given a pertinent set of data:

    y(x) = Mx + C + A*gsexp(X0,SIG,TAU) ,

where

                               1           [ - (x-X0)**2 ]  
    gsexp(X0,SIG,TAU) =  -------------- exp|-------------| 
                         SIG*sqrt(2*pi)    [  2 * SIG**2 ]

Convolved with

    {        0           if x/TAU < 0
    {                                  .
    { exp(-x/TAU)/|TAU|  if x/TAU > 0

Parameters:

Pars (Realarray)

Pars[1] = M
Pars[2] = C
Pars[3] = A
Pars[4] = X0
Pars[5] = SIG
Pars[6] = TAU

Peakfit:Loren

Estimates the parameters of a Lorentzian-peak, sitting on a straight-line background, given a pertinent set of data:

    y(x) = Mx + C + A*lorentz(X0,GAMMA) ,

where

                                  GAMMA  
    lorentz(X0,GAMMA) = ---------------------------  .
                        pi [ (x-X0)**2 + GAMMA**2 ]

Parameters:

Pars (Realarray)

Pars[1] = M
Pars[2] = C
Pars[3] = A
Pars[4] = X0
Pars[5] = GAMMA

Peakfit:Lexp

Estimates the parameters of a peak, consisting of a Lorentzian convolved with a sharp-edged exponential, sitting on a straight-line background, given a pertinent set of data:

    y(x) = Mx + C + A*lzexp(X0,GAM,TAU) ,

where

                                    GAM  
    lzexp(X0,GAM,TAU) =   -------------------------
                          pi [ (x-X0)**2 + GAM**2 ]

Convolved with

    {        0           if x/TAU < 0
    {                                  .
    { exp(-x/TAU)/|TAU|  if x/TAU > 0

Parameters:

Pars (Realarray)

Pars[1] = M
Pars[2] = C
Pars[3] = A
Pars[4] = X0
Pars[5] = GAM
Pars[6] = TAU

Peakfit:Voigt

Estimates the parameters of a Voigt-peak sitting on a straight-line background, given a pertinent set of data:

    y(x) = Mx + C + A*voigt(X0,SIG,GAM) ,

where

                               1           [ - (x-X0)**2 ]
    voigt(X0,SIG,GAM) =  -------------- exp|-------------|
                         SIG*sqrt(2*pi)    [  2 * SIG**2 ]

Convolved with

             GAM
     --------------------  .
     pi [ x**2 + GAM**2 ]

Parameters:

Pars (Realarray)

Pars[1] = M
Pars[2] = C
Pars[3] = A
Pars[4] = X0
Pars[5] = SIG
Pars[6] = GAM

Peakfit:Vexp

Estimates the parameters of a peak, consisting of a Voigt convolved with a sharp-edged exponential, sitting on a straight-line background, given a pertinent set of data:

    y(x) = Mx + C + A*vtexp(X0,SIG,TAU) ,

where

                               1           [ - (x-X0)**2 ]
    voigt(X0,SIG,GAM) =  -------------- exp|-------------|
                         SIG*sqrt(2*pi)    [  2 * SIG**2 ]

Convolved with

             GAM
     --------------------  .
     pi [ x**2 + GAM**2 ]

Convolved with

    {        0           if x/TAU < 0
    {                                  .
    { exp(-x/TAU)/|TAU|  if x/TAU > 0

Parameters:

Pars (Realarray)

Pars[1] = M
Pars[2] = C
Pars[3] = A
Pars[4] = X0
Pars[5] = SIG
Pars[6] = GAM
Pars[7] = TAU

 

 

Peakfit:Poly

Estimates the polynomial coefficients of a peak by attempting to fit an nth degree polynomial, the degree of the polynomial fit is given by the number of parameters supplied to pars, for this routine "Pars" is not optional.

    y(x) = p1 + p2*x + p3*x^2 + p4*x^3 + ...

For example

    >> pars = dimensions(3)			# create an array
    >> fill pars 0.0				# fill with 0.0
    >> fit = Peakfit:Poly(x, y, e, pars)	# quadratic fit.

Parameters:

Pars (Realarray)

Pars[1] = p1
Pars[2] = p2
Pars[3] = p3
Pars[4] = p4
Pars[5] = p5
Pars[6] = p6