Skip to main content

xraydc — X-Ray Diffraction Cooking

xraydc provides X-ray diffraction recipes and helper functions for the nx5d analysis framework. Within the nx5d Spice Concept, it supplies the domain-specific logic that "cooks" raw detector data into reciprocal-space representations that are ready for physical interpretation.

Overview

  • QMapper maps angular detector images into reciprocal-space with coordinates $q_x$, $q_y$, and $q_z$ using well tested algorithms provided by xrayutilities.
  • sRSM generates static reciprocal-space maps from a single scan.
  • TRSM generates parameter-grouped reciprocal-space maps, for example over delay, temperature, or scan index.
  • QMapper.qmap_groupby() provides split-apply-combine Q-mapping over grouped xarray datasets.

The package is designed to work with xarray, supports arbitrary goniometer and detector geometries, and can be used with pixelated area detectors beyond the original beamline setup.

Provenance

xraydc originated at the KMC3-XPP beamline at BESSY II (Helmholtz-Zentrum Berlin). It is also used in the Ultrafast Dynamics group of Prof. Matias Bargheer (University of Potsdam) for laboratory-based plasma X-ray source time-resolved diffraction experiments.

The Q-mapping workflow has been used with the following detector and beamline combinations:

Facility Beamline Detector(s)
BESSY II KMC3-XPP Dectris Pilatus 100K, Dectris Eiger
MAX IV FemtoMAX Dectris Pilatus 1M
European XFEL MID AGIPD

Installation

pip install xraydc

Runtime dependencies:

Package Role
nx5d Data management and Spice framework
xrayutilities Angle-to-Q conversion backend
xarray Labelled multidimensional arrays
dask Lazy and parallel computation
scipy Scientific computing utilities

Quick Start

The example below uses the standard KMC3-XPP geometry with a Pilatus 100K detector and the actual motor names used at the beamline.

KMC3-XPP 4-circle goniometer geometry with θ, 2θ, χ, φ axes and area detector
Standard KMC3-XPP 4-circle geometry with Pilatus 100K area detector.

from xraydc.signal import QMapper

exp_setup = {
    "goniometerAxes": {
        "Theta_mea": "y-",
        "Chi": "x+",
        "Phi": "z+",
    },
    "detectorAxes": {
        "TwoTheta_mea": "y-",
    },
    "detectorTARAlign": [0.0, 0.0, 0.0],
    "imageAxes": ["y-", "z-"],
    "imageSize": [195, 487],
    "imageCenter": [95, 244],
    "imageDistance": 481.0,
    "imageChannelSize": [0.172, 0.172],
    "sampleFaceUp": "z+",
    "beamDirection": [1, 0, 0],
    "sampleNormal": [0, 0, 1],
    "beamEnergy": 10000.0,
}

mapper = QMapper(**exp_setup)

# raw_data is an xarray.Dataset containing detector images and angle arrays
q_data = mapper.qmap(raw_data)

# Example: 2D reciprocal-space projection
q_data_2d = mapper.qmap(raw_data, dims=("qx", "qz"))

Using nx5d Recipes

Inside an nx5d Spice pipeline, the recipe layer is usually called through nx5d rather than directly:

from xraydc.cooking import TRSM, sRSM

result = sRSM(scan_type, data, exp_info=exp_info, offsets=offsets)

result = TRSM(
    scan_type,
    data,
    exp_info=exp_info,
    qargs={"groupby": "delay", "dims": ("qy", "qz"), "qsize": None, "gridargs": None},
)

Repository Layout

src/xraydc/
├── signal.py     # QMapper and Q-space conversion logic
├── cooking.py    # nx5d-compatible XRD recipes
└── _version.py   # generated by setuptools_scm during packaging

scripts/
└── release.sh    # maintainer release helper

Development

# install package with test and documentation extras
pip install -e ".[all]"

# run the test suite
pytest

Release Workflow

The repository includes a maintainer release helper at scripts/release.sh.

./scripts/release.sh 0.2.3

Before creating and pushing the release tag, the script verifies:

  • semantic version format (X.Y.Z)
  • current branch is master
  • working tree is clean
  • local master is in sync with origin/master
  • tag vX.Y.Z does not already exist
  • setuptools_scm write_to target in pyproject.toml matches src/xraydc/_version.py

Notes:

  • Run the script from the repository root in Git Bash, Linux, or WSL.
  • The script asks for confirmation before creating and pushing the tag.
  • CI release jobs are triggered by the pushed tag.

License

GPLv3+ — see pyproject.toml for package metadata and licensing information.

Authors

  • Matthias Rössle (Helmholtz-Zentrum Berlin)
  • Alexander von Reppert (University of Potsdam)
  • Florin Boariu (Helmholtz-Zentrum Berlin)

Metadata

Release files for xraydc 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xraydc 0.4.1
File Size Uploaded Provenance Actions
xraydc-0.4.1.tar.gz 354.2 kB Without provenance Details for xraydc-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xraydc 0.4.1
File Interpreter ABI Platform Actions
xraydc-0.4.1-py3-none-any.whl Python 3 none any Details for xraydc-0.4.1-py3-none-any.whl

Total release size: 380.7 kB

Release files / xraydc-0.4.1.tar.gz

Download URL xraydc-0.4.1.tar.gz
Size 354.2 kB
Tags Source
SHA-256 checksum
How to use checksums
742664c524ad97c125ac3ab8ee09b166ba1d3415bc9cbe6f767ffbce8191a858
BLAKE2b-256 checksum
How to use checksums
30b84565290356b5bc7639a2232fef2315ae0ceea265d453e318ffe7996110fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Release files / xraydc-0.4.1-py3-none-any.whl

Download URL xraydc-0.4.1-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6ddbd3742dfea62c680ca94408c783b0003fca6da477b1e300ba2ff0bbec960
BLAKE2b-256 checksum
How to use checksums
2bb7bfdd97906c4d292d7fb110d0910f5db1422819c1641158d6a05d616aa475
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Security for xraydc 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page