DPPA Fittings

DPPA Fittings

This section details how the Fit Panel in BIG dippa works Back to Help Home DPPAdocs.html

The text in the grey boxes is code used to generate this html help file. Essentially what this code is doing is using command prompts to replicate the pressing of buttons on the GUI, and making some features of the GUI green to highlight them



The fittings panel is used to fit the diffraction peaks to pseudo-Voigt functions. For each peak 5 quantities are obtained:

  1. The position of the peak (K=1/d)
  2. The intensity of the peak
  3. The full-width of the peak
  4. The pseudo-Voigt mixing parameter of the peak (1 = Lorentzian, 0 = Gauss)
  5. The individual background level of the peak
  • Variables 1-4 are stored in the folder '/0. variables/fit.mat' under the variable name 'aa' in the order given above (i.e. aa(1,:) is the positions of the different peaks, aa(2,:) the intensities of these peaks, etc).
  • If peak asymmetry is selected the 5th and 3rd positions are full-widths of different sides of the peak, and 6th and 4th positions are mixing parameter values of the different sides of the peak
  • The individual background of the peaks are contained in the variable 'aabcg'. The total background is given in the variable 'aa' in the last column, the values are for a 2nd order polynomial
gre =[0 0.8 0]; wht =[1 1 1];

Loading a sample

A new sample is loaded using the 'Load data' button on the right hand side of the fittings panel. Data can be in 2-theta, d, or 1/d, and will be converted to 1/d scale by interpolation. The data can be loaded in 2 ways, both use the function loadb_GUI_MW.m

  • If the data is in a set format (given in loadb_GUI_MW) it can be loaded directly. If the same data is continuously loaded it may be beneficial to modify the loadb_GUI_MW.m file.
  • Alternatively the data can be imported into the workspace and given the name 'data'. The variable 'data' will have 2 columns: two theta & intensity. See also below Here we will load the file thom_co7 which has a Co tube and the data is in 2-theta.

Selecting the phase and peak

The menus in the middle of the Fit panel are used to select a particular phase and hkl peak. When a particular peak is selected the fitting parameters of that peak are displayed on the left-hand-side and the fit of the peak is displayed in the figure. The total fit can be seen by pressing 'Plot fit', but because of the use of indivdual background settings for each peak this can often look like a poor fit.

handles.indexres_l.Value =3;


Fitting Parameters

On the left of the Fit panel are the fitting variables for the pattern and a particular peak. These values can be changed manually by entering new values in the boxes.

The background level for all peaks is given on the right-hand side. The different values of the polynomial against 1/d. The fitting values for a particular peak are, anti-clockwise from top-left):

  • K(=1/d). The position of the middle of the peak
  • Intensity. The maximum intensity of the peak.
  • Background individual. Additional values to adjust the background level around a particular peak, I=m(1/d)+ c the first value is c and the 2nd is m.
  • Neta. The pseudo Voigt mixing parameter. Neta = 1 is Lorentzian peak, and Neta = 0 is a Gauss.
  • FW. The full-width at half-maximum inetensity of a peak.

The two buttons labelled 'Original k' and 'K-I' are used to set the position of the peak. 'Original k' returns the peak position to its value given by the materials settings file, this can be useful when the position of a peak moves due to a nearby peak with higher intensity. The 'K-I' button can be used to click on the maxima of a peak to adjust the peak position and intensity. This is useful when there are problems with the fitting algorithm in fitting to the peak.

handles.phaseres_l.BackgroundColor=[1 1 1];handles.indexres_l.BackgroundColor=[1 1 1];

Fitting The Peaks

To fit one peak use the 'Fit individual' button. Or to fit multiple peaks use 'Fit All', but be careful to check the fit has worked.

The other buttons and textboxes involved in fitting are as follows:

  • Reset fit data. This resets any fit data so that the peak position are given by the settings file and the intensity of the peak given by intensity close to the peak. Arbitrary FW and neta values are set.
  • Fit range. This is used to crop the data over a smaller 1/d range. For example when there are peaks or intensity changes that don't need to be accounted for
  • Bcg spline. This button fits a polynomial background spline to the data. The intensity at and around the peak positions are ignored, how far from the centre of the peak depends on the value used in 'Plot interval'.
  • Fitting interval. Value in 1/d over which the fitting is performed over. 0.02 is a reasonable value but there are cases when lower and higher ranges work better
  • Plot interval. This is how much of the pattern around a peak is included in the figure when a peak is plotted.
  • Use asymmetric peaks. If this is ticked the peak is allowed to have different FW and neta values on the left and right side of the peak.
handles.fitleft_p.BackgroundColor=[1 1 1];
Local minimum possible.

lsqcurvefit stopped because the final change in the sum of squares relative to 
its initial value is less than the default value of the function tolerance.

Loading and Saving Fit Data

Saving fit data

Once the data has been fitted it should be saved using the 'Save fit' button. This saves the 1/d vs intensity data, the fitting data and the settings used. Normally a sample is part of a project that contains multiple samples. To account for this when saving the first file of the project give it a name and press save, however for subsequent files when saving select the same file to save to and ignore the warning about saving over previous data this will not happen. Overwritting will only occur if the filename is the same and then that part of the data will be overwritten.

Loading fit data

Due to the use of projects that contain multiple samples, the way to load a previously fitted file involves two steps

  1. Load the fit file that contains the project with 'Load Fit Folder'. This will then list all the samples in the menu above this button.
  2. Select one of the samples of the project and select 'Load fit' to load details of that sample.

This should then load the data, fit information and setting information.

% <<Load4.png>>

Batch Fit

If you have to fit multiple diffraction patterns of the same sample, i.e. with the same materials and instrumental settings (e.g. beamline experiment), then the Batch Fit button can be used for this.

Selecting batchfit opens up a new dialog box where the batch fit takes place



@ All Rights Reserved