Skip to main content

midas-peakfit

Differentiable PyTorch peak-fitting for FF-HEDM Zarr archives. A drop-in replacement for PeaksFittingOMPZarrRefactor (C/OpenMP/NLopt) with the following changes:

  • Optimizer: Nelder-Mead → batched Levenberg-Marquardt on CPU/CUDA
  • Backend: OpenMP → PyTorch (autograd, batched linear algebra)
  • Precision: fp64 default; --dtype float32 available for speed
  • Output: identical binary format (AllPeaks_PS.bin, AllPeaks_PX.bin)
  • CLI: drop-in compatible

The C tool is kept as the validation oracle. Output is scientifically equivalent to the C tool, not bit-exact (LM and Nelder-Mead converge to slightly different minima within the same basin).

Installation

pip install -e packages/midas_peakfit[dev]

or once published:

pip install midas-peakfit

PyTorch with CUDA support must be installed separately if GPU acceleration is desired. Follow the PyTorch install guide for the right wheel for your CUDA version.

Notebooks

Worked-example Jupyter notebooks live in notebooks/. They are not shipped with pip install — get them by cloning the MIDAS repository.

Usage

peakfit_torch DataFile.MIDAS.zip 0 1 8                    # CPU/CUDA auto
peakfit_torch DataFile.MIDAS.zip 0 1 8 --device cuda --dtype float32
peakfit_torch DataFile.MIDAS.zip 0 1 8 OutputFolder 1     # explicit ResultFolder + fitPeaks
peakfit_torch DataFile.MIDAS.zip 0 1 8 \
    --validate-against /path/to/c_AllPeaks_PS.bin         # parity check

Positional args mirror the C tool exactly: DataFile blockNr nBlocks numProcs [ResultFolder] [fitPeaks].

New flags:

Flag Default Meaning
--device {cpu,cuda} cuda if available else cpu Compute device
--dtype {float32,float64} float64 Numeric precision
--batch-size N 4096 Cross-frame region batch threshold
--validate-against PATH Compare to C-produced AllPeaks_PS.bin and emit parity report
--deterministic off Force deterministic algorithms (fp64 only)

Parity tolerances

Field Tolerance
nPeaks per frame, pixel sets, maxY/maxZ, returnCode, maskTouched exact
YCen, ZCen, Radius, diffY, diffZ ≤ 0.05 px
Eta ≤ 0.02°
IMax, IntegratedIntensity, RawSumIntensity ≤ 1% relative
BG, SigmaR, SigmaEta, σGR, σLR, σGEta, σLEta, MU, FitRMSE ≤ 5% relative

Downstream gate: indexer (IndexerOMP) on both outputs must produce identical grain orientations within 0.05° misorientation.

Output

Two binary files in {ResultFolder}/Temp/:

  • AllPeaks_PS.bin — peak summary (29 columns × nPeaks per frame; see FF_HEDM/src/PeaksFittingConsolidatedIO.h for layout).
  • AllPeaks_PX.bin — pixel coordinates for each peak.

These files are byte-compatible with the C tool's output and readable by ConsolidatedPeakReader/ConsolidatedPixelReader in that header.

Tests

cd packages/midas_peakfit
pytest tests/ -v                      # unit tests (fast)
pytest tests/ -v -m slow              # full pipeline parity (~3 min)
pytest tests/ -v -m gpu               # CUDA-only tests (skip on CPU)

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

midas_peakfit-0.5.0.tar.gz (131.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

midas_peakfit-0.5.0-py3-none-any.whl (124.5 kB view details)

Uploaded Python 3

File details

Details for the file midas_peakfit-0.5.0.tar.gz.

File metadata

  • Download URL: midas_peakfit-0.5.0.tar.gz
  • Upload date:
  • Size: 131.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for midas_peakfit-0.5.0.tar.gz
Algorithm Hash digest
SHA256 dc4a902275a80907f67b0b60ecf725be52f9a8d54d24755890f9b268ae502313
MD5 9fcd5eae688761806180c527a01ad557
BLAKE2b-256 42943ad30e69693e2527e5c02355c155d61a6c7ba4aa0f2ace8fdb0094fa4767

See more details on using hashes here.

Provenance

The following attestation bundles were made for midas_peakfit-0.5.0.tar.gz:

Publisher: python-packages.yml on marinerhemant/MIDAS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file midas_peakfit-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: midas_peakfit-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 124.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for midas_peakfit-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bac8fc2bc9382b08362fa5d92cc68bee29eea0118ca9d1190830040703cf7b09
MD5 c4d972f25a60e733aa8ade1bb04addd3
BLAKE2b-256 62d494d325fb035f15c5bac64ead492c85df0020dc4c54fc0e7475d3404c2197

See more details on using hashes here.

Provenance

The following attestation bundles were made for midas_peakfit-0.5.0-py3-none-any.whl:

Publisher: python-packages.yml on marinerhemant/MIDAS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.1

2 files

This release

0.5.0 This release

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page