Skip to content

refactor: dedupe FootprintPlotter, import from cs_util#186

Open
cailmdaley wants to merge 1 commit intodevelopfrom
fix/footprint-plotter-dedup
Open

refactor: dedupe FootprintPlotter, import from cs_util#186
cailmdaley wants to merge 1 commit intodevelopfrom
fix/footprint-plotter-dedup

Conversation

@cailmdaley
Copy link
Copy Markdown
Collaborator

Summary

FootprintPlotter was duplicated between sp_validation.plots and cs_util.plots, with the local copy stale relative to the canonical cs_util version. Delete the sp_validation copy and re-export cs_util's class so the public surface (from sp_validation.plots import FootprintPlotter) is unchanged.

What diverged

The sp_validation copy was missing improvements that had landed in cs_util:

  • no vmin kwarg on plot_area / _regions
  • no draw_milky_way call
  • no set_autorescale(False) + set_extent(extend) enforcement
  • no axis labels set on the projection

Both versions share the same __init__ signature (nside_coverage=32, nside_map=2048) and the same public methods (create_hsp_map, plot_area, plot_region, plot_all_regions, plot_footprint_as_hp, hp_pixel_centers). cs_util's API is a superset; nothing removed.

Backward compatibility

FootprintPlotter is re-imported at module top level in sp_validation/plots.py, so every existing import path keeps working:

  • from sp_validation.plots import FootprintPlotter — still works
  • from sp_validation.cosmo_val import FootprintPlotter — still works (via cosmo_val's own re-import)
  • from sp_validation.plots import * — still picks it up

Caller audit

Grepped the repo for FootprintPlotter; every caller was inspected:

  • src/sp_validation/cosmo_val.py:1011FootprintPlotter() + create_hsp_map + plot_region(hsp_map, fp._regions[region], outpath=...). Compatible.
  • notebooks/demo_create_footprint_mask.py:95 — same usage via cosmo_val.FootprintPlotter(). Compatible.
  • notebooks/cosmo_val/catalog_paper_plot/plot_gaia_sky.py:100,138FootprintPlotter(nside_coverage=32, nside_map=2048) and plot_area(..., vmax=...). vmax is still a keyword arg in cs_util's signature. Compatible.

No caller passes vmax to __init__ (the stale class didn't accept it either); no caller assumes autorescale=True; no caller reads _regions[*] expecting the absence of vmin.

Visual deltas to expect

Callers will now see the cs_util improvements on footprint plots: the Milky Way overlay, axis labels, and enforced extents. Color scaling will start at vmin=0 rather than matplotlib auto, which matches the implicit previous behavior for count maps.

Other changes

  • pyproject.toml: bumped cs_util>=0.1.5 to cs_util>=0.1.9 to guarantee the import resolves.

Test plan

  • Re-run cosmo_val.CosmoVal.plot_footprints and confirm NGC/SGC/fullsky plots render.
  • Re-run notebooks/cosmo_val/catalog_paper_plot/plot_gaia_sky.py end-to-end.
  • Confirm from sp_validation.plots import FootprintPlotter and from sp_validation.cosmo_val import FootprintPlotter resolve to the cs_util class.

Generated with Claude Code (Opus 4.7, 1M context).

The FootprintPlotter class was duplicated between sp_validation and
cs_util, with the sp_validation copy stale (missing vmin, milky way,
extent enforcement). Delete the local copy and re-export cs_util's
version for API compatibility. Bump the cs_util dep to >=0.1.9 to
guarantee the import resolves.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cailmdaley
Copy link
Copy Markdown
Collaborator Author

Live smoke test passed inside the shapepipe container (Python 3.12, cs_util 0.1.9):

from sp_validation.plots import FootprintPlotter
import cs_util.plots
fp = FootprintPlotter()
# FootprintPlotter.__module__ -> cs_util.plots
# FootprintPlotter is cs_util.plots.FootprintPlotter -> True
# list(fp._regions.keys()) -> ['NGC', 'SGC', 'fullsky']
# all('vmin' in r for r in fp._regions.values()) -> True

Re-export is transparent; same class object is returned, _regions matches cs_util's (with vmin). Ready for review.

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