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: object

Simulates 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”).

azimint()[source]

Initializes the azimuthal integrator for diffraction pattern conversion.

calcbeamcentre()[source]

Computes the beam center coordinates based on detector parameters.

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.

run()[source]

Starts the virtual acquisition process.

saveprms()[source]

Saves the scan parameters to an HDF5 file.

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.

Parameters:
  • detpixsz1 (float, optional) – Pixel size along the first dimension (default is 172 µm).

  • detpixsz2 (float, optional) – Pixel size along the second dimension (default is 172 µm).

  • shape (tuple of int, optional) – Detector shape in pixels (default is (1679, 1475)).

setdirs(savedir, dname)[source]

Sets the directory and filename for saving the acquired data.

Parameters:
  • savedir (str) – Directory where the acquired frames will be saved.

  • dname (str) – Base filename for the output files.

setscanprms(trans, nproj, fastaxis='Translation', slowaxis='Rotation')[source]

Sets the scan parameters for the simulation.

Parameters:
  • trans (int) – Number of translation steps (detector elements).

  • nproj (int) – Number of projections (angular steps).

  • fastaxis (str, optional) – Fast scanning axis. Options: ‘Translation’, ‘Rotation’.

  • slowaxis (str, optional) – Slow scanning axis. Options: ‘Translation’, ‘Rotation’.

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.

Parameters:
  • addnoise (bool, optional) – If True, applies Poisson noise to the frames (default is False).

  • ct (float, optional) – Scaling factor for the noise model (default is 0.1).

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.

write_frame(fn)[source]

Saves the current diffraction frame in the specified format.

Parameters:

fn (str) – Filename without extension. The extension is determined by the selected file format.

write_h5()[source]

Placeholder method for saving frames in HDF5 format.

write_tiff(fn)[source]

Saves the current frame as a TIFF file.

Parameters:

fn (str) – Full path to the output file.