Skip to content

Compare tab, plasma-signal strip, per-n mode amplitude, Ip-flattop cut-off - #95

Merged
J-Chiriboga merged 1 commit into
OpenFUSIONToolkit:developfrom
ebursch:feature/compare-tab-plasma-signals
Oct 9, 2026
Merged

J-Chiriboga merged 1 commit into
OpenFUSIONToolkit:developfrom
ebursch:feature/compare-tab-plasma-signals

Conversation

@ebursch

@ebursch ebursch commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

What this adds

Compare tab. The rotating and quasi-stationary results stacked on one shared time axis: spectrogram (n-map or log power), n(t), per-|n| mode amplitude, QS φ–t contour / amplitude / phase, and the selected plasma signals. You can annotate across panels (vertical lines, shaded spans, per-panel horizontal levels and points), saved per shot with JSON import/export. You can reorder panels by dragging or with ‹ › buttons, and the order persists. It plots the params last run in the Rotating and QS tabs, else their defaults.

Plasma-signal strip above every tab. Ip / Bt / κ toggle chips, plus any coil or probe channel in the shot file, stacked against time with the shared cursor. Pointnames not yet in the file are still fetched with the QS tab's existing custom-signal panel, after which they show up in the strip.

Shared time axis. Zooming the strip, any QS time trace, the rotating spectrogram or time tracks, or the Compare figure zooms all of them, across tabs. Double-click or the strip's "↺ full range" resets it.

Rotating mode amplitude, one trace per toroidal |n|. New mode_amplitude node and Rotating card (n-map colors). At each (t, f) cell the toroidal array is projected onto every n, as the n-map does, and the cell counts only toward its best-fit n. The |n| trace is the strongest such cell per time. On the unevenly spaced DIII-D array, a plain per-n projection would make a strong n=1 echo into n=2/3. Gaps mark times where an |n| owns no cell.

Stop analysis at the Ip flattop end (checkbox in the strip). core.plasma.ip_flattop finds where smoothed |Ip| ≥ 95 % of peak. With cut_flattop=1, the QS fit's tmax is clamped, so the fit never sees post-flattop data. The rotating tracks end their sampling window there, and the spectrogram / n-map / coherence drop later columns. The strip shades the excluded time.

Contract changes

  • New node mode_amplitude: line, series n=0…5, null = gap, meta.freq_kHz.
  • extra_signals meta gains available (every channel grouped plasma / coil / sensor), units, and flattop_ms.
  • Optional cut_flattop=1 query param on the QS nodes, mode_track / mode_over_time / mode_amplitude, and spectrogram / mode_number / coherence. Without it nothing changes.

Notes for review

  • Plot gains an optional onDoubleClick. When it's set, single clicks are held 320 ms, because a click that moves the cursor re-renders the plot and would otherwise swallow the double-click.
  • Plot now purges only after an in-flight Plotly.react settles. Purging mid-draw threw inside Plotly when a plot unmounted while redrawing.
  • The QS-tab fit zoom resets now fire only on real trim or fit changes, not on mount, so opening the tab doesn't wipe the shared zoom.

Testing

  • ruff format --check, ruff check, ty check src/magnetics, pytest (494 passed).
  • eslint, tsc -b, vitest (65 passed), vite build.
  • New tests:
    • Python: test_plasma.py (flattop edges, sign, spikes, dips); test_mode_amplitude_by_n.py (two-mode 2:1 ratio recovered, no n=1 echo into n=2–5); node tests for mode_amplitude, the extra_signals listing/units/flattop, and cut_flattop on every affected node.
    • Frontend: unit tests for timeRange, signalUnits, flattop, panel ordering, and annotations.
  • Driven with Playwright on DIII-D 194122 against the live backend:
    • Strip on every tab, with the channel picker.
    • Zoom linked across all tabs; double-click and button reset.
    • Compare plasma panels, drag/arrow reorder that persists across reload, and reset.
    • Flattop cut: 1448–4385 ms; every analysis trace ends at 4385 ms, raw Ip/Bt are uncut.
    • Per-n amplitude legend n=0…5.
    • Rapid tab switching produced no page errors.

🤖 Generated with Claude Code

Compare tab: the rotating spectrogram (n-map or log power), n(t), per-|n|
mode amplitude, the QS phi-t contour / amplitude / phase and the selected
plasma signals stacked on one shared time axis, with user annotations
(v-lines, spans, h-levels, points; persisted per shot, JSON import/export)
and a drag/arrow panel order. It plots the params last run in the Rotating
and QS tabs (store.rotParams / qsParams), else their defaults; the shared
trace builders move to lib/plotTraces.ts.

Plasma-signal strip above every tab: Ip / Bt / kappa chips plus any coil or
probe channel in the shot file, stacked on the time axis with the cursor.

Shared time axis: store.timeRange links the strip, the QS traces, the
rotating spectrogram and time tracks, and Compare; zoom any of them and the
rest follow; double-click or the strip's reset restores the full range.

Rotating mode amplitude: new mode_amplitude node and card, one trace per
toroidal |n| (core mode_shape.mode_amplitude_by_n). Each (t, f) cell counts
only toward its best-fit n, so a strong n=1 does not echo into n=2/3 on the
unevenly spaced DIII-D array.

Ip flattop cut-off: core plasma.ip_flattop (smoothed |Ip| >= 95 % of peak);
with cut_flattop=1 the QS fit window, the rotating tracks and the (t, f)
maps stop at the flattop end. Toggled from the strip.

Plot: optional onDoubleClick (single clicks held 320 ms so a cursor move
can't swallow a double-click), and unmount purges only after an in-flight
Plotly.react settles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ebursch
ebursch requested a review from J-Chiriboga October 8, 2026 21:34
@ebursch ebursch self-assigned this Oct 8, 2026
@J-Chiriboga
J-Chiriboga merged commit 45ec292 into OpenFUSIONToolkit:develop Oct 9, 2026
5 checks passed
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.

2 participants