Simplify plot weights

Summary

Reworks the Python weight-visualisation tooling: the old monolithic plot_weights.py (with its embedded grid_utils.py) is replaced by two focused tools and a shared utility module.

New tools

Tool Purpose
yac_plot_weights.py Interactive map showing interpolation weight arrows, core/halo grids, fixed-value target points, and hover tooltips
yac_plot_grid.py Interactive map showing one or more YAC debug grid files with auto-discovery of all contained grids

Both tools support uv run for zero-friction dependency management.

Key improvements over plot_weights.py

  • Debug-grid based — reads YAC's native debug grid format (.clo/.cla/.gid) so global indices always match the weight file exactly
  • Core/halo distinction — halo cells are drawn dimmed and dashed when a core mask (.cmk/.vcmk) is present in the grid file
  • Fixed-value target points — target cells assigned a constant by the fixed fallback interpolation method are shown as scatter markers with a legend
  • Hover tooltips — hovering over a weight arrow shows src id, tgt id, and the weight value
  • Shared _utils/plotting.py — projection setup, geodesic extent calculation, edge plotting, and label toggling are factored out and reused by both tools
  • Interactive label toggling — press s/t (weights tool) or A/B/… (grid tool) to toggle cell-ID labels per grid

yac_generate_weights.py updates

  • Supports named grids via --src-grid-name / --tgt-grid-name (loads from multi-grid files via uxarray.open_multigrid)
  • Interpolation stack entries are now full JSON values on the command line (a plain string for methods without parameters, a ["method", {...}] array for parameterised methods)
  • Writes src_grid_name / dst_grid_name attributes to the output weight file so yac_plot_weights.py can locate the correct grids automatically
  • Target grid mask loading switched to netCDF4 for consistency

Closes #155 (closed), #70 (closed)

Checklist

  • All code changes are covered by unit tests
  • Code coverage did not deteriorate
  • Code follows the Style Guide
  • Documentation updated (weight_files.dox, yac_generate_weights.dox, components.dox)
  • Manual running of configure/build jobs was successful
  • Version info updated (doc/src/version_info.dox, Unreleased section)
Edited by Nils-Arne Dreier

Merge request reports

Loading