a fit2d SAXS/WAXS primer

Detlef Smilgies, CHESS D1 station

version  7/2/2009



fit2d is a free program running on LINUX and MS Windows and can be downloaded from ESRF. Check out the fit2d homepage for terms and the latest version. Click here for the fit2d on-line manual; an introduction can be found here. For use of the advanced fit2d features please include an acknowledgement.

This fit2d primer is meant for the SAXS/WAXS users at CHESS D1 station. The incomplete subset of fit2d features explained here, are some things that work for me and come up all the time. fit2d has a 300 page plus manual that can be viewed on-line or downloaded from ESRF - please take a look to find out about further details. I'll be glad for feedback on this primer and to learn new tricks - but don't ask me any detailed fit2d questions: this primer sums up pretty much what I know and use of fit2d.

No ready-made program will take care of all fine details of the analysis by itself.  For instance proper Lorentz and polarization factor corrections depend on the experiment. So if you are very picky, the best way is to do this part yourself. This is particularly true for GISAXS and GIWAXS data, for which I still have some questions about proper data processing.

a final hint

The way the various items are ordered roughly corresponds to when you would need to use them. The order also reflects the degree of sophistication. If you are unfamiliar with fit2d, it may make sense to go through the list in order. Right-click here and choose "save target as" to download the datafile I used in the examples below.


display an image

sample input: WAXS raw data
Figure 1. Raw WAXS data of MedOptics CCD camera: silver behenate calibration sample (10 keV photons, sample-detector distance about 100mm).

display a series of images


background subtraction

for very weak scatterers or strongly scattering sample environments such as x-ray capillaries or liquid cells it may be important to take background images, in order to subtract out the sample cell scatter. This can be done in the SAXS/GISAXS or the IMAGE PROCESSING menu:

simple operations in pixel space

These simple operations are useful for a quick check of images right while the data are streaming in.

graphics output

calibrated plots

direct beam position

distance & wavelength calibration


azimuthal integration

for SAXS/WAXS from non-textured samples you want to simply integrate the intensity rings and create a simple radial plot:
You have a choice of plot axes:
There are some other parameters that are related to the rescaling of the intensity, which however, depend on the scattering geometry:
Some processing parameters:


Reference: A P Hammersley, S O Svensson, M Hanfland, A N Fitch, and D Hńusermann, ``Two-Dimensional Detector Software: From Real Detector to Idealised Image or Two-Theta Scan'', High Pressure Research, 14, pp235-248, (1996)

cake plots and sector integration

CAKE provides much more sophisticated integration features than INTEGRATE and I will get into these in quite some detail. In particular if there is parasitic scattering in the images or if the integration area includes corner sections, it is most useful to be able to choose "clean" sectors of the image for highest quality integrations. CAKE uses the same parameters as INTEGRATE (see above); additionally you have to indicate
some conversion parameters:
Other parameters

sample output from CAKE

Figure 3. Sample output from CAKE: Shown are the silver behenate rings from the raw image converted to a azimuth-versus-Q_radial plot. The powder rings are homogeneous showing the high quality of the conversion. For a textured sample powder ring features can be fitted to  measure angular features.

special option: integrations with CAKE

The CAKE integration features shall be demonstrated with a more realistic example. Poly(hexyl thiophene) (P3HT) is a common semiconducting polymer. The side-chains order the polymer backbone in lamellae parallel to a silicon wafer surface. Polymer backbones are closely packed due to pi-stacking of the monomer aromatic rings. The degree of order depends on details of the preparation conditions, and is subject to current studies.

GIWAXS from P3HT film

Figure 4. GIWAXS from a poly(hexyl thiophene) (P3HT) film spin coated onto a silicon wafer covered with the native oxide.
Incident angle was chosen as 0.3░. Other parameters are λ=1.24 ┼, sample-detector distance L = 101.75mm,
direct beam position on detector: x0=950.2 pixels, z0=54.2 pixels.

I would like to thank Satoyuki Nomura and George Malliaras, Cornell, for providing an image from a P3HT sample.

 Two CAKE special options are of immediate interest:
p3ht radial scans

Fig 5. Radial scans perpendicular and parallel to the film.

Left panel: Radial scan (90-890 pixels in 800 steps), integrated over azimuth range of 90░-120░. The (H00) reflections indicative of lamellae formed by the ordering of the alkyl side-chains show up prodominantly in the perpendicular direction, i.e. the lamellae are mostly parallel to the surface. The broad powder ring is due to the amorphous silicon oxide layer at the wafer surface.

Right panel: Radial scan (90-890 pixels in 800 steps), integrated over azimuth range of 120░-180░. In the in-plane direction the (010) peak due to the pi-stacking of the aromatic rings of the polymer back-bone can be found, i.e. polymer chains are parallel to the surface and parallel to each other. The weak (010) peak is superimposed to the silicon oxide powder ring (dashed curve). Weak (H00) powderrings indicate that some parts of the film contain lamellae that have arbitrary orientation (3D powder).

p3ht azimuth scans

Fig 6. Azimuthal scans fron 90░ to 180░ in steps of 1░ for the four reflections identified above. A narrow radial range was chosen around each arc of intensity: (a) 90-250 pixels for the (100) reflection, (b) 250-400 pixels for (200), (c) 450-540 for (300), and (d) 680-790 pixels for the (010) reflections. Azimuthal widths of all four reflections are comparable (about 40░ FWHM). Note that (010) is perpendicular to the (H00) reflections and the its background is higher, as (010) is located on top of the broad powder ring of the amorphous silicon oxide layer.

For further analysis the azimuth distributions can be fitted  as shown below  For writing the distributions to an ASCII file for creating publishable figures and or further data analysis, use OUTPUT > CHIPLOT.

Tricks & Traps - Some things I found the hard way


Projections onto calibrated axes are an extremely powerful tool, in particular for the analysis of GISAXS data. Fit2D provides such a tool in the SAXS/GISAXS menue, however, I have not been able to get it to work reliably. The manual states:

"PROJECTION : Integrate rectangular region to 1-D scan. This uses the beam centre and a user input coordinate to define an integration line. A second user input coordinate defines the width of the integration region. Pixels within this region are effectively ``collapsed'' onto the integration line, and then re-binned to the required 1-D output scan. This type of integration is specifically for grazing incidence data."

Disclaimer: I have never figured out how to do this correctly.But here is a kludge that seems to give reasonable results - but not guarantees given (you should always check with a standard or a known sample):

(calibrated 2D plots)

I have not yet been able to find a feature in fit2d which handles this common task in an elegant way, i.e. converting from x, y (pixels) to q_x, q_y (inverse Angstroem).

Here's the brute force way which is only good for SAXS or GISAXS maps, when the transformation from pixel space to angle space or Q-space are essentially linear:
See also Peter Busch's fit2d notes.

For D1-style GIWAXS, the non-linear coordinate transformation form pixels to scattering angles to q-components has to be done with another program, for instance an Origin 7.0 spreadsheet. See GIWAXS at D-line .

1D peak fitting of calibrated data

sample outpit: integration and fit
Figure 2. Integration of AgBeh raw input data and succesive fit (6th order polynominal background and 7 Gaussians; the 2 small peaks on the right were not attempted to be fitted). The bottom plot shows the residuals.

Reference: A P Hammersley and C Riekel, ``MFIT: Multiple Spectra Fitting Program'', Synchrotron Rad. News, 2, pp24-26, (1989) .

final remark

This page a work in progress. Nonetheless it has provided the backbone for on-line and off-line data analysis for the users of CHESS D1 station in the past years. Please report errors to me. If you find another useful fit2d feature to include in this page, please let me know.  DS