Skip to content

Mode suite#7

Merged
nathanchenseanwalter merged 9 commits into
mainfrom
mode-suite
Jul 7, 2026
Merged

Mode suite#7
nathanchenseanwalter merged 9 commits into
mainfrom
mode-suite

Conversation

@nathanchenseanwalter

Copy link
Copy Markdown
Contributor

No description provided.

Nathaniel Chen added 9 commits July 6, 2026 19:28
One module per subcommand (app/run/download/example) exposing
add_subcommand(subparsers); shared HF-error printing in cli/_errors.py.
Import path tokeye.cli:main and all CLI behavior unchanged — existing
test_cli.py passes without edits. Prepares for the mode-analysis suite
subcommands (modespec, elmspec, alfvenspec, eigspec, modesearch).
ModelSpec gains repo_id (None -> DEFAULT_REPO_ID) and repo_for() resolves
the repo for CLI error messages. ae_tf_maskrcnn registered at
nc1/ae_tf_maskrcnn with AETFMaskConfig(weights=None) so the registry
builder never downloads COCO weights; AETFMaskModel now honors
config.weights instead of hardcoding the torchvision default.
Registry insertion order documented + guarded: big_tf_unet stays first
for _build_from_state_dict probing.
Mask R-CNN takes a list of 3-channel images, not a (B,1,H,W) batch;
verify_checkpoint now selects the probe per registry model and --repo
defaults to the model's registry repo. Actual nc1/ae_tf_maskrcnn upload
pending a write-scoped HF token.
tokeye elmspec runs big_tf_unet and turns mask[1] into discrete ELM
events: column-wise active-bin fraction, gap-closing merge, per-event
intervals plus per-input count/frequency/duty-cycle. Outputs
elm_events.csv + elm_summary.csv (absolute times when --fs given) and
optional overlay PNGs. Event extraction is pure numpy (tokeye.elmspec),
unit-tested without a model.
tokeye alfvenspec runs the instance-detection model over spectrograms
and writes ae_detections.csv (boxes/labels/scores) plus optional
instance masks. R-CNN inference lives in tokeye.alfvenspec.inference,
keeping the segmentation contract in tokeye.inference untouched.

Wide spectrograms are processed in training-width column windows
(default 710) with box x-coordinates mapped back to global columns:
the R-CNN transform caps inputs at 1333 columns, so an unwindowed
full shot is crushed horizontally and detects nothing (verified on
shot 178632: 0 detections unwindowed vs 135 windowed). Final slivers
fold into the previous window rather than being dropped.

Kept deliberately thin pending energetic-particle group requirements.
Vendored from PlasmaControl/pymodespec @ 1e0e48f (MIT): Mirnov
spectrograms, matched-filter toroidal mode-number fits, per-shot mode
CSVs. New subcommand: tokeye modespec <config.yaml>.

Local changes (full list in PROVENANCE.md): relative intra-package
import, main() split into run_config() for the CLI, actionable MDSplus
error messages (GA cluster / conda-forge / atlas.gat.com). Style rules
relaxed for the vendored tree in ruff.toml; correctness rules stay on.
Lazy PEP 562 re-exports keep the package import cheap; the CLI sets the
Agg backend before the vendored pyplot import.

modespec/deep/ reserves the next-generation single-chord engine
(integratedmode project) as tokeye modespec --engine deep.

pyyaml promoted to a declared dependency (was transitive-only).
Reserves tokeye.modesearch and documents the design: offline crawler
indexes suite detections into per-mode records; query layer answers
'find shots with mode X'; feeds the fusion-world-model shot designer;
complements shotsearch's setup-similarity search. tokeye modesearch
prints the plan and exits 0.
docs/ROADMAP.md: suite status, mode catalogue schema (the keystone
record type all detectors will emit), modesearch build-out plan, and
future ideas for mode researchers (mask mode-number labeling, trajectory
tracking, cross-diagnostic confirmation, ELM database, AE taxonomy,
inter-shot mode, OMFIT/toksearch hooks).

README gains a Mode-analysis suite section and the per-model HF repo
table; CLAUDE.md documents the new packages, CLI layout, registry-order
constraint, and vendored-code policy.
Vendored from PlasmaControl/eigspec @ 923ad5d (MIT): modal
identification, stochastic subspace ID, AR/PCA, random-projection
spectral analysis. New subcommand: tokeye eigspec [SCRIPT] (interactive
prompt or script file). sklearn-dependent clustering behind the new
tokeye[eigspec] extra; base import needs no new dependencies.

Local fixes (full list in PROVENANCE.md, worth upstreaming):
- import-breaking: 7x 'lambda' attribute access (SyntaxError) via
  getattr; missing typing imports in subspace_identification.py
  (NameError at import on py3.13).
- covariance_driven_ssi numeric bugs: block-Hankel rows were flattened
  channel-major while all downstream slicing assumes time-block-major
  (scrambled past/future blocks, wrong pole frequencies), and the
  'A = O1 \ O2' step carried a spurious transpose (lstsq already
  matches MATLAB backslash). A damped-sinusoid test now recovers pole
  frequency and damping ratio to <1%.
@nathanchenseanwalter nathanchenseanwalter merged commit 68c9843 into main Jul 7, 2026
3 checks passed
@nathanchenseanwalter nathanchenseanwalter deleted the mode-suite branch July 7, 2026 00:25
nathanchenseanwalter added a commit that referenced this pull request Jul 8, 2026
nathanchenseanwalter added a commit that referenced this pull request Jul 8, 2026
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