Skip to content

ShowPDF widget: interactive tool for PDF analysis#1

Draft
ehrhardtkm wants to merge 5 commits into
calibrationfrom
showpdf-widget
Draft

ShowPDF widget: interactive tool for PDF analysis#1
ehrhardtkm wants to merge 5 commits into
calibrationfrom
showpdf-widget

Conversation

@ehrhardtkm

Copy link
Copy Markdown
Owner

What problem this PR addresses

ShowPDF is an interactive widget for the PDF pipeline. PDF analysis has several parameters (masking, k-range, window, damping), where finding optimal values for each depends on seeing the resulting G(r) curve and taking round trips through notebook cells to retune each one is slow. ShowPDF wraps PairDistributionFunction from quantem.diffraction and lets the user explore those parameters with live feedback.

image

Layout:

  • Left panel: real-space navigation image (BF / ADF / HAADF virtual image) with an interactive mask, probe, or line-scan. Using these options, the user selects scan positions contribute to the PDF.
  • Right panel: live 1D curve plots of I(k) + B(k) (radial mean with fitted background), windowed F(k), and G(r), plus the parameter controls.

Changing either the selected scan region in the left panel or the parameter controls in the right panel trigger fast recomputation.

This PR is intended to build off of a separate PR, which will add elliptical/pixel calibration methods. The base is set to this calibration branch for now so that the diff only shows the widget files. Technically, the widget functions don't directly interact with the calibration files at all, so it can be tested and reviewed without issue.

New files in this PR:

  • widget/src/quantem/widget/showpdf.py — the Python widget class (state, traits, recompute orchestration).
  • widget/js/showpdf/index.tsx — the React frontend, built into a single ES module via the existing widget/scripts/build.mjs pipeline.
  • widget/src/quantem/widget/detector.py — small helpers for BF disk detection and BF/ADF/HAADF virtual image computation on the nav panel; the algorithm matches Show4DSTEM.auto_detect_center.
  • widget/src/quantem/widget/__init__.py and widget/scripts/build.mjs — two-line exports / build registration.

ShowPDF follows the same patterns already used by Show2D and Show4DSTEM in this package: shared imports from figure, colormaps, stats, format; no separate CSS file; no tool-parity registry. Avoids adding new infrastructure.

To use:

For local dev:

cd widget
pip install -e .
npm install
npm run build

In notebook:

# construct pdf object first
pdf = em.diffraction.PairDistributionFunction.from_data(ds)
# import widget
from quantem.widget import ShowPDF
widget = ShowPDF(rdf)
widget

Example notebook:

What should the reviewer(s) do

This is a draft until the calibration PR merges and I update the base. Reviewing now is welcome, though, since the widget code itself is independent of other ongoing work.

  • This PR introduces a public-facing change (e.g., figures, CLI input/output, API).
    • For functional and algorithmic changes, tests are written or updated.
    • Documentation (e.g., tutorials, examples, README) has been updated.
    • A tracking issue or plan to update documentation exists.
  • This PR affects internal functionality only (no user-facing change).ShowPDF, an interactive anywidget-based widget for the PDF pipeline. The motivation is that PDF analysis has several parameters (masking, k-range, window, damping) where the right choice depends on seeing the resulting G(r) curve — round-tripping through notebook cells to retune each one is slow. ShowPDF wraps PairDistributionFunction from quantem.diffraction and lets the user explore those parameters with live feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant