X-Ray Scattering Tools

© 2020 Naveen Venkatesan

Series of tools for analyzing synchrotron diffraction images, written in Python 3, with GUIs generated with PyQt5. The basis for these tools is from the following publication from 2018:

N. R. Venkatesan, R. M. Kennard, R. A. DeCrescent, H. Nakayama, C. J. Dahlman, E. E. Perry, J. A. Schuller, and M. L. Chabinyc, Phase intergrowth and structural defects in organic metal halide Ruddlesden–Popper thin films, Chem. Mater., 2018, 30 (23), 8615 – 8623. [Link]

This software is licensed under the MIT license, feel free to contribute features and improve any functionality as you see fit. Here is a link to fork the repository on Github.

Installation Instructions

1. Clone Github repository

> git clone https://github.com/naveenv92/xray-scattering-tools
> cd xray-scattering-tools/
            
2. Create and activate virtual environment

> python3 -m venv venv
> source venv/bin/activate
            
3. Install dependencies

> (venv) pip install -r requirements.txt
            
4. Run analysis tools

> (venv) python convert-binary-to-tiff/convert-binary-to-tiff.py
> (venv) python giwaxs-image-simulator/giwaxs-image-simulator.py
> (venv) python xrs-analyzer/xrs-analyzer.py
            

Convert Binary To TIFF

To save output from CCDs, data from sychrotrons are often saved as binary files. These streams of bytes must be decoded and reshaped to produced a tractable image. This program does batch conversion of binary files to TIFF image files, provided you know the output image resolution and the number precision of the encoded bytes.

Operating Instructions
  1. Load images (binary files) using the Browse... button – to select multiple files use Ctrl / or Shift when selecting files.
  2. Enter the image width and height values in pixels (should be the same as your detector size).
  3. Select the number precision of the pixel encoding (signed/unsigned short, signed/unsigned int, signed/unsigned long, signed/unsigned long long, float, or double).
  4. Select the save directory with the Browse... button – this directory will be set by default to the location of your binary files.
  5. Click Convert Files to generate your TIFF files for further analysis.

GIWAXS Image Simulator

This program allows you to simulate the GIWAXS (Grazing-Incidence Wide-Angle X-Ray Scattering) pattern of any fiber-textured thin film given that you have a CIF (Crystallographic Information File) file and knowledge of the out-of-plane crystallographic direction.

Generating structure factors in VESTA
  1. Open your .cif with VESTA
  2. Navigate to Edit > Edit Data > Unit Cell.
  3. Click the Remove Symmetry button to remove all symmetry elements in the structure. Click Ok to exit from unit cell menu.
  4. Navigate to Navigate > Structure Factors, edit the X-ray wavelength (λ) and click Calculate.
  5. Use the Export button to save your structure factor data – you may now exit VESTA (do not save the file to revert to original symmetry).
Operating Instructions
  1. Load both your .cif and structure factor files using Browse... buttons – upon loading the .cif, the lattice parameters and angles should populate.
  2. Set the maximum values of Qxy and Qz for the simulation – the output is a 1000 x 1000 TIFF file with both Qxy and Qz starting at 0 Å-1.
  3. Peak shapes are approximated by three-dimensional Gaussian functions with rotation. You must set a value for the full-width at half maximum (fwhm) of peak broadening in the x-direction (along Qxy) and y-direction (along Qz), in Å-1.
  4. Set the out-of-plane direction of your sample (hkl).
  5. Click Simulate GIWAXS Pattern to generate a list of reflections (.csv), and a TIFF file of the final simulated image. At the conclusion of the program, a window will pop-up with the simulated image.

X-Ray Scattering Analyzer

This program allows you to manipulate images collected from synchrotron X-ray diffraction. The beam center and sample-to-detector distance are calibrated using a diffraction image of a known calibrant (silver behenate or lanthanum hexaboride). The program has functions to calculate rotationally averaged diffraction patterns for isotropic samples, geometrically-corrected diffraction images for anisotropic GIWAXS measurements, and in-plane and out-of-plane intensity cuts.

Calibrating sample-to-detector distance
  1. Open the .tif file of your calibrant with the Browse... button – the image resolution fields should automatically populate.
  2. Select your calibrant (currently supports AgBe and LaB6) and enter the X-ray energy and pixel size of the detector in the associated boxes. Now click Calibrate and a new window should open with your calibrant image file.
  3. Zoom in and click points on the 3rd diffraction ring of your calibrant – you may select up to 30 points. When finished, press Enter to fit your selected points and extract the beam center and sample-to-detector distance. You may now exit the calibration window – the fields for beam center and SDD should now be populated.
Circular Averaging
  1. Open the .tif file of your sample with the Browse... button – the minimum and maximum intensity fields should automatically populate.
  2. To get the circular average, press the Circular Average button. After a few seconds, a new window will pop up with a plot of the average intensity values as a function of scattering vector (q). These values will also be saved in a .csv file in the same directory as your sample image.
In-plane/out-of-plane linecuts
  1. Open the .tif file of your sample with the Browse... button – the minimum and maximum intensity fields should automatically populate (if you have done so already, you do not need to reload the file).
  2. Set the incident angle of your experiment in the associated field.
  3. To get your linecuts, press the IP Linecut or OOP Linecut buttons. After a few seconds, a new window will pop up with a plot of intensity values as a function of Qxy (in-plane) or Qz (out-of-plane). These values will also be saved in a .csv file in the same directory as your sample image.
Reshaped GIXS image
  1. Open the .tif file of your sample with the Browse... button – the minimum and maximum intensity fields should automatically populate (if you have done so already, you do not need to reload the file).
  2. Set the incident angle of your experiment in the associated field.
  3. You may enter the minimum and maximum values of Qxy (default [0, 2.5]), Qz (default [0, 2.5]), and the intensity in the associated fields.
  4. In the right-bottom panel, you have control over the font and font-size, colormap, and major/minor tick intervals. You may change these as you desire.
  5. To get your reshaped GIXS image, press the GIXS Image button. After a few seconds, a new window will pop up with the reshaped GIXS image, and this will also be saved as a .png file in the same directory as your sample image.

Contact

naveen.venkatesan@gmail.com