A package containing file readers for XRD raw files.
Project description
fairmat-readers-xrd
A package developed by FAIRmat and collaborators that contains file readers for various X-ray diffraction (XRD) file formats.
Install and use
To use the readers, install the package using pip and import the read_file
function. It will check the file extension and, using an appropriate file
reader, return a Python dictionary containing the data.
pip install fairmat-readers-xrd
from fairmat_readers_xrd import read_file
file_path = "<filepath>.xrdml"
data_dict = read_file(file_path)
You can also import individual file readers.
from fairmat_readers_xrd import read_panalytical_xrdml, read_bruker_raw
# Read PANalytical XRDML file
file_path = "<filepath>.xrdml"
data_dict = read_panalytical_xrdml(file_path)
# Read Bruker/Siemens RAW v4 file
raw_file_path = "<filepath>.raw"
raw_data_dict = read_bruker_raw(raw_file_path)
Currently, the following file extensions are supported:
| File Extension | Corresponding Reader Function | Vendor/Format | Notes |
|---|---|---|---|
.xrdml |
read_panalytical_xrdml |
PANalytical | |
.rasx |
read_rigaku_rasx |
Rigaku | |
.brml |
read_bruker_brml |
Bruker | |
.raw |
read_bruker_raw |
Bruker/Siemens RAW v4 | Single-axis scans only, extracts anode material and wavelengths |
Note on .raw files: The parser supports Bruker/Siemens RAW v4 format for single-axis theta-2theta powder diffraction scans. It extracts:
- Scan parameters (angles, step size, scan axis)
- X-ray tube anode material (from binary file offset 0x01A8)
- Wavelengths (K-alpha1, K-alpha2, K-beta) via lookup table from International Tables for Crystallography
Multi-axis scans (texture, pole figures) are not validated and may not parse correctly.
Development
The package is still under development. To contribute, start with simply raising an issue on the repo.
Contributing code
In case you want to contribute a piece of code, or a whole new reader, clone the repo in your local and start a virtual Python environment inside the directory.
git clone git@github.com:FAIRmat-NFDI/readers-xrd.git
cd readers-xrd
python3 -m venv .pyenv
source .pyenv/bin/activate
Then install the package in editable mode (-e flag), with dev dependencies.
You can also run the pytest to confirm all went well.
As a recommended practice, you can also install the pre-commit hook for linting (more on
this here).
python -m pip install --upgrade pip
pip install -e .[dev]
pytest
pre-commit install
Now you can start tinkering around on a new branch (or a fork).
If you want to contribute the code back to the upstream, simply create a
Pull Request (PR),
and we will get back to you. As a good practice, add tests for new readers and
make sure existing tests (pytest) are passing before creating PR.
Ruff
We have placed GitHub actions for checking the linting. This can lead to your PR failing
the CI tests in case your code is not correctly linted or formatted.
Best way to avoid this is to use Ruff for
automatic linting and formatting.
This is already part of the dev environment and you can run Ruff before committing:
ruff check --fix
ruff format
Ruff pre-commit hook
Additionally, we also provide pre-commit hook for Ruff. This will run Ruff every time you try to commit and raise errors (and provide fixes) in case your code needs linting or formatting. You simply have to add these fixes and commit again.
To use this pre-commit hook, make sure to run the following in the terminal after you clone the repo:
pre-commit install
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 fairmat_readers_xrd-0.0.8.tar.gz.
File metadata
- Download URL: fairmat_readers_xrd-0.0.8.tar.gz
- Upload date:
- Size: 6.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd4f996e6eca6677b91f2864cc1c5a2704025721d72bd92475e990898a07f105
|
|
| MD5 |
c7e1ba6d31695e20d1c1eeac1f166c26
|
|
| BLAKE2b-256 |
f69f6c8ecbac08b98821fd5e7c71fed480d19ac2769107f4d23211d4c22b9637
|
File details
Details for the file fairmat_readers_xrd-0.0.8-py3-none-any.whl.
File metadata
- Download URL: fairmat_readers_xrd-0.0.8-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19d8d7333cf248846515a005dd687e0cbd33b6d604c42cd7ca6cf365d39b6aa8
|
|
| MD5 |
8c7566efe25fe1169d8c7a3156493c8d
|
|
| BLAKE2b-256 |
2f85690b40bf3fc342db5d55cee799405b5baad4047c48f34d4e0d0500de2419
|