Peak Fit v1.2.0
Fit a function to an intensity profile or any array data I(q) or y(x). The fitted function (Model) is the sum of several independent components, usually one or several peaks with some background.
- Range (optional): Defines a region which should be used for fitting by "start - end". Also several subranges with gaps in between can be defined using semicolons: "start_1 - end_1; start_2 - end_2;...". If empty, the whole intensity profile is used.
- Model: A model to fit the curve. It should include one or more of the following functions (new line in the input field for each function). The parameters need to be filled with start values. The fit model is the sum of all given functions.
- CB(const): A constant non-zero background, i.e. f(x) = |const|.
- LB(y_cut, slope): A linear background, i.e. f(x) = y_cut + x * slope.
- EXP(ampl, shift, scale): An exponential background, i.e. f(x) = ampl * exp((x - shift) / scale).
- POL<N>(p0, p1, p2, ..., p<N>): A polynomial background of order <N> f(x) = p0 + p1 * x + p2 * x**2 + ... + p<N> * x**<N>. <N> can be any number from 0 to 8, i.e. POL0 to POL8 are available.
- GA(pos, height, fwhm): A Gaussian function parameterised as f(x) = height * exp(-(x - pos)**2 / (fwhm**2 / 4.0 / log(2.0))).
- LO(pos, height, fwhm): A Lorentz distribution parameterised as f(x) = height / (1 + ((x - pos) / (fwhm / 2.0))**2).
- PSV(pos, height, fwhm, shape): A pseudo-Voigt profile
- Further functions can be defined by the user using Python as described below in section User Fit Functions.
- A "*" char after a parameter excludes this parameter from the fit and holds it constant.
- Fit Type: Choose between the following fitting approaches.
- Weighting: Choose between the following options - use only for Fit Type least-squares.
- None: No weighting is applied.
- 1/I (counting data): Each data point is weighted with the inverse of its intensity (or zero if I = 0). This is appropriate if you have pure counting statistics (no background subtraction etc.). Note that in case of very low intensities (< 10 or so), a likleihood fit would give better results than least-squares.
- 1/sigma(I)^2: Each data point is weighted with its inverse square of the uncertainty given as input sigma(I) (opt.).
- Reuse Fit Results: Reuse the results of the last fit as start parameter for fitting the next profile of the sequence.
- Max Iterations: Specifying the maximum number of iterations to perform.
- q: The q or chi values of an intensity profile.
- I: The intensity values of an intensity profile.
- sigma(I) (opt.): Uncertainties of the intensity values. Used only if the parameter 'Weighting' is set to 1/sigma(I)^2.
- q: Same as input.
- I: Same as input.
- I_fit: The fitted curve.
- fit_param: An array of the fitted parameters. The parameters have the same order in which they are specified in Model.
- fit_sderr: An array of the uncertainties of the fitted parameters.
- status: A result string from the underlying scipy.oder routine. The fit result is e.g. not reliable if the string contains 'Iteration limit reached' (try again with increased Max Iterations), 'Problem is not full rankat solution', etc.
- model_str: A copy of the Model parameter.
- range_str: A copy of the Range (optional) parameter.
User Fit Functions
The list of functions that can be part of the Model can be extended by the user. To do so, you have to write a python file (with .py suffix) that defines your function and registers it to DPDAK. Here is an example:
# Here we import all we need from DPDAK, e.g. GA as one of the functions # that are available by default. from base.functions import GA, add_function # define new function def digauss(pos, amp1, amp2, fwhm1, fwhm2, x): """Two Gauss peaks with same position, but independent amplitudes/fwhms.""" # We re-use the the Gaussian definition from DPDAK as imported above: return GA(pos, amp1, fwhm1, x) + GA(pos, amp2, fwhm2, x) # Now register the function to be available as 'D_GA' in the peak fit model. # We have to state that it has five fit parameters and that it should not be # treated as a background function # (which is relevant only for the Peak Fit Display tool). add_function(digauss, 'D_GA', 5, is_bg=False)
Now start the DPDAK Options dialogue from DPDAK's main menu: 'Configuration' -> 'DPDAK Options' and add the directory of the Python file to the list of 'User Plugin Directories'. Your function will be available immediately. In the next DPDAK session you do not have to configure the list of user directories again since they will be stored when exiting DPDAK.