Detect tiles with SExtractor on data too; take NUMBER from the UNIONS catalogue - #933
cailmdaley wants to merge 15 commits into
Conversation
Since #897 the data path takes its tile sample from the UNIONS DR6 catalogue, which has only isophotal barycentres, and read_ext_sexcat copied them into XWIN_*: every tile-side position (stamp centres and OFFSET, the ngmix centroid prior, tile PSF interpolation, epoch membership, the catalogue RA/Dec) was the barycentre, while image simulations get SExtractor's windowed centroid. read_ext_sexcat now measures XWIN_IMAGE/YWIN_IMAGE at every catalogue object: a vectorised numpy port of SExtractor 2.25's compute_winpos (Gaussian window of sigma 2 FLUX_RADIUS / 2.35, 4-sigma aperture with 11x11 edge subsampling, step 2x the weighted mean offset, at most 16 steps, stop below 1e-4 px), on the tile less a SExtractor-like BACK_SIZE 512 / BACK_FILTERSIZE 9 background, with neighbours' segmentation footprints replaced by their mirror image as MASK_TYPE CORRECT does. XWIN_WORLD/YWIN_WORLD come from the tile WCS, 1-based. SExtractor's fallbacks to the barycentre (FLAGS_WIN 1, 2, 4, 8) are reproduced; 16 marks an unmeasurable object and 32 a centroid still moving after 16 steps. FLAGS_WIN joins final_cat.param, and epoch membership reads XWIN_WORLD as in the SExtractor path. On tile 186.307 it reproduces SExtractor's XWIN_IMAGE exactly when SExtractor does not mask neighbours (0 of 41,425 objects off by more than 0.01 px in windows free of zero-weight pixels), and for 97% of objects on the DR6 catalogue path; the barycentre it replaces is off by 0.16 px at the median and 1.4 px at the 99th percentile. astra.yaml's object_position_columns and background_model say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NsPvmF43rzKrb5eYPNR3Ki
Review of #933 and the 202.301 run on Nibi: - Pixels that are 0 or not finite hold no data in a tile. They were left out of the background but read as signal in the window. They now take their mirror image through the centre, as SExtractor's MASK_TYPE CORRECT treats pixels under the weight threshold, and a mirror that is itself invalid counts as 0. - Non-finite pixels never enter the background or the sums: samples outside the aperture are zeroed before the product, and a non-finite sum gives FLAGS_WIN 16 at the barycentre. - The second moments are normalised as SExtractor's are after its loop, so a negative source is FLAGS_WIN 4, not 6. - FLUX_RADIUS <= 0 or NaN (DR6 carries values down to -1.2e6) is an empty window, FLAGS_WIN 4; windows wider than MAX_HALF = 256 px are FLAGS_WIN 16; and the working box never exceeds the image. The -12402 radius on 202.301 had built an 84k-px box and been killed at 16 GB. On 186.307 the agreement with SExtractor is unchanged (2.8% of objects off by more than 0.01 px on the DR5 tile, 3.4% on the DR6 path). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NsPvmF43rzKrb5eYPNR3Ki
|
is the underlying problem that the DR6 catalog doesn't include a sextractor quantity that we need it to? i need a little more exposition to understand. what are the barycenter vs windowed centroid? why is each one used where it is? does shapepipe need to use this other quantity? reimplementing a part of sextractor seems like not the right solution. we could ask the new columns be included in the DR6 catalog eventually, but what's the first-principles fix here? |
|
You're right. The first-principles fix is to run ShapePipe's own tile SExtractor on data, exactly as sims do, and take DR6's IDs by a positional join. I'm rewriting this PR to do that, and dropping the port. Barycentre vs windowed centroid. The barycentre ( Where ShapePipe uses it. The position sets the final RA/Dec and mask queries, epoch membership, PSF interpolation and the multi-epoch stamp centres. It is also the origin of the ngmix Jacobian, where the centroid prior (σ = 1 px) is centred. At 0.16 px, only the prior is plausibly affected. My expectation is that using the barycentre would move shear very little; I haven't measured it. The real problem is that sims use SExtractor's XWIN, so data and sims would be running different centroid definitions, and sim calibration would not exactly describe the data, mostly in blends. DR6 lacks the column, but we don't need it from DR6. #929 showed that
What the rewrite does. Data runs Asking for the new XWIN columns in a future DR6 release would also work, but it wouldn't help us: running SExtractor ourselves is cheap and keeps data and sims on one code path. Scripts and outputs: Claude Opus 5.5 on behalf of Cail |
The port re-implemented SExtractor's windowed centroid in numpy for UNIONS-catalogue tiles. Running SExtractor itself on the DR6 image and joining its rows to the DR6 catalogue replaces it (next commits). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A value with ${VAR:-default} expands to default when VAR is unset or
empty, as in the shell; $VAR and ${VAR} stay strict. The same change as
feat/uberseg-seg-vignet's, so the two merge cleanly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MATCH_CATALOGUE (an ASCII SExtractor catalogue of the same image) pairs each SExtractor row with its mutual nearest neighbour within MATCH_RADIUS pixels; paired rows take its NUMBER, unpaired rows leave the catalogue, and a SEG_VIGNET column, when present, is relabelled to the new numbering. Fewer than MATCH_MIN_FRACTION of the rows pairing stops the run: that is what a catalogue measured on other pixels (a DR5 image against DR6) looks like. The join runs before the post-processing keys epochs on NUMBER. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Data and image simulations both run tile_detect as SExtractor (config_tile_Sx.ini), so XWIN, FLAGS_WIN, the VIGNET neighbour markers and every SExtractor column are measured one way. Under tile_detection: unions_catalogue, tile_get_catalogue fetches only the UNIONS .cat and tile_detect joins its detections to it (SP_MATCH_CATALOGUE), keeping the shared NUMBER and TILE_UNIQUE_ID. On DR6 186.307 all 41,201 detections pair (median separation 4e-5 px); 45 catalogue objects, faint deblended children, have no detection. Gone: read_ext_sexcat and its tests, config_tile_Uc.ini, the runner link, the segmentation-map fetch, merge_final_cat's SEXTRACTOR_ONLY_COLUMNS and --tile-detection, and the detection.catalogue_neighbour_marking decision. completeness.py changes, so this lands at a campaign boundary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The rewrite is in, and the description is updated. One correction to my comment above: Claude Opus 5.5 on behalf of Cail |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without DETECTION_IMAGE the runner called SExtractor in dual-image mode with the same image and weight twice, which changes the background, MAG_AUTO and FLUX_RADIUS of a fifth of a tile's objects against the single-image call and the UNIONS catalogue. Dual-image mode stays for a real detection image. Closes #936 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ation The run also stops when fewer than MATCH_MIN_FRACTION of the catalogue objects pair, which catches a detection configuration that finds fewer objects than the catalogue. Tests cover the radius bound and both sides of the guard. astra.yaml records the eight-tile numbers, single-image detection, and the MAG_AUTO differences beyond a pixel-stack overflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
${VAR-x}, ${VAR:=x} and ${ VAR } passed through as literal paths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Peak RSS 1.75 GiB and wall time 143 s at most; SExtractor is built without threads. One retry doubles memory and runtime. Image simulations export SP_MATCH_CATALOGUE empty. Stale comments on the catalogue fetch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
300000 overflowed on four of eight DR6 tiles (a cD galaxy, a bright star's halo, 13 times on Alioth's tile); 3000000 clears all eight. Peak RSS rises to 1.84 GiB and wall time to 160 s on the worst tile; tile_detect's 4000 MB stays at 2.1x. The exposure config never overflows on the 40 CCDs checked and is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guard catches other pixels (DR5 pairs ~95%), not deblending near large objects (DR6 tiles pair at least 99.2%) or a few children on a near-empty edge tile. New key MATCH_TOLERATED_UNPAIRED = 20; MATCH_MIN_FRACTION = 0.98. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #936. Refs #924.
Data and image sims now detect tiles the same way: ShapePipe runs SExtractor (
config_tile_Sx.ini) on the tile, and on data each detection takes itsNUMBERfrom the UNIONS DR6 catalogue (Stephen Gwyn's MegaPipe run) by a positional join. Stephen's catalogue defines which objects exist, their IDs, and the photometry for photo-z. ShapePipe's own run defines everything the shape measurement reads: windowed centroids,FLAGS_WIN, the VIGNET stamps with their neighbour marking, sizes and fluxes. Shape, photometry and photo-z catalogues still share oneTILE_UNIQUE_ID, as #897 intended.Why. Since #897, data took its sample from DR6 through a converter (
read_ext_sexcat), while sims ran SExtractor. That had three problems:XWIN_*. That is 0.16 px from the windowed centroid at the median and 1.6 px at p99.Running SExtractor removes all three and puts data and sims on one code path, so sim calibration describes the data.
How.
tile_get_cataloguefetches onlyCFIS.<tile>.r.cat.sextractor_runner,match_catalogueruns after SExtractor and before the multi-epoch post-processing. It pairs each detection with its mutual nearest DR6 object within 1 px (MATCH_RADIUS), and the detection takes that object'sNUMBER. Unpaired detections leave the catalogue, and aSEG_VIGNETcolumn, if present, is relabelled to match.MATCH_CATALOGUE, so their command is unchanged.MATCH_MIN_FRACTION = 0.98) and 20 objects (MATCH_TOLERATED_UNPAIRED). This catches a tile image from another release (DR5 pixels pair at about 95%) and a drifted detection configuration. It tolerates deblending differences near large objects and a few unpaired children on near-empty edge tiles.sextractor_runnernow calls SExtractor with one image and one weight. It used to call it in dual-image mode with the same image twice, which changed MAG_AUTO by more than 0.01 for 3.7% of objects and FLUX_RADIUS for 20%. On the 40 CCDs of exposure 2254826, the PSF-star selection is identical: the same 2,202 stars, and the same FWHM mode on every CCD.MEMORY_PIXSTACKis 3,000,000 indefault_tile.sex. At 300,000, SExtractor truncated the pixel stack at very large objects on four of the eight test tiles (13 times around Alioth), and dropped detections behind them.read_ext_sexcatand its tests,config_tile_Uc.ini, the segmentation-map fetch, the runner link intile.smk,merge_final_cat --tile-detectionwithSEXTRACTOR_ONLY_COLUMNS, and the decisiondetection.catalogue_neighbour_marking.astra.yamlrewritesdetection.tile_detectionandpreparation.object_position_columns, and pins the match keys andMEMORY_PIXSTACK.Validation on eight DR6 tiles, using the real
sextractor_runnerand the delivered exposure headers. The tiles are three typical high-latitude ones, one at b = 18°, the A2199 cluster, Alioth's halo, and two survey-edge tiles at 96% zero weight.rand()(refine.cgatherup()), and one stream runs through the image. After the first object whose draw count differs from MegaPipe's build, deblended objects get different pixels. Positions match; deblended photometry differs by a few percent per object. No configuration setting changes this. Data and sims run the same binary, so this doesn't affect calibration.Cost. The whole step takes 23–160 s and peaks at 1.84 GiB. SExtractor in the image is built without threads, so
tile_detectasks for 1 core, 4 GB and 20 min, with one retry that doubles memory and runtime. On Nibi it bills 1 core-equivalent instead of 8. That is about 1% oftile_ngmix's CPU per tile.Tests.
${config values.tile_detectwaits for the catalogue fetch and sims export an empty path.Each test was seen to fail under an injected bug.
tests/unit,tests/moduleandtests/workflow: 828 passed, 1 skipped.astra validatepasses. An Opus review and two GPT reviews found no blocking defects, and their fixes are folded in.Campaign boundary.
completeness.pychangesSCRIPT_HASH, which is in the params of 13 rules. Resuming any campaign on develop after the merge, sims included, therefore reruns every finished unit, and tile and exposure SExtractor measurements change with single-image mode. Merge between campaigns. The tile mirror a campaign reads must be DR6, or every data tile stops at the guard.Rebasing #925. In
sextractor_runner,add_seg_vignetmust run beforematch_catalogue, or the relabelling misses the stamps.Validation scripts and tables:
candide:/n17data/cdaley/scratch/xwin-assoc/tiles/(table_pix3e6.md,where.png).Claude Opus 5.5 on behalf of Cail
🤖 Generated with Claude Code