midas-pink
Pink-beam (and white-beam) HEDM analysis via a spectrum-aware differentiable forward model.
midas-pink extends midas-diffract
from monochromatic to arbitrary illumination spectra by integrating
S(E) as a discrete weighted sum over per-energy mono forward
evaluations. The construction unifies monochromatic, pink, and white
HEDM under a single differentiable computational graph with no change
to the loss, the optimiser, or the parameterisation.
Companion paper. Sharma, Andrejevic, Cherukara, "Pink-Beam High-Energy Diffraction Microscopy via a Differentiable Forward Model with Spectrum-Aware Inversion," IUCrJ (submitted, 2026). Full text and reproducible scripts in
dev/paper/.
Install
pip install midas-pink # post-publication
# or, for development:
pip install -e packages/midas_pink/
Requires midas-diffract>=0.1.0 and midas-hkls>=0.1.0.
Notebooks
Worked-example Jupyter notebooks live in notebooks/. They are not shipped with pip install — get them by cloning the MIDAS repository.
Quick start
import torch
import midas_diffract as md
import midas_pink as mp
# 1. Spectrum: fixed Gaussian pink S(E) FWHM/E0 = 1e-2
spec = mp.ParameterisedSpectrum(
E0_keV=71.6764, half_bw=0.03, n_samples=51,
init_kind="gaussian", init_rel_bw=1e-2, fixed=True,
)
# 2. Per-energy mono model bank from a geometry factory
def geom(lam_A):
return md.HEDMGeometry(
Lsd=1_000_000.0, y_BC=1024.0, z_BC=1024.0, px=200.0,
omega_start=-180.0, omega_step=0.25, n_frames=1440,
n_pixels_y=2048, n_pixels_z=2048,
min_eta=6.0, wavelength=lam_A,
)
from midas_hkls import SpaceGroup, Lattice
bank = mp.build_pink_bank(
spec,
space_group=SpaceGroup.from_number(225), # FCC
lattice=Lattice.for_system("cubic", a=4.078),
geom_factory=geom, two_theta_max_deg=8.0,
)
# 3. Pick ROIs from the ground-truth state, splat observation
plan = mp.plan_rois_from_state(
bank, euler.unsqueeze(0), pos.unsqueeze(0),
lattice_params=latc, roi_h=31, roi_w=31,
)
observed = mp.splat_rois(bank, plan, euler.unsqueeze(0), pos.unsqueeze(0),
latc, sigma_psf_px=1.5)
# 4. Recover (orientation, lattice) from a perturbed initial guess
result = mp.recover_grain_state(
bank, plan, observed,
init_euler=init_euler, init_position=init_pos, init_lattice=init_latc,
cfg=mp.RecoveryConfig(sigma_psf_px=1.5),
)
print("misori (m-deg):", result["misori_mdeg"])
print("strain err max:", result["strain_err_max"])
What's in the package
| Module | What it provides |
|---|---|
midas_pink.spectrum |
ParameterisedSpectrum -- learnable softmax-normalised energy weights over a fixed dense grid |
midas_pink.inverse |
build_pink_bank, plan_rois_from_state, splat_rois (2D), splat_rois_3d (3D, with frame axis), recover_grain_state (mono/pink with known S(E)), recover_joint (joint S(E) + grain fit with optional centroid pin), fit_spectrum_to_rois (two-stage calibrant fit) |
Form factor (via midas_hkls.form_factor), Lorentz-polarization, and
mosaicity are optional per-spot weighting in splat_rois / splat_rois_3d.
Reproducing the paper
All synthetic results in the companion paper are reproducible from
dev/paper/scripts/. See dev/paper/README.md
for the per-proto index.
License
BSD-3-Clause.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file midas_pink-0.1.0.tar.gz.
File metadata
- Download URL: midas_pink-0.1.0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3f2e23adf6d42272b1e502259f94b8a4deec96d4c8131a8c9a85f6482e2710c
|
|
| MD5 |
41c7c900b5519e73ce75fb6e4bf139c0
|
|
| BLAKE2b-256 |
8c320c0dd52ea9a9ba9e532bce4fd7e5354fffe789d951accfb86a7e4cbc2f83
|
Provenance
The following attestation bundles were made for midas_pink-0.1.0.tar.gz:
Publisher:
python-packages.yml on marinerhemant/MIDAS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midas_pink-0.1.0.tar.gz -
Subject digest:
d3f2e23adf6d42272b1e502259f94b8a4deec96d4c8131a8c9a85f6482e2710c - Sigstore transparency entry: 2281793673
- Sigstore integration time:
-
Permalink:
marinerhemant/MIDAS@39dcce1352a4159dfa4d808587ce28eba6de5b35 -
Branch / Tag:
refs/tags/midas-pink-v0.1.0 - Owner: https://github.com/marinerhemant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-packages.yml@39dcce1352a4159dfa4d808587ce28eba6de5b35 -
Trigger Event:
release
-
Statement type:
File details
Details for the file midas_pink-0.1.0-py3-none-any.whl.
File metadata
- Download URL: midas_pink-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9251c933063e19a627a5974c5137ec30b344149cc29e0b2dd1ed3081d282ad9
|
|
| MD5 |
1e688333cb4271b20ff9c1ea1de5f7a4
|
|
| BLAKE2b-256 |
4bb31d4fef42bcf8c21f5e21d2c3ce8499ff6a7155645ebd7c1b02f89969c2f8
|
Provenance
The following attestation bundles were made for midas_pink-0.1.0-py3-none-any.whl:
Publisher:
python-packages.yml on marinerhemant/MIDAS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midas_pink-0.1.0-py3-none-any.whl -
Subject digest:
e9251c933063e19a627a5974c5137ec30b344149cc29e0b2dd1ed3081d282ad9 - Sigstore transparency entry: 2281793707
- Sigstore integration time:
-
Permalink:
marinerhemant/MIDAS@39dcce1352a4159dfa4d808587ce28eba6de5b35 -
Branch / Tag:
refs/tags/midas-pink-v0.1.0 - Owner: https://github.com/marinerhemant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-packages.yml@39dcce1352a4159dfa4d808587ce28eba6de5b35 -
Trigger Event:
release
-
Statement type: