Starting point for a LS refinement is a loaded data set ( xi, yi), the selection of a suitable theory function y(xi,p) to describe the data and a set of starting values for the fit parameters p. The program KUPLOT offers the following three predefined theory functions and additionally allows the use of a user defined function (see section 8.3).
Let us have a closer look at these theory functions. The first one shown in equation 8.1 is a simple polynom of the order of N which can be defined by the user. The fit parameters pn are the corresponding coefficients. Note that KUPLOT actually numbers the fit parameters starting with one, i.e. parameter one corresponds to the term x0.
The next function (equation 8.2) is a sum of N Gaussians and a linear background defined by the first two parameters p1 and p2. The number of Gaussians to be used is defined by the user. Each Gaussian is represented by a set of four fit parameters: p1,n is its peak height and p2,n is its peak position. The half width of the Gaussian (as well as the Lorentzian) is defined by a half width parameter p3,n and an asymmetry parameter p4,n. Obviously the symmetric case is given by p4,n = 1.0. The Lorentzian theory function (equation 8.3) is defined by a similar set of parameters. Currently both function types can not be used in combination except as user defined theory function as described in section 8.3.
Now we will see the fitting segment of KUPLOT in action in the following example. The data set is the profile we have used in examples before in Figure 4.1. Assuming the corresponding data are loaded as set one, the next step is to enter the LS sublevel of the program KUPLOT. This is done by the command 'fit' followed by the data set number that should be used as observed data (line 1). The macro is show below and as before the line number are not part of the macro file itself.
1 fit 1
2 #
3 mfen 7
4 func gaus,1
5 par
6 #
7 run
8 save
The command in line 3 sets the 'window' size used to determine maxima within the plot which are used as defaults for the starting values. The procedure is equivalent to the command 'smax' explained in section 7.4. For our example the setting to 7 points will determine the main maximum correctly. Next (line 4) the theory function is specified to be one Gaussian. Note that KUPLOT determines the default starting values for the fitting parameters pat this stage and the command 'mfen' has to be entered before to have an effect. Furthermore all current values of the fit parameters, e.g. from a previous run, are replaced by the new default values. The command 'par' (line 5) lists the current parameter settings and after checking them on the screen we are ready to go. The fit is started via the command 'run' in line 7 of our example command file. The fit progress is displayed on the screen until the fits converges to a minimum or the maximum number of cycles is reached. This maximum cycle number can be altered using the 'cyc' command in the fitting sublevel. In our example it took 9 iterations to reach the minimum and the resulting parameters are listed in table 8.1 on the left. Finally the results are saved (line 8) as two data files containing the calculated and difference data set and a text file summarizing the results.
| ||||||||||||||||||||||||||||||||
The resulting plot of the observed and calculated data as well as the difference between them is shown in Figure 8.1 again on the left. Although there a reasonable agreement is achieved, there are clearly visible differences especially at the tails of the Gaussian. Note that we have fitted a symmetric Gaussian which is the default, i.e. the parameter p4,n is set to 1.0 and not refined. To refine this parameter use the command 'par 6,1'. The first number is the number of the fit parameter (since we have two background parameters it is 4+2=6) and the next number can be 1 for refining or 0 for keeping the corresponding parameter fixed. An optional third parameter allows one to alter the value of the fit parameter.
To improve the fit we will try to fit two Gaussians located at the same position to the data set. This will allow to model the sides of the peak in a better way. The corresponding macro is shown below. Lines 1-4 are the same as before except that we select two Gaussians rather than one. Again we assume the profile is loaded as data set one.
1 fit 1
2 #
3 mfen 7
4 func gaus,2
5 #
6 par 7,1,0.0
7 par 8,1,p[4]
8 par 9,1,p[5]
9 par10,0,p[6]
10 par
11 #
12 run
13 save
Since KUPLOT will only find one maximum a warning will be displayed and we have to set the starting values for our second Gaussian manually (lines 6-9). We set the peak height to 0.0 and take the other parameters from the settings for the first Gaussian using the variables p[i]. Just to be sure we list the current settings again (line 10) and the fit is started in line 12 by the 'run' command. Finally the results are saved as before (line 13). The resulting parameters are listed in Table 8.1. A measure for the quality of a fit is the R-vale which is defined as:
Here the sum goes over all N data points (
xi,yi) and
y(xi,p)is the theory function. KUPLOT offers a variety of weights wito be selected to the fit. The default we have used in our example is
.
Check the online help for the command 'wic' to
obtain more information about supported weighting schemes. Inspection of
the results for this second fit shown in Table 8.1 and Figure
8.1 clearly show that the second fit describes the data much
better. However the parameters marked with * in Table 8.1 could
not be refined and remained at their starting values. Possible steps to
avoid that problem are to refine the parameters one by one or change the
setting of 'URF' which controlled the 'speed' of the fit. A small value,
e.g. 0.1, will converge quickly to the minimum but in case of a more
complex problem, the fit might fail. A larger value of 'URF' on the other
hand will change the parameters in each iteration by a smaller amount and
the fit might work. However care has to be taken to not end up in a local
minimum. The value of 'URF' (which stands for something very German) is
altered via the command 'urf'. The authors recommend playing around with
the various settings of the fit sublevel to get familiar with the LS
fitting process.