Skip to content

refactor(pixel-scale): derive from image WCS instead of hardcoding it#858

Open
cailmdaley wants to merge 1 commit into
developfrom
fix/imsims-pixel-scale-0.185-v2
Open

refactor(pixel-scale): derive from image WCS instead of hardcoding it#858
cailmdaley wants to merge 1 commit into
developfrom
fix/imsims-pixel-scale-0.185-v2

Conversation

@cailmdaley

@cailmdaley cailmdaley commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What

Unify where the pixel scale is defined. The image WCS is the single source of truth. No pixel-scale value is hardcoded in the example configs.

Why

The pixel scale was set in four places that could drift from the image astrometry:

  • ngmix config PIXEL_SCALE
  • spread_model config PIXEL_SCALE
  • mask config MESSIER_PIXEL_SCALE
  • the images' own WCS

SExtractor (PIXEL_SCALE 0) and the mask code already read it from the WCS. Only ngmix and spread_model carried a hardcoded constant. The previous version of this PR corrected that constant to 0.185. This removes the constant instead, so it cannot go stale again.

Changes

  • ngmix — derives the pixel scale from the image WCS when PIXEL_SCALE is absent or non-positive (the same convention as SExtractor's PIXEL_SCALE 0). It stays an optional override. Only the centroid-prior width and noise window use it. The fit Jacobian is already built per object from the full WCS.
  • spread_model — drops the parameter. The spread-model statistic is computed in pixel space, so the pixel scale cancels exactly. The models now render in pixel units.
  • mask — deletes MESSIER_PIXEL_SCALE. Nothing reads it; mask.py derives the Messier radius from the WCS pixel_scale_matrix.
  • configs — removes every hardcoded PIXEL_SCALE / MESSIER_PIXEL_SCALE from the example configs.

Verification

  • spread_model: the rendered vignets are byte-for-byte identical to the old pixel-scale rendering across a (sigma, pixel_scale) grid. The parameter was inert.
  • ngmix: pixel_scale_from_wcs returns 0.185000 for a synthetic 0.185 arcsec/px WCS.
  • ngmix module tests pass (test_ngmix, test_ngmix_uberseg, test_ngmix_weight_validation). One pre-existing azgauss failure comes from a stale local container on ngmix 2.4.0; it is unrelated and green in CI (which builds with the pinned 2.4.1).

Closes UNIONS-WL/MultiBand_ImSim#2.

— Claude, on behalf of Cail

…nobs

The pixel scale lived in four places that could silently drift from the
actual image astrometry: the ngmix and spread_model config values, a dead
MESSIER_PIXEL_SCALE mask knob, and the images' own WCS. SExtractor and the
mask code already read it from the WCS; only ngmix and spread_model carried
a hardcoded constant. Unify on the image WCS as the single source of truth.

- ngmix: derive the pixel scale from the image WCS when PIXEL_SCALE is
  absent or non-positive (mirrors SExtractor's `PIXEL_SCALE 0`). It stays an
  optional override. Only the centroid-prior width and noise window use it;
  the fit Jacobian is already built per object from the full WCS.
- spread_model: drop the parameter entirely. The statistic is computed in
  pixel space, so the scale cancels exactly (verified byte-for-byte); the
  models now render in pixel units.
- mask: delete MESSIER_PIXEL_SCALE from the configs -- nothing reads it
  (mask.py derives the Messier radius from the WCS pixel_scale_matrix).
- configs: remove every hardcoded PIXEL_SCALE / MESSIER_PIXEL_SCALE from the
  example configs. Nothing left to drift.

Supersedes the 0.185 hardcode (#858).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQxJdyKjKSbHRudXLHfXZb
@cailmdaley
cailmdaley force-pushed the fix/imsims-pixel-scale-0.185-v2 branch from 8a4f7c5 to c041cb3 Compare July 20, 2026 20:53
@cailmdaley cailmdaley changed the title fix(imsims): pin example sim configs to the rendered pixel scale 0.185 refactor(pixel-scale): derive from image WCS instead of hardcoding it Jul 20, 2026
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.

Grid sims: confirm the rendered pixel scale (generator config: 0.185; downstream consumers assume 0.186 / 0.187)

1 participant