Repository navigation
Analysis - FEATURE - Redraw every Analysis plot with Makie, loaded as a package extension - #658
Conversation
…n the result summaries
…oundary stability to the summaries
…rminant in both verdicts
…he available plots
…m an output struct
…ture/analysis-result-plots
…es instead of a MethodError
…gure theme and a plots CI group Makie becomes a weak dependency with the GPECMakieExt extension, which holds the figure theme, the label helpers and saving with whichever backend is loaded. Analysis._draw is the entry point ported plots use; it throws an ArgumentError naming `using CairoMakie` or `using GLMakie` when no backend is loaded. The plot tests move to a new `plots` group whose CI job stacks a CairoMakie environment onto LOAD_PATH, so Makie stays out of the package's own dependencies; changes under ext/ now trigger the test workflow.
…e whole Δ′ family
…d add the control-surface, (R, Z) and island views
…nd docs figures with Makie
… plane to the perturbed-equilibrium plots
…poloidal-plane panel
…t every Analysis plot
… list summaries only when a panel can be drawn
…ational surfaces on a bare equilibrium
…l surfaces on the equilibrium summary
…ercentile of |value| by default
…lar values and singular vectors
There was a problem hiding this comment.
@matt-pharr — nothing pushed. I reviewed the structure, the API surface and the tests from the source; I did not render the figures here (no Makie backend on this machine), so nothing below is a judgment of how they look beyond the four PNGs in the docs.
Structure
- Data extraction in
src/Analysis, drawing inext/GPECMakieExt, and a plainArgumentErrorwhen no backend is loaded: this is the right split, and it takes Plots and PlotlyJS out of every user's load time. benchmarks/still doesusing Plotsin at least five scripts (benchmark_against_fortran_run.jl,equil_spline_comparison.jl,benchmark_diiid_ideal_ntv_torque.jl,benchmark_q_vs_iota_edge.jl,plot_grid_knot_placement.jl, …), and Plots is no longer inProject.toml. They now run only where Plots happens to be in the global environment. Port them, or say so indocs/development/benchmarking.md.- Loading GPEC changes the user's own Makie figures.
__init__callsset_texfont_family!on the session-wide MathTeXEngine, so every LaTeX string in the session switches face once the extension loads. Set it insidethemed()and restore it afterwards, as the theme itself is scoped. using Makiewithout a backend sets_BACKEND[] = true, so the helpful error is skipped and the failure comes from inside Makie. TestMakie.current_backend()at draw time instead of a flag set at load.src/ForcingTerms/ForcingTerms.jlchanges behavior outside plotting:RMPFieldconstructors now validate eagerly, the ASCII reader rejects non-integer n, m rows, and the coil-set constructor takes new argument forms. That is fine, but it is not in the release note and "Numerical impact: none" hides that a malformed forcing file now fails at construction. Add a line to Migration.
Interface changes not in the release note
The Migration line names two renames. The diff also has:
| Function | Change |
|---|---|
plot_cond_fbar |
zoom removed |
plot_edge_stability_scan |
ylims and kwargs... removed |
plot_eigenvalues |
default matrix_type :total → :all |
plot_energy_eigenvectors |
matrix_type replaced by nmodes |
plot_mode_displacement |
default modes 1:5 → nothing |
plot_dominant_mode_spectrum |
mode::Int → modes=1:3 |
plot_surface_overlay |
levels → top |
plot_surface_3d |
camera, colorbar_title, kwargs... removed; label added |
plot_coil_geometry_3d/rz, plot_mode_spectrum, plot_bn_contour |
kwargs... pass-through removed |
plot_gse_by_theta, plot_gse_integrated |
replaced by plot_gse(gse), in memory only |
- Any analysis script that passed Plots keywords through
kwargs...(titles, limits, sizes) now gets aMethodError. List these in Migration, and put the!on the title's tag, since the interface changes. - The Grad-Shafranov residual can no longer be plotted from a saved run. #650 made "result or
gpec.h5path" the contract for every plot, and this PR removes the only reader ofgse.h5along with the:gse_filescapability. Is that intended? If the sidecar files are going away, say so; if not, keep a path method.
Publication figures
The body sets "roughly publication quality" as the goal. Three things fall short of what we need for papers and slides:
- The theme is sans-serif (Makie default, TeXGyreHeros for math) at regular weight. Journals set Times; our paper figures use bold serif.
- Figure sizes are in pixels (820×440, 900×560, …), not at a print width, so 15 pt labels come out at an arbitrary size once the figure is scaled to a 3.4 in column.
save_pathwrites one file. A paper needs the PDF and slides need a PNG of the same figure.
I am not asking to change the default look for REPL diagnosis. A second theme (themed(; paper=true) or GPEC_PAPER_THEME: serif bold, widths 3.4 / 5.0 / 7.0 in at 10 pt) and a save_path without extension writing both formats would cover it. Your call whether here or as a follow-up.
Tests
julia --project=. test/runtests.jlwith no group now includes the plot files, whichusing CairoMakiefrom the global environment. On a machine without it the full suite fails at load. Skip theplotsgroup with a printed reason when CairoMakie cannot be loaded, and add the requirement to the test commands inCLAUDE.md.- CI adds CairoMakie to a temporary environment on
JULIA_LOAD_PATHrather than declaring it under[extras]/[targets]. That works forruntests.jlbut not forPkg.test, which is how a missing dependency is normally caught; note it next to the workflow step. - Most draw checks are
isa Figure. The stronger ones (stairs padding, axis scales, line counts) are good; the summaries would benefit from one check each on which panels were drawn.
Docs
- Four PNGs (2.0 MB,
pe_summary.pngalone 0.96 MB) are committed and regenerated by hand. They will go stale silently. Either build them in the docs job, or record the generating commit indocs/src/figures/manifest.tomlso staleness is visible. - The rule in
plotting.mdthat agents do not add plots without a human asking is a good one.
No merge without approval from a human reviewer. This comment is not an approval.
| displacements rather than at the step, see [`plot_linearity_check`](@ref). | ||
| Plot how linear each coil set's field is in its rigid motions: for the six taps (shift and tilt about `x`, `y`, `z`) | ||
| the ratio of the central second difference to the largest first difference among the set's taps, as stored in | ||
| `ErrorFields/CoilSensitivities/*_linearity_residual`. `at = :step` shows it at the finite-difference steps; `at = :tolerance` rescales each tap by `tolerance / step` to the coil's own tolerance range. Tolerances come from the file's |
There was a problem hiding this comment.
232 characters; the margin is 180.
| `ErrorFields/CoilSensitivities/*_linearity_residual`. `at = :step` shows it at the finite-difference steps; `at = :tolerance` rescales each tap by `tolerance / step` to the coil's own tolerance range. Tolerances come from the file's | |
| `ErrorFields/CoilSensitivities/*_linearity_residual`. `at = :step` shows it at the finite-difference steps; | |
| `at = :tolerance` rescales each tap by `tolerance / step` to the coil's own tolerance range. Tolerances come from the file's |
|
@logan-nc for your claude, these are my opinions:
Edits as described above will follow. |
…tests without one and compare every extractor
…ger, with whole-number ticks and labels that fit
|
@logan-nc changes since your review:
|
|
@matt-pharr I'll take a look at this soon, but I think the best test for it will be post merge when I create the perturbed fields PR chain, which will require adding new plots to Analysis and I can give direct feedback on how easy it is to conform new plots to this standard. Also, I found this way funnier than it probably should have been |
|
@jhalpern30 lmao. And yeah it is ok if feedback on this is more big picture, we can adjust plots as things go, but the riccati overhaul PR is blocked on this one so I would like to get this one merged so that can make it into develop soon. |


Release note
using CairoMakieto save files,using GLMakiefor interactive windows); without one, a plot call throws and says so. Plots return a MakieFigureinstead of aPlots.Plot, and Plots and PlotlyJS are no longer dependencies.plot_fixed_boundary_stability_criterionis nowplot_critical_determinant, andplot_gse_by_thetaandplot_gse_integratedare oneplot_gse(gse)that takesEquilibrium.equilibrium_gse!'s result; thegse.h5reader is removed, so the residual is plotted from memory only. Plots no longer pass extra keywords to the plotting library:plot_coil_geometry_3d,plot_coil_geometry_rz,plot_mode_spectrum,plot_bn_contour,plot_edge_stability_scanandplot_surface_3dnow reject them. Keywords removed:zoomfromplot_cond_fbar,ylimsfromplot_edge_stability_scan,cameraandcolorbar_titlefromplot_surface_3d(which gainslabel). Keywords replaced:plot_energy_eigenvectorstakesnmodesinstead ofmatrix_type,plot_dominant_mode_spectrumtakesmodes=1:3instead ofmode, andplot_surface_overlaytakestopinstead oflevels. Defaults changed:plot_eigenvaluesdrawsmatrix_type=:all(was:total), andplot_mode_displacementdraws the six largest harmonics (modes=nothing, was1:5). Outside plotting,RMPFieldnow checks its source when it is built: a missing or malformed forcing file, a non-integer n or m in an ASCII mode table, an unknown normalization, or a coil set without geometry or currents throws anArgumentErrorat construction instead of when the perturbed equilibrium runs.Overhaul and visual polish of the existing plots. Guidance on when to add a standard plot and when not to (mostly to prevent AI agents from running wild adding superfluous junk). Both interactive/zoomable and panable plots and can be saved to pdf or png in a script. Replaced Plotly library with Makie which is generally the more polished and julia-y option.
The goal of this PR is to make sure all the main plots that were widely used from the OMFIT module are included in some easily accessible form, that diagnosing a run is relatively easy from the REPL, and that the plots that we see are roughly of publication quality. That means that we cannot have anything be difficult to read, look like a first-pass plot, or have overlapping text. This must be balanced by making sure the included plots are not too busy and do not look like vibe code output.
We also add guidance on when to add a plot. All plots to be added as standard plots must be viewed as mockups by a human before an AI adds them, to avoid our standard plots becoming polluted by random one-off plots from rogue claude sessions. AI agents should not propose new plots to the standard plots unless making an entirely new module, or unless they are requested to consider new plots. New plots should be added sparingly otherwise the available_plots() function will become crowded and lose its usefulness.
Regression report
develop @ b11dfb244againstfeature/analysis-plots-overhaul @ 9880101a7(fan-out on ITER's SDCC cluster, Julia 1.12.6): 28 cases, 389 quantities, all unchanged. Each branch ran under its own pinned manifest, since this PR replaces Plots with Makie and neither branch loads under the other's package set; the report compares the two sets of cached runs.Per-case report
Plot registry, before and after
34 registered plots before, 42 after, by module
Equilibrium
plot_equilibrium_summaryplot_qprofileplot_pressure_profileplot_f_profileplot_flux_surfacesplot_gse_by_thetaplot_gse(gse)(unregistered)plot_gse_integratedplot_gse(gse)(unregistered)ForceFreeStates
plot_ffs_summaryplot_critical_determinantplot_fixed_boundary_stability_criterionplot_eigenvaluesplot_mode_displacementplot_energy_eigenvectorsplot_edge_stability_scanplot_delta_primeplot_delta_prime_rawplot_delta_coilplot_cond_fbarplot_ballooning_alpha_boundaryPerturbedEquilibrium
plot_perturbed_equilibrium_summaryplot_resonant_area_weighted_fieldplot_resonant_area_weighted_field_amplitudeplot_island_widthsplot_chirikov_parameterplot_driven_delta_primeplot_mode_spectrogramplot_dominant_mode_surfaceplot_singular_mode_rzplot_coupling_matrixplot_perturbed_field_rzplot_effective_islandsplot_islandsCoilForcing
plot_bn_contourplot_coil_geometry_3dplot_coil_geometry_rzplot_mode_spectrumplot_sourcesErrorFields
plot_error_field_summaryplot_coil_sensitivitiesplot_overlap_phasorsplot_linearity_residualsplot_dominant_mode_spectrumplot_tolerance_pdfplot_threshold_scalingplot_locking_riskNotes for reviewers
developonce that merges.Pkg.testresolves the test environment (.github/workflows/julia-test-version.yaml). The cached depot's registry predated the regenerated pins (HDF5_jll2.2.4), so every test job failed to resolve.🤖 Generated with Claude Code