Ultra-fast Python package for X-ray optical properties calculation with CXRO/NIST data, CLI tools, and synchrotron applications
Project description
XRayLabTool
Python package and CLI for calculating X-ray optical properties of materials using CXRO/NIST atomic scattering factor data.
Installation
pip install xraylabtool
# Or with uv (recommended for development)
git clone https://github.com/imewei/pyXRayLabTool.git
cd pyXRayLabTool
uv sync
Quick Start
Python API
import xraylabtool as xlt
# Single material at 10 keV
result = xlt.calculate_single_material_properties("SiO2", 10.0, 2.2)
print(f"Critical angle: {result.critical_angle_degrees[0]:.3f}°")
print(f"Attenuation length: {result.attenuation_length_cm[0]:.2f} cm")
# Multiple materials comparison
materials = {"SiO2": 2.2, "Si": 2.33, "Al2O3": 3.95, "C": 3.52}
results = xlt.calculate_xray_properties(
list(materials.keys()), 10.0, list(materials.values())
)
for formula, r in results.items():
print(f"{formula:6}: θc = {r.critical_angle_degrees[0]:.3f}°")
Command-Line Interface
xraylabtool calc SiO2 -e 10.0 -d 2.2 # Single material
xraylabtool calc Si -e 5-15:11 -d 2.33 -o out.csv # Energy sweep
xraylabtool convert energy 8.048,10.0 --to wavelength
xraylabtool formula Al2O3 # Formula analysis
xraylabtool bragg -d 3.14,2.45 -e 8.048 # Bragg angles
xraylabtool batch materials.csv -o results.csv # Batch processing
xraylabtool completion install # Shell tab-completion
GUI
python -m xraylabtool.gui
Single-material analysis and multi-material comparison with interactive plots and CSV/PNG export.
Calculated Properties
| Property | Field | Unit |
|---|---|---|
| Dispersion coefficient | dispersion_delta |
dimensionless |
| Absorption coefficient | absorption_beta |
dimensionless |
| Scattering factors | scattering_factor_f1, f2 |
electrons |
| Critical angle | critical_angle_degrees |
degrees |
| Attenuation length | attenuation_length_cm |
cm |
| Scattering length density | real_sld_per_ang2, imaginary_sld_per_ang2 |
Å⁻² |
All properties are returned as NumPy arrays in the XRayResult dataclass, supporting single energies or energy sweeps.
Scientific Background
Calculations use Henke, Gullikson, and Davis atomic scattering factor tabulations (0.03–30 keV):
- Refractive index: n = 1 - δ - iβ
- Critical angle: θc = √(2δ)
- Attenuation: Beer-Lambert law with μ = 4πβ/λ
Documentation
Full documentation: pyxraylabtool.readthedocs.io
Development
make test # Run tests with coverage
make test-all # Full suite (unit + integration + perf + CLI)
make format # Format with ruff
make lint # Lint with ruff
make docs # Build Sphinx docs
Citation
@software{xraylabtool,
title = {XRayLabTool: High-Performance X-ray Optical Properties Calculator},
author = {Wei Chen},
url = {https://github.com/imewei/pyXRayLabTool},
year = {2024}
}
License
MIT License. See LICENSE for details.
Acknowledgments
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xraylabtool-0.4.0.tar.gz.
File metadata
- Download URL: xraylabtool-0.4.0.tar.gz
- Upload date:
- Size: 555.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61af084f256958cacdb6c6131d717201f421f84e56db510d3ce5cae5c97683c3
|
|
| MD5 |
3767c3d89c222d9cb705a70b3584ffb6
|
|
| BLAKE2b-256 |
e62c6ceb7af4352875becf5247ab3d0533258f30b3d8a92c681774c887572848
|
Provenance
The following attestation bundles were made for xraylabtool-0.4.0.tar.gz:
Publisher:
publish.yml on imewei/pyXRayLabTool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xraylabtool-0.4.0.tar.gz -
Subject digest:
61af084f256958cacdb6c6131d717201f421f84e56db510d3ce5cae5c97683c3 - Sigstore transparency entry: 1248272244
- Sigstore integration time:
-
Permalink:
imewei/pyXRayLabTool@9d2ed40c1a2b0eb2e424aec6a6481060e72afd9d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/imewei
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9d2ed40c1a2b0eb2e424aec6a6481060e72afd9d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file xraylabtool-0.4.0-py3-none-any.whl.
File metadata
- Download URL: xraylabtool-0.4.0-py3-none-any.whl
- Upload date:
- Size: 640.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2f669dd5604635352251829946fee2bc311ce6878069a6caf3c29a5891d28b4
|
|
| MD5 |
fa396be0f18653fd720cba56bd62537b
|
|
| BLAKE2b-256 |
a21ba54137eeddb0ae0b72e50e9b244a2203a43dafbe9a66e118dc343e0e73d2
|
Provenance
The following attestation bundles were made for xraylabtool-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on imewei/pyXRayLabTool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xraylabtool-0.4.0-py3-none-any.whl -
Subject digest:
f2f669dd5604635352251829946fee2bc311ce6878069a6caf3c29a5891d28b4 - Sigstore transparency entry: 1248272691
- Sigstore integration time:
-
Permalink:
imewei/pyXRayLabTool@9d2ed40c1a2b0eb2e424aec6a6481060e72afd9d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/imewei
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9d2ed40c1a2b0eb2e424aec6a6481060e72afd9d -
Trigger Event:
workflow_dispatch
-
Statement type: