DMCpy: A powder and single crystal neutron diffraction software for DMC
The recently upgraded DMC diffractometer at SINQ, equipped with a state-of-the-art 2D He detector, enables high-resolution neutron diffraction experiments optimized for both powder and single-crystal studies. To address the increased complexity and volume of data produced by this instrument, we developed DMCPy, a Python-based software package tailored specifically for DMC data analysis. DMCPy facilitates seamless data reduction and visualization, supporting conversion to reciprocal space, normalization, and masking of detector artifacts. Its modular architecture integrates tools for analyzing both powder diffraction patterns and single-crystal datasets, including advanced visualization features like 3D reciprocal space mapping and interactive scan inspection. By streamlining workflows and enhancing data interpretation, DMCPy empowers researchers to unlock the full potential of the DMC instrument for probing nuclear and magnetic structures in condensed matter systems.
💡 Research Summary
The paper presents DMCPy, a Python‑based software suite specifically designed for the upgraded DMC neutron diffractometer at SINQ, which now features a large‑area 2‑D He detector. The instrument’s capability to perform both high‑resolution powder and single‑crystal experiments generates massive, complex datasets that cannot be handled efficiently with traditional reduction tools. DMCPy addresses this challenge through a modular architecture comprising six core modules (DataFile, Sample, DataSet, Viewer3D, InteractiveViewer, RLUAxes) and auxiliary scripts for file handling and utility functions.
Data ingestion is performed by the DataFile object, which reads raw detector files (typically HDF5) and converts pixel coordinates into experimental Q‑space using the Lumsden coordinate system and Bragg’s law. A detector‑wide normalization table, derived from a long‑duration vanadium measurement, corrects for inter‑module sensitivity variations; defective pixels are masked by inserting NaN values, ensuring they are ignored in all downstream analyses.
Sample orientation is handled by the Sample object, which constructs the UB matrix by combining a unitary rotation matrix (U) that aligns the crystal with the instrument and a B matrix derived from the crystal’s unit cell parameters. The software supports both manual peak selection and an automated peak‑suggestion algorithm (described in Appendix 7) to facilitate rapid UB determination.
Because DMC experiments can produce datasets containing tens of millions of detector pixels (e.g., a 60° rotation scan with 0.1° steps and two detector positions yields >88 million points), DMCPy implements “lazy calculation” and batch processing. The DataSet object acts as an advanced list that streams portions of the data into memory, performs on‑the‑fly calculations, and writes intermediate results to disk, thereby keeping RAM usage within the limits of a typical laptop.
Visualization tools are a central feature. Viewer3D provides interactive 3‑D navigation of reciprocal‑space volumes, while InteractiveViewer displays raw detector images with sliders for sample rotation (A3), summed intensity along the detector’s vertical (z) direction, and intensity versus scattering angle (2θ). The RLUAxes module overlays reciprocal‑lattice grids that automatically adapt to the chosen space group and unit cell, guaranteeing distortion‑free plots across different crystallographic settings.
For powder data, DMCPy offers two integration strategies: Q‑space binning (default step 0.125 Å⁻¹) and vertical integration (ignoring the out‑of‑plane component). Users can apply angular masks (e.g., 5° or 10°) to improve low‑angle peak resolution at the cost of reduced statistics. Export functions generate data in PSI‑powder or xy formats, which are directly readable by standard Rietveld packages such as FullProf, GSAS‑II, and Jana2020.
The software is distributed via PyPI, compatible with Python 3.6+, and depends on widely used scientific libraries (NumPy, SciPy, Pandas, Matplotlib, h5py). It is released under the Mozilla Public License 2.0, allowing free modification and redistribution.
Validation is demonstrated on MnS and MnO samples, showing that Q‑space integration yields more symmetric peaks than vertical integration, and that the vanadium‑based normalization effectively removes module‑specific intensity artifacts. The authors note current limitations: the absence of a standalone GUI application and limited support for MPI‑based parallel processing on high‑performance clusters. Future development plans include a web‑based dashboard and enhanced parallelism to further accelerate large‑scale analyses.
In summary, DMCPy provides a comprehensive, memory‑efficient, and highly visual workflow for reducing, normalizing, and analyzing both powder and single‑crystal neutron diffraction data from the DMC instrument, thereby significantly streamlining the path from raw measurements to scientific insight.
Comments & Academic Discussion
Loading comments...
Leave a Comment