refactor(pixel-scale): derive from image WCS instead of hardcoding it#858
Open
cailmdaley wants to merge 1 commit into
Open
refactor(pixel-scale): derive from image WCS instead of hardcoding it#858cailmdaley wants to merge 1 commit into
cailmdaley wants to merge 1 commit into
Conversation
…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
force-pushed
the
fix/imsims-pixel-scale-0.185-v2
branch
from
July 20, 2026 20:53
8a4f7c5 to
c041cb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
PIXEL_SCALEPIXEL_SCALEMESSIER_PIXEL_SCALESExtractor (
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
PIXEL_SCALEis absent or non-positive (the same convention as SExtractor'sPIXEL_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.MESSIER_PIXEL_SCALE. Nothing reads it;mask.pyderives the Messier radius from the WCSpixel_scale_matrix.PIXEL_SCALE/MESSIER_PIXEL_SCALEfrom the example configs.Verification
pixel_scale_from_wcsreturns 0.185000 for a synthetic 0.185 arcsec/px WCS.test_ngmix,test_ngmix_uberseg,test_ngmix_weight_validation). One pre-existingazgaussfailure 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