Repository navigation
fix(sextractor): tolerate WCS inversion divergence in post-process - #825
Merged
Merged
Conversation
make_post_process epoch-matching inverse-projects every tile object through every exposure CCD's WCS. With astropy 7 / wcslib 8.4 the iterative de-distortion (disx2p) raises InvalidCoordinateError for positions far outside a CCD's distortion domain - routine for tile objects several CCDs away - killing the whole tile (7/10 CFIS P3 tiles failed; the astropy 6 stack used previously did not raise). wcs_world2pix diverges identically, so there is no linear fallback. Fix: forward-project (pixel to world, always well defined) the CCD centre and corners to get its sky footprint, and inverse-project only objects within 1.5x the footprint radius; everything else can never pass the CCD bounds test. If the inversion still diverges for a near-footprint batch, log how many objects were skipped for that exposure/HDU and record no epoch for them instead of raising. Validation on CFIS P3: a previously-succeeding tile reproduces its N_EPOCH column bit-for-bit; a previously-crashing tile completes with a sane epoch distribution (all objects >= 1 epoch, max = its 9 contributing exposures) and zero divergence warnings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
7 tasks
martinkilbinger
approved these changes
Jul 14, 2026
martinkilbinger
left a comment
Contributor
There was a problem hiding this comment.
Nice fix! I remember I saw this behaviour in the past but didn't know how to solve it.
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.
Problem
During the Nibi test run in #808, the SExtractor post-processing step crashed on some tiles with astropy
NoConvergenceerrors from inverse-WCS evaluation, while the same configuration had previously run cleanly. The regression appeared with the astropy 6 → 7 pin bump: astropy 7's epoch-matching changed which exposure footprints are evaluated, feeding positions far outside a CCD's valid WCS region intoworld_to_pix, where the iterative inversion diverges.Root cause
Post-processing tests every object position against every exposure WCS with no footprint prefilter and no divergence tolerance; positions far off-CCD make the SIP inversion diverge and raise.
Fix
In
sextractor_script.py/sextractor_runner.py(+95/-12 vs develop): prefilter objects against each exposure footprint before inversion, and tolerate residual divergence (quiet=Truehandling) instead of crashing, so far-off-CCD positions are simply counted as not-in-epoch.Evidence / testing
N_EPOCHvalues with the fix applied.Found during the Nibi test run in #808.
— Claude (Fable) on behalf of Cail.
🤖 Generated with Claude Code