Skip to main content

powerxrd

Minimal, extensible Python tools for powder XRD analysis with a lightweight Rietveld refinement engine.


✨ Overview

powerxrd is a modular framework for:

  • Parsing powder XRD data
  • Background subtraction and smoothing
  • Peak analysis
  • Lightweight Rietveld refinement
  • Extensible lattice definitions

It is not a replacement for FullProf or GSAS.

It is a compact, inspectable refinement engine designed for:

  • Teaching
  • Prototyping
  • Research exploration
  • Algorithm experimentation
  • Rapid lattice model development

🧱 Architecture

The package is organized into clear layers:

Lattice  → geometry only (d-spacing, HKL generation)
Model    → profile + background + peak physics
Refine   → least-squares optimization
Workflow → staged refinement orchestration
Chart/Data → preprocessing utilities

This separation allows you to extend:

  • New lattice systems (tetragonal, hexagonal, etc.)
  • Alternative peak shapes
  • Custom refinement strategies
  • Structure factor implementations

The lattice layer is fully abstracted through BaseLattice, enabling clean geometric extensions.


📦 Installation

From PyPI (for users)

pip install powerxrd

🛠 Development Setup (recommended: uv)

PowerXRD uses uv for fast, reproducible dependency management.

Install uv:

pip install uv

Then inside the repository:

uv sync --group dev

This will:

  • Create a virtual environment automatically
  • Install runtime dependencies
  • Install development tools (pytest, ruff, mypy)

No manual venv activation required.

To run anything inside the project environment:

uv run python script.py

🚀 Quick Example

from powerxrd.lattice import CubicLattice
from powerxrd.model import PhaseModel
import powerxrd.refine as rr

# Define lattice
model = PhaseModel(lattice=CubicLattice(a=4.0))

# Load experimental data (example)
x_exp, y_exp = rr.load_data()

# Staged refinement
rr.refine(model, x_exp, y_exp, ["scale"])
rr.refine(model, x_exp, y_exp, ["bkg_intercept", "bkg_slope"])
rr.refine(model, x_exp, y_exp, ["a"])

# Plot final fit
rr.plot_fit(model, x_exp, y_exp, model.pattern(x_exp))

Full examples are available in:

examples/

Including extended hello_rietveld workflows.

Run them via:

uv run python examples/hello_rietveld_long.py

🧪 Development

Run tests:

make test

Lint:

make lint

Format:

make format

Type check:

make type

Build package:

make build

🧠 Philosophy

This project prioritizes:

  • Clarity over feature bloat
  • Extensibility over monolithic design
  • Numerical transparency
  • Minimal abstraction overhead
  • Inspectable scientific computation

It is intentionally small.

The goal is not to compete with large crystallographic suites — but to provide a clean, programmable refinement core.


📚 References

See RIETVELD_CLASSIC.md for foundational Rietveld literature and background resources.


License

MIT License © Andrew Garcia

Metadata

Release files for powerxrd 4.0.0

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

Source distribution (sdist)

Source distribution for powerxrd 4.0.0
File Size Uploaded
powerxrd-4.0.0.tar.gz 3.6 MB Details

Built distribution (wheel)

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

Total release size: 3.6 MB

Release files / powerxrd-4.0.0.tar.gz

Download URL powerxrd-4.0.0.tar.gz
Size 3.6 MB
Tags Source
SHA-256 checksum
How to use checksums
6e4c435722c1aa3fb9743d08bff5a0f135c61db43e7099a6f53a57818ca3c881
BLAKE2b-256 checksum
How to use checksums
95d1d2a104fe091600475df09a800d1de7ed7a5a43355d49f759584685131a8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / powerxrd-4.0.0-py3-none-any.whl

Download URL powerxrd-4.0.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b180d8dc3e9de9796317bb7db44234b88314affd7c11e58363b2910258643d8a
BLAKE2b-256 checksum
How to use checksums
2bac7aa09b59c457d10f10ad4f952a60dde585380c8b37bb0d8a9a218cde371d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.0.0

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.8

2 release files

2.1.7

2 release files

2.1.6

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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