Skip to content

ajamalkhan/pyxe

 
 

Repository files navigation

pyXe: X-ray Diffraction Strain Analysis Package

DOI Build Status Build status Coverage Status

What is pyXe?

PyXe is a package developed to address bottlenecks in the diffraction-strain analysis workflow. It is vital that X-ray diffraction data acquired during synchrotron beamtimes is analysed in as close to real time as is possible. This allows for a tight feedback loop and ensures that decisions regarding acquisition and experimental parameters are optimized.

The pyXe package therefore aims to allow for the efficient analysis and visualization of diffraction data acquired from these large scale facilities. It achieves this through the extraction of strain from individual peaks (i.e. not a Reitveld type refinement). Peak fitting routines can be run over 1D, 2D and 3D data sets. Peaks and strain are extracted as a function of azimuthal position (either detector position or caking angle). The resultant strain data is then further interrogated to facilitate the calculation of principal and shear strains. Analysed data is stored in the hdf5 file format and can be easily reloaded and visualised.

This package was originally designed to work with energy dispersive X-ray diffraction data (EDXD) stored in the NeXus format acquired on the I12:JEEP beamline at the Diamond Light Source, UK. However, tt now supports calculation of strain from both energy dispersive and monochromatic (area detector) experiments. The analysis of data from area detectors is possible through the pyFAI library, which allows for fast, accurate azimuthal integration.

Example Usage

If we want to analyze data from an energy dispersive detector we need to import the energy_dispersive module and the associated detector class (EDI12 in the case of the 23-element detector array found on the I12:JEEP beamline). In this case the data was split into two files - coarse and fine scans - these can be merged using the ordered_merge function:

>> from pyxe.energy_dispersive import EDI12
>> from pyxe.merge import ordered merge

The data from I12 is supplied in the NeXus format - we just need to specify the filepaths. In addition to coarse and fine scans there was an associated far field stress free d0 reading, which can be applied to the scans to allow us to accurately calculate the strain.

>> i12_fine = EDI12(fpath='data/50414.nxs')
>> i12_coarse = EDI12(fpath='data/50418.nxs')
>> i12_d0 = EDI12(fpath='data/50402.nxs')

Before going any further it is often useful to vizualise one of the recorded diffraction patterns:

>> coarse.plot_intensity()

ScreenShot

To calculate the peak position we must specify an approximate value of q0 (in this case the material is Fe and the associated (111) peak is located at q=3.1). We must also specify a window within which to search for the peak. A larger window is better as long as it doesn't impinge upon other peaks:

>> i12_coarse.fit_peaks(3.1, 0.25)
>> i12_fine.fit_peaks(3.1, 0.25)
>> i12_d0.fit_peaks(3.1, 0.25)
...
Progress: [####################] 100%
Total points: 6555 (23 az_angles x 285 positions)
Peak not found in 0 position/detector combintions
Error limit exceeded (or pcov not estimated) 12 times

To then convert these peaks into strain we simply apply the d0 readings to each analyzed dataset. Unless specified otherwise this function also attempts to calculate the full strain tensor via a full ring fit. This is often smooths the data and allows for the calculation of strain at arbitrary angles/shear strain determination.

>> fine.calculate_strain(i12_q0)
>> coarse.calculate_strain(i12_q0)

Before plotting the strain map/profile we need to merge the coarse and fine data (although this can be done at any point!). We want to remove overlapping data, with the data points from the fine scan taking priority. Removing overlapping data often improves the final merged data set, although if no priority order is supplied then all data is kept.

>> merged = ordered_merge([coarse, fine], [1, 0])

We can now plot a strain map. To do this we call the plot_slice method, stating which type of data we want to plot (e.g. peaks, fwhm, strain, stress, shear strain). We also need to supply either an azimuthal angle (phi) or a specific azimuthal slice index. In this case the slice index corresponds to the element of the 23-detector array.

>> merged.plot_slice('strain', phi=np.pi/2)

ScreenShot

Requirements

PyXe is built on Python’s scientific stack (numpy, scipy, matplotlib). Additionally, the h5py package is required for the manipulation and management of the NeXus data files. Testing and development were carried out using the Anaconda (v 4.0) package manager, which built with the following versions:

  • Python: version 2.7.11 and 3.5.2
  • numpy: version 1.10.4
  • scipy: version 0.17
  • matplotlib: version 1.5
  • h5py: version 2.5.0

The new area detector analysis module relies on pyFAI, which is a software package developed at the ESRF, designed to reduce SAXS, WAXS and XRPD images recorded by area detectors to 1D plots or 2D patterns (known as caking or azimuthal regrouping). Testing has so far been completed using:

  • pyFAI: version 0.12.0
  • fabIO: version 0.3.0

Installation

Although pyXe is pip installable, this is not recommended at this time. The version available on PyPI is not up to date and significantly inferior to/behind the current version. The current version will be made available on PyPI once more testing has been completed.

In the meantime, you can install from the distribution using the setup.py script. The source is stored in the GitHub repo, which can be browsed at:

https://github.com/casimp/pyxe

Simply download and unpack, then navigate to the download directory and run the following from the command-line:

python setup.py install

About

Strain analysis and visualization package for synchrotron X-ray diffraction data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%