Skip to main content

ReflectoFit

Tests License: MIT

The first run below: Poisson counts from examples/film.toml, the starting model and the fit, with normalised residuals

A fast X-ray reflectivity fitting engine and command line: layer models, an instrument model, least squares, differential evolution and MCMC, model selection, and fit reports.

It is for anyone with a measured specular XRR curve of a thin film who wants the thickness, roughness and density of each layer. The forward model is a float64 Parratt recursion (compiled with numba) with Névot-Croce roughness, Gaussian resolution, beam footprint, Cu Kα₂ and a 2θ offset; it agrees with refnx to 1e-10. A torch backend gives the same curves with gradients. The forward physics lives in ReflectoSim, which also generates synthetic XRR data for machine learning; ReflectoFit is the inverse problem on top of it.

Status: early development. The design is in docs/DESIGN.md; model selection follows.

Forward-model curves per second against batch size for seven engines, for one film, five layers and a 50-layer superlattice

Forward-model throughput on the benchmark machine (docs/design-bench/throughput.json, DESIGN.md section 5). The numba backend computes about 57 000 five-layer curves per second in batches of 100 000 on CPU; hollow markers are values scaled or extrapolated from a smaller batch.

Install

Not on PyPI yet. From a clone, with uv:

git clone https://github.com/NaNIsaac/ReflectoFit
cd ReflectoFit
uv sync

First run

Simulate a measured curve of a 240 Å film on SiO₂ on Si with Poisson counts, then fit it from a wrong starting guess:

uv run reflectofit calc --model examples/film.toml --counts 1e8 -o film.dat
uv run reflectofit fit film.dat --model examples/film_start.toml --loss poisson --counts-scale 1e8 -o fit

The fit prints each free parameter with its standard error and writes fit/result.json, fit/model.toml (the fitted model, reusable as a start) and fit/fitted.dat.

Model files, every command and the Python API: docs/usage.md.

Development

uv run pytest

License

MIT

Metadata

Release files for reflectofit 0.1.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 reflectofit 0.1.0
File Size Uploaded Provenance Actions
reflectofit-0.1.0.tar.gz 21.8 kB With provenance Details for reflectofit-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 46.8 kB

Release files / reflectofit-0.1.0.tar.gz

Download URL reflectofit-0.1.0.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8ace852495c027fb70c77df70e96ecfc5f82f1bdab506d7b17aa7f5f4919f3d3
BLAKE2b-256 checksum
How to use checksums
4470ceabf08b1d35fe46329b465116014b0926fc8afa14b3719ac867d6003b80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / reflectofit-0.1.0-py3-none-any.whl

Download URL reflectofit-0.1.0-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ab735655fc9a270205928bcbc7759c0ad1f3f7c494fafc4385545fcdeb3ef52
BLAKE2b-256 checksum
How to use checksums
59bb2633de352da175875bbf990503b532fef41afd4f6485df932cd8f4515e5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for reflectofit 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for reflectofit-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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