Cut postage stamps in-house and reuse their exact centroid in ngmix (drop sf_tools)#811
Open
cailmdaley wants to merge 3 commits into
Open
Cut postage stamps in-house and reuse their exact centroid in ngmix (drop sf_tools)#811cailmdaley wants to merge 3 commits into
cailmdaley wants to merge 3 commits into
Conversation
vignetmaker's postage-stamp extraction no longer calls sf_tools' FetchStamps. A shapepipe-owned get_stamps() zero-pads by the stamp radius and slices around the rounded integer pixel — bit-identical to FetchStamps for in-bounds objects (checked against it directly in the tests), but an out-of-bounds centre now raises instead of being silently wrapped modulo the image shape. The extractor also records, per object per epoch, the integer extraction pixel and the sub-pixel offset (catalog float minus rounded int). Both ride on the multi-epoch vignette — in its sqlite entry alongside VIGNET, no sidecar file. ngmix's "wcs" (coadd) centroid source now consumes that stored OFFSET instead of re-projecting the sky position through galsim and re-rounding: one projection, one rounding, so a milli-pixel WCS disagreement can no longer flip a rounding tie and put the centroid prior a whole pixel off (#767). CENTROID_SOURCE hsm|wcs stays selectable. sf_tools is removed from pyproject.toml, uv.lock, and the two module depends lists. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KusTeTS6EHFXkwevF4vqaX
- Drop sf_tools from docs/source/dependencies.md (the one tracked file the dep removal missed). - prepare_postage_stamps reads OFFSET with .get() rather than [] so the "hsm" path, which never uses it, is not coupled to the field. The "wcs" path still fails fast on a missing offset — the error now fires precisely where the data matters instead of as an incidental KeyError in the shared stamp-prep loop. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KusTeTS6EHFXkwevF4vqaX
… gone The bit-identity test importorskips sf_tools, which this branch uninstalls — so CI would silently skip it forever. The golden test hand-derives expected stamps arithmetically (value = 10*row + col), covering round-half-to-even ties and edge zero-padding, independent of the pad/slice implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T1af8cuFLwE9MsHkAiYHJG
This was referenced Jul 12, 2026
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.
Closes #767.
ShapePipe cuts a small "postage stamp" image around every object before measuring its shape with ngmix. Until now the cutting was done by
sf_tools(unmaintained for years), and ngmix independently re-computed the object's position — through a different WCS library — to place its centroid prior. Two computations of the same number can disagree: near a rounding tie, a milli-pixel WCS difference rounds to a different pixel and puts the prior a full pixel off the stamp it was cut from (#767).What changes
vignetmaker.get_stamps()replacessf_tools.FetchStamps: zero-pad by the stamp radius, slice aroundround(pos). Bit-identical to sf_tools for in-bounds objects (tested directly against it, plus a hand-computed golden test that keeps the behavior pinned once sf_tools is uninstalled). An out-of-bounds centre now raises instead of being silently wrapped modulo the image shape.INT_POS) and sub-pixel offset (OFFSET) alongside each vignette in the same sqlite entry — no sidecar file. ngmix'swcscentroid consumes the storedOFFSETinstead of re-projecting and re-rounding: one projection, one rounding, so the stamp and the centroid prior cannot disagree. This is Axel's condition on ngmix centroid: switched to WCS in #741 — confirm correct, and any reason to keep HSM? #767, met by construction.CENTROID_SOURCE hsm|wcsstays selectable, so the eventual real-data hsm-vs-wcs comparison runs against a single pipeline.sf_toolsdropped frompyproject.toml,uv.lock, and the moduledepends.Note: vignette files produced before this change carry no
OFFSET; running new ngmix on them withCENTROID_SOURCE wcsfails fast with a message saying to regenerate the vignettes. Intended — a propagated offset genuinely doesn't exist for old files.Out of scope: the real-data hsm-vs-wcs A/B (needs a real-data run), and removing the HSM path (the open question on #767).
— Claude on behalf of Cail
🤖 Generated with Claude Code