PyFAI is an azimuthal integration library designed for high-performance, achieving performance comparable to C and even greater through OpenCL-based GPU acceleration.
It is based on histogramming the 2θ/Q positions of each pixel centre, weighted by pixel intensity, whereas the parallel version performs a SparseMatrix-DenseVector multiplication.
Both method achieve the same numerical result.
Neighboring output bins also receive contributions from pixels adjacent to the border through pixel splitting.
PyFAI also provides tools to calibrate the experimental setup using Debye-Scherrer rings of a reference compound.
References
The philosophy of pyFAI is described in the proceedings of SRI2012
Implementation in parallel is described in the proceedings of EPDIC13
Benchmarks and optimization procedure are described in the proceedings of EuroSciPy2014
Application of signal separation to diffraction image compression and serial crystallography in J. Appl. Cryst. (2025)
Installation
Using PIP (python-package installer)
As with most Python packages, pyFAI is available via pip:
pip install pyFAI[gui]
It is recommended to run this in a virtual environment.
Provide the --user option to perform an installation local to your user-space (not recommended).
Under UNIX, you may have to run the command via sudo to gain root access and perform a system wide installation (which is neither recommended).
Using conda installer
PyFAI is also available via the conda installer from Anaconda:
conda install pyfai -c conda-forge
To install conda please see either conda or Anaconda.
From source code
The current development version of pyFAI can be downloaded from GitHub.
The source code is currently distributed as a zip package.
Download and unpack it:
unzip pyFAI-main.zip
cd pyFAI-main
Install dependencies:
pip install -r requirements.txt
Build and test it:
python run_tests.py
For its tests, pyFAI downloads test images from the internet. Depending on your network connection and your local network configuration, you may have to set up a proxy configuration like this (not needed at ESRF):
export http_proxy=http://proxy.site.org:3128
Finally, install pyFAI in the virtualenv after testing it:
pip install .
The latest development version is available by checking out the Git repository:
git clone https://github.com/silx-kit/pyFAI.git
cd pyFAI
pip install .
To enable GPU acceleration in pyFAI, please install pyopencl.
Documentation
Documentation can be built using this command and Sphinx (installed on your computer):
python build-doc.py
Dependencies
Python 3.10 … 3.14 are well tested and officially supported (thread-free is untested).
For full functionality of pyFAI, the following modules need to be installed:
On Ubuntu or Debian, the required Python modules for pyFAI can be installed either via the Synaptic Package Manager (under System → Administration) or from the command line using apt-get:
sudo apt-get install pyfai
MacOSX
On macOS, a recent version of Python (≥3.10) must be installed before installing pyFAI.
Apple provides only an outdated version of Python 2.7 which is deprecated.
To build pyFAI from source, you will also need Xcode, which is available from the Mac App Store.
The binary extensions will use only a single core due to the limitation of the compiler from Apple.
OpenCL is hence greatly advised on Apple systems.
Next, install the missing dependencies using pip:
pip install -r requirements.txt
Windows
On Windows, a recent version of Python (>=3.10) must be installed before pyFAI.
The Visual Studio C++ compiler is required when building from source
Next, install any missing dependencies using pip:
pip install -r requirements.txt
Getting Help
A mailing-list, pyfai@esrf.fr, is available to get help on the program and how to use it.
One needs to subscribe by sending an email to sympa@esrf.fr with the subject “subscribe pyfai”.
There is also a discussion space at GitHub and an issue tracker where bugs can be reported.
Fast Azimuthal Integration in Python
Main development website: https://github.com/silx-kit/pyFAI
PyFAI is an azimuthal integration library designed for high-performance, achieving performance comparable to C and even greater through OpenCL-based GPU acceleration. It is based on histogramming the 2θ/Q positions of each pixel centre, weighted by pixel intensity, whereas the parallel version performs a SparseMatrix-DenseVector multiplication. Both method achieve the same numerical result. Neighboring output bins also receive contributions from pixels adjacent to the border through pixel splitting. PyFAI also provides tools to calibrate the experimental setup using Debye-Scherrer rings of a reference compound.
References
Installation
Using PIP (python-package installer)
As with most Python packages, pyFAI is available via pip:
It is recommended to run this in a virtual environment. Provide the
--useroption to perform an installation local to your user-space (not recommended). Under UNIX, you may have to run the command viasudoto gain root access and perform a system wide installation (which is neither recommended).Using conda installer
PyFAI is also available via the
condainstaller from Anaconda:To install conda please see either conda or Anaconda.
From source code
The current development version of pyFAI can be downloaded from GitHub. The source code is currently distributed as a zip package.
Download and unpack it:
Install dependencies:
Build and test it:
For its tests, pyFAI downloads test images from the internet. Depending on your network connection and your local network configuration, you may have to set up a proxy configuration like this (not needed at ESRF):
Finally, install pyFAI in the virtualenv after testing it:
The latest development version is available by checking out the Git repository:
To enable GPU acceleration in pyFAI, please install pyopencl.
Documentation
Documentation can be built using this command and Sphinx (installed on your computer):
Dependencies
Python 3.10 … 3.14 are well tested and officially supported (thread-free is untested).
For full functionality of pyFAI, the following modules need to be installed:
numpyscipymatplotlibfabioh5pypyopenclpyside6silxnumexprThose dependencies can simply be installed by:
Ubuntu and Debian-like Linux distributions
On Ubuntu or Debian, the required Python modules for pyFAI can be installed either via the Synaptic Package Manager (under System → Administration) or from the command line using apt-get:
MacOSX
On macOS, a recent version of Python (≥3.10) must be installed before installing pyFAI. Apple provides only an outdated version of Python 2.7 which is deprecated. To build pyFAI from source, you will also need Xcode, which is available from the Mac App Store. The binary extensions will use only a single core due to the limitation of the compiler from Apple. OpenCL is hence greatly advised on Apple systems. Next, install the missing dependencies using pip:
Windows
On Windows, a recent version of Python (>=3.10) must be installed before pyFAI. The Visual Studio C++ compiler is required when building from source Next, install any missing dependencies using pip:
Getting Help
A mailing-list, pyfai@esrf.fr, is available to get help on the program and how to use it. One needs to subscribe by sending an email to sympa@esrf.fr with the subject “subscribe pyfai”. There is also a discussion space at GitHub and an issue tracker where bugs can be reported.
Maintainers
Contributors
Thanks to all who have contributed to pyFAI!
Indirect contributors (ideas, …)