Skip to main content

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fairmat_readers_xrd-0.0.9.tar.gz (6.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fairmat_readers_xrd-0.0.9-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file fairmat_readers_xrd-0.0.9.tar.gz.

File metadata

  • Download URL: fairmat_readers_xrd-0.0.9.tar.gz
  • Upload date:
  • Size: 6.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fairmat_readers_xrd-0.0.9.tar.gz
Algorithm Hash digest
SHA256 40bf62e0f8599aba58b6e681263be9766d5a9a44da33178a21ea785625df018b
MD5 74d7750d3c83a1ddd13e2a6c96a30f69
BLAKE2b-256 cc2b658735188b78520195569c492279a3fb54b025c4b233774b0d56ada5c7b8

See more details on using hashes here.

File details

Details for the file fairmat_readers_xrd-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for fairmat_readers_xrd-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8e7e4e72b97753968489870216bdb61fb16aaa15874d1215bb7fa552f0d9dd2f
MD5 b61150b66622bde72bb769770f2fabfc
BLAKE2b-256 30658cb62692153934186c4d338fc207dad5fef89ea1c2dfc5f413bfa8e6207a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page