XRD-CT Sim Module
xrdct: Simulation of 2D XRD-CT Data from 1D Diffraction Patterns
This module provides a virtual acquisition framework for simulating 2D X-ray diffraction computed tomography (XRD-CT) datasets using 1D diffraction sinogram data. The class nDVAcq allows users to: - Define acquisition strategies and scan parameters. - Convert 1D diffraction patterns into 2D diffraction frames. - Simulate detector readout with optional noise models. - Save the acquired data in multiple formats (cbf, edf, tiff). - Export and import scan parameters for reproducibility.
This simulation framework is useful for validating and optimizing XRD-CT reconstruction algorithms and processing workflows.
@author: Dr A. Vamvakeros
- class nDTomo.sim.xrdct.nDVAcq(mask=None, file_format='cbf', fastaxis='Translation', slowaxis='Rotation', units='q_A^-1')[source]
Bases:
objectSimulates the acquisition of 2D X-ray diffraction computed tomography (XRD-CT) data using 1D diffraction sinogram data.
This class enables the simulation of various scan strategies, detector configurations, and acquisition parameters. It supports data export in multiple formats and includes options for adding Poisson noise to the simulated frames.
- Parameters:
mask (np.ndarray or None, optional) – A mask for the detector area (default is None).
file_format (str, optional) – Format for saving the acquired frames. Options: ‘cbf’, ‘edf’, ‘tiff’ (default is ‘cbf’).
fastaxis (str, optional) – Axis along which fast scanning occurs. Options: ‘Translation’ or ‘Rotation’ (default is ‘Translation’).
slowaxis (str, optional) – Axis along which slow scanning occurs. Options: ‘Translation’ or ‘Rotation’ (default is ‘Rotation’).
units (str, optional) – Units for the diffraction pattern conversion (default is “q_A^-1”).
- conv1Dto2D(I, msk=None, units='q_A^-1')[source]
Converts a 1D diffraction pattern into a 2D diffraction image.
- Parameters:
I (np.ndarray) – 1D diffraction intensity data.
msk (np.ndarray, optional) – Optional mask for the detector.
units (str, optional) – Units for the diffraction pattern (default is “q_A^-1”).
- Returns:
The generated 2D diffraction image.
- Return type:
np.ndarray
- readponi(poni)[source]
Reads detector calibration parameters from a PONI file.
- Parameters:
poni (str) – Path to the PONI calibration file.
- readscanprms(fn=None)[source]
Reads the scan parameters from an HDF5 file.
- Parameters:
fn (str, optional) – Path to the scan parameters file. If None, uses the default path based on savedir and dname.
- setdata(data, xaxis)[source]
Sets the 1D diffraction sinogram data for acquisition.
- Parameters:
data (np.ndarray) – A 3D array of shape (ntrans, nproj, nch), representing the sinogram data.
xaxis (np.ndarray) – The axis for the 1D diffraction patterns.
- setdetector(detpixsz1=0.000172, detpixsz2=0.000172, shape=(1679, 1475))[source]
Sets the detector properties.
- setscanprms(trans, nproj, fastaxis='Translation', slowaxis='Rotation')[source]
Sets the scan parameters for the simulation.
- setwvl(wvl)[source]
Sets the X-ray wavelength.
- Parameters:
wvl (float) – X-ray wavelength in meters.
- setxrdprms(dist, poni1, poni2, rot1, rot2, rot3)[source]
Sets the XRD calibration parameters.
- Parameters:
dist (float) – Sample-to-detector distance.
poni1 (float) – Detector calibration parameter (first coordinate).
poni2 (float) – Detector calibration parameter (second coordinate).
rot1 (float) – First rotation parameter.
rot2 (float) – Second rotation parameter.
rot3 (float) – Third rotation parameter.
- start_scan(addnoise='No', ct=0.1)[source]
Simulates the data acquisition process.
The function performs the virtual scan according to the defined scan type, fast axis, and slow axis. It iterates over the projections and translations to generate 2D diffraction frames.
- write_cbf(fn)[source]
Saves the current frame as a CBF file.
- Parameters:
fn (str) – Full path to the output file.
- write_edf(fn)[source]
Saves the current frame as an EDF file.
- Parameters:
fn (str) – Full path to the output file.