PyNX stands for Python tools for Nano-structures Xtallography.It can be used for:

  • Coherent X-ray imaging simulation and analysis: coherent diffraction imaging (CDI), Ptychography, Wavefront propagation, near field and far field techniques…

  • Fast scattering calculations from large number of atoms and reciprocal space positions.

Using  pynx

pynx is installed as a python 3.9 virtual environment. Use modules to setup the environment:

xwhich pynx

# Provided by module(s)
#  ... module load maxwell pynx/2020.2.2                        which pynx: /software/pynx/2020.2.2/bin/pynx 
#  ... module load maxwell pynx/2022.1                          which pynx: /software/pynx/2022.1/bin/pynx 
#
# Documentation: https://confluence.desy.de/display/MXW/pynx

module load pynx/2022.1

# note: the pynx command is just a dummy

 Installation

the procedure used to install pynx v2022.1:

# setup
module purge
module load maxwell openmpi/3.1.6 cuda/11.3 python/3.9
unset PYTHONPATH
unset MPI_PYTHON3_SITEARCH
unset MPI_PYTHON_SITEARCH

# create the virtual environment
cd /software/pynx/
mkdir 2022.1
cd 2022.1/
virtualenv -p python3.9 ./
source bin/activate

# install python packages
python3.9 -m pip install --upgrade pip
python3.9 -m pip install setuptools wheel --upgrade
python3.9 -m pip install numpy cython scipy matplotlib ipython notebook h5py psutil pyvkfft --upgrade
python3.9 -m pip install scikit-image hdf5plugin h5glance silx fabio ipywidgets ipympl scikit-learn --upgrade
python3.9 -m pip install mpi4py --upgrade 
python3.9 -m pip install pybind11 mako
python3.9 -m pip install pyopencl --upgrade
has_pyopencl=1
python3.9 -m pip install pyqt5 pyopengl
python3.9 -m pip install scikit-cuda

# install pycuda
mkdir dev
cd dev
wget https://files.pythonhosted.org/packages/5a/56/4682a5118a234d15aa1c8768a528aac4858c7b04d2674e18d586d3dfda04/pycuda-2021.1.tar.gz
tar xf pycuda-2021.1.tar.gz 
cd pycuda-2021.1/
python configure.py --cuda-root=$CUDA_PATH --cxxflags="-std=c++11"
make
make install
cd ..

# install pynx
curl -O http://ftp.esrf.fr/pub/scisoft/PyNX/pynx-latest.tar.bz2 
tar xf pynx-latest.tar.bz2 
cd pynx/
pip install .