Mode suite#7
Merged
Merged
Conversation
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%.
5204f37 to
be45166
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.