Skip to content

Replace notebooks with Analysis module and .jl example scripts#184

Merged
logan-nc merged 9 commits intodevelopfrom
notebooks_cleanup
Mar 11, 2026
Merged

Replace notebooks with Analysis module and .jl example scripts#184
logan-nc merged 9 commits intodevelopfrom
notebooks_cleanup

Conversation

@logan-nc
Copy link
Collaborator

@logan-nc logan-nc commented Mar 6, 2026

Summary

Closes #156, closes #161.

  • Remove all .ipynb files — three run_and_analyze.ipynb example notebooks and the entire notebooks/ directory (spline examples, vacuum tests, equilibrium notebooks)
  • Add src/Analysis/ module — reusable post-processing submodule with:
    • Analysis.ForceFreeStates.plot_mode_displacement — Im(ξ_ψ) vs ψ_N for selected m values
    • Analysis.ForceFreeStates.plot_eigenmode_summary — 3-panel DCON summary (eigenvectors, heatmap, eigenvalues)
    • Analysis.ForceFreeStates.plot_stability_criterion — crit vs ψ_N
    • Analysis.Equilibrium.plot_flux_surfaces — R-Z flux surface contours from a PlasmaEquilibrium object
  • Convert examples to .jl scripts — each example now has run_example.jl and analyze_example.jl in place of the notebook
  • Add PlotlyJS backend — interactive browser-based plots (zoom, pan, hover); plots returned as named variables (p_modes, p_eigen, p_stab) so all persist simultaneously in the REPL
  • Preserve CHEASE datanotebooks/CHEASE_INP1/ and notebooks/Chease_Binary_example/ moved to test/test_data/

REPL usage

julia --project=.
include("examples/DIIID-like_ideal_example/analyze_example.jl")
p_modes   # view mode displacement plot
p_eigen   # view eigenmode summary
p_stab    # view stability criterion

Test plan

  • julia examples/DIIID-like_ideal_example/run_example.jl completes without error
  • include("examples/DIIID-like_ideal_example/analyze_example.jl") opens interactive browser plots
  • julia --project=. -e 'using JPEC; JPEC.Analysis.ForceFreeStates.plot_mode_displacement("examples/DIIID-like_ideal_example/jpec.h5")' runs without error
  • All existing tests pass: julia --project=. test/runtests.jl

🤖 Generated with Claude Code

logan-nc and others added 2 commits March 6, 2026 17:32
… Equilibrium plot functions; convert example notebooks to .jl scripts; clean up notebooks directory

- Add src/Analysis/ module with:
  - ForceFreeStates.jl: plot_mode_displacement, plot_eigenmode_summary, plot_stability_criterion
  - Equilibrium.jl: plot_flux_surfaces
- Convert all three run_and_analyze.ipynb examples to run_example.jl + analyze_example.jl scripts
- Delete entire notebooks/ directory (deprecated spline, vacuum, and equil notebooks)
- Move CHEASE_INP1 and Chease_Binary_example data to test/test_data/ for preservation
- Wire Analysis module into src/JPEC.jl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…return named plot variables

- Add PlotlyJS dependency for interactive browser-based plots (zoom, pan, hover)
- Replace display() calls with named variables (p_modes, p_eigen, p_stab) so all
  plots persist in the REPL and users can view each on demand

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@logan-nc logan-nc added WIP Work in progress work in progress labels Mar 6, 2026
@logan-nc
Copy link
Collaborator Author

logan-nc commented Mar 9, 2026

Summary of notebook content migration

Deleted outright (no content worth preserving)

  • notebooks/spline_examples.ipynb + spline_examples2.ipynb — explicitly deprecated per Clean up of Notebooks area #161
  • notebooks/vac_fourier.ipynb + vac_wall.ipynb — superseded by Julia vacuum implementation
  • notebooks/vacuum_tests/ (entire directory) — references old Fortran paths that no longer exist
  • notebooks/equil_chease_binary_test.ipynb, equil_inverse_test.ipynb, equil_soloviev_example.ipynb, equil_lar_example.ipynb — all used deprecated APIs (JPEC.Spl.bicube_eval, old EquilibriumConfig constructor); no test assertions worth extracting
  • notebooks/equil_read_chease_comparison.ipynb — visual debugging notebook comparing EFIT vs CHEASE ASCII vs CHEASE binary; same deprecated APIs, no extractable assertions

Moved to test/test_data/

  • notebooks/CHEASE_INP1/ (EQDSK, INP1_ascii, INP1_binary, equil.toml)
  • notebooks/Chease_Binary_example/ (INP1)

These are equilibrium data files, not code. No tests currently use them, but they are preserved in case someone wants to write CHEASE regression tests later.

Extracted into src/Analysis/

  • notebooks/equil_gfile_example.ipynb — the flux surface contour plot logic became Analysis.Equilibrium.plot_flux_surfaces
  • examples/*/run_and_analyze.ipynb — the stability plots became Analysis.ForceFreeStates.plot_mode_displacement, plot_eigenmode_summary, and plot_stability_criterion

Nothing went to benchmarks — benchmarks/ was already clean .jl files and was not touched. No new tests were added either, since the notebooks did not contain any numerical assertions, only plots.

logan-nc and others added 3 commits March 9, 2026 18:22
Expand the CHEASE consistency testset in runtests_equil.jl to verify that
ASCII and binary CHEASE formats produce identical equilibria across all key
quantities: magnetic axis, global parameters (q0, qmin, qmax, qa, bt0, crnt),
1D profile spline values (q, F, P, dV/dψ), and flux surface geometry (rfac²
and angle offset on the full nodal grid).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…data

This file used the legacy [EQUIL_CONTROL]/[EQUIL_OUTPUT] format from Fortran GPEC.
Nothing references it; configuration now lives in [Equilibrium] sections of jpec.toml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t_data; remove duplicate/orphan CHEASE data dirs

- Rename test/test_data/regression_equilibrium_example/ → CHEASE_test_data/ to
  distinguish unit test fixtures from true full-run regression tests
  (regression_solovev_ideal_example{,_multi_n} are end-to-end runs with toml configs;
  CHEASE_test_data only holds input files for equilibrium reader unit tests)
- Delete test/test_data/CHEASE_INP1/ — exact duplicate of CHEASE_test_data/
- Delete test/test_data/Chease_Binary_example/ — orphaned file from deleted
  equil_inverse_test.ipynb with no active tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
logan-nc added a commit that referenced this pull request Mar 11, 2026
…otebook removal

- Rename all JPEC references to GPEC / GeneralizedPerturbedEquilibrium
- Remove Fortran compiler install and build steps (Fortran removed from codebase)
- Remove all Jupyter/notebook instructions (notebooks removed per PR #184)
- Replace "Run the Example Notebook" step with gpec script invocation
- Remove nbstripout pre-commit hook documentation
- Renumber sections throughout to fill gaps

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@logan-nc logan-nc added architecture and removed work in progress WIP Work in progress labels Mar 11, 2026
@logan-nc logan-nc self-assigned this Mar 11, 2026
@logan-nc logan-nc marked this pull request as ready for review March 11, 2026 15:33
@logan-nc logan-nc changed the title WIP: Replace notebooks with Analysis module and .jl example scripts Replace notebooks with Analysis module and .jl example scripts Mar 11, 2026
logan-nc and others added 2 commits March 11, 2026 12:02
…EC rename in example scripts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@logan-nc logan-nc merged commit c57a3ea into develop Mar 11, 2026
5 checks passed
@logan-nc logan-nc deleted the notebooks_cleanup branch March 11, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up of Notebooks area Move example notebooks to be example scripts

1 participant