Skip to main content

de-ebsd

Differentiable, GPU-accelerated EBSD: dynamical master-pattern simulation from a crystal structure, native Monte Carlo electron transport, orientation indexing, gradient and high-resolution refinement, pattern-center calibration and HR-EBSD strain. The API is composable and object oriented, in the manner of abTEM.

A master pattern is the backscattered-electron intensity as a function of crystal direction, stored on the square-Lambert grid. de-ebsd builds it from first principles, crystal, structure factors with absorption, reflections, Bloch-wave dynamical solve, depth integration over a Monte Carlo exit-depth profile - and then runs the inverse problem against measured patterns. The results are validated against EMsoft (Callahan & De Graef 2013).

Installation

Windows / Linux with uv (Python >= 3.11; torch comes from the CUDA 12.4 index on Windows and the CPU index on Linux, configured in pyproject.toml):

git clone https://github.com/directelectron/de-ebsd
cd de-ebsd
uv sync

The distribution is named de-ebsd; the Python package is de_ebsd. The fused CUDA kernels of live indexing need CuPy: uv sync --extra live.

Quickstart: simulation

import de_ebsd as de

crystal = de.Crystal.from_parameters(
    a=0.5431, space_group=227, atoms=[("Si", (0.125, 0.125, 0.125))]
)
microscope = de.Microscope(energy=20e3, sample_tilt=70.0)
sim = de.MasterPatternSimulator(
    crystal,
    microscope,
    npx=500,
    dmin=0.05,
    bethe=de.BetheParameters(),
    # backend="bloch_smatrix" is the default: the batched dynamical solve.
    # "bloch" is the one-direction-at-a-time float64 reference it reproduces.
)

# every stage is inspectable (all figures render through anyplotlib):
sim.structure_factors().show()  # |U_g| per family, absences, V_0
sim.reflections(k=(0, 0, 1)).show()  # Bethe strong / weak split for one beam
sim.dynamical_matrix(k=(0, 0, 1)).show()

master = sim.compute(device="cuda")  # -> MasterPattern
master.show(projection="lambert")  # also "stereographic" and "sphere"
sim.crystal.show()  # real 3-D expanded crystal structure

# refine and recompute (structure factors are reused when still valid):
better = sim.refine(npx=1000, dmin=0.04)

# project to a detector for a batch of orientations (orix Rotation):
detector = de.EBSDDetector(shape=(480, 480), pattern_center=(0.5, 0.5, 0.6))
patterns = master.project(detector, orientation=rotations)

# interactive geometry widget in Jupyter (anywidget):
sim.show_setup(detector=detector)

# phase composition for Jupyter or a host application; figures stay native:
phase = sim.crystal.overview(master_pattern=master)
sim.microscope.show(detector=detector, crystal=sim.crystal)

# STEM zone-axis exploration: geometric Kikuchi lines + kinematic spots,
# independently toggleable in one projection; no master pattern required:
explorer = sim.crystal.explore(energy_kev=200, dmin=0.1)

The exit-depth statistics the dynamical solve integrates over come from a native Monte Carlo (de_ebsd.sim.montecarlo) unless you pass a DepthDistribution, for example one read from an EMsoft Monte Carlo file.

License

GPL-3.0-or-later. See LICENSE and NOTICE for the work this package is built on.

Metadata

Release files for de-ebsd 0.7.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 de-ebsd 0.7.0
File Size Uploaded Provenance Actions
de_ebsd-0.7.0.tar.gz 390.7 kB With provenance Details for de_ebsd-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for de-ebsd 0.7.0
File Interpreter ABI Platform Actions
de_ebsd-0.7.0-py3-none-any.whl Python 3 none any Details for de_ebsd-0.7.0-py3-none-any.whl

Total release size: 774.6 kB

Release files / de_ebsd-0.7.0.tar.gz

Download URL de_ebsd-0.7.0.tar.gz
Size 390.7 kB
Tags Source
SHA-256 checksum
How to use checksums
31432a4b543df73c5b8cb22d20b846b7939d4f994995a6b20a12b7f648c3fcb8
BLAKE2b-256 checksum
How to use checksums
9a87edd358239d77d82ee9c255e7f114dfc4aaf7314b21f7320e24f049360f05
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 20, 2026.

Transparency log

Release files / de_ebsd-0.7.0-py3-none-any.whl

Download URL de_ebsd-0.7.0-py3-none-any.whl
Size 383.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a33e1dce4e10f043a96be242d513185d7bb6215527db31087b19a494b37eeb1
BLAKE2b-256 checksum
How to use checksums
6e7e64211538e45e667aec705b5074969ca5448a1cb907be8397b8e2c2900b97
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 20, 2026.

Transparency log

Security for de-ebsd 0.7.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 de_ebsd-0.7.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 20, 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.

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