From 52c79a5f7a0b6626e58aebac3978ee99f9e2e3df Mon Sep 17 00:00:00 2001 From: Cail Daley Date: Sat, 21 Nov 2026 19:26:41 -0700 Subject: [PATCH 1/6] astra: first-order inputs, wired stages, a release stage and the run-1 baseline The record now reads as the pipeline's analysis: - root inputs are the survey data run 1 read (DR6 tile stacks, tile catalogues, exposures with weights and flags, the tile list, the dr6-2026-09-29 mask ladder, the runtime image), with where each lives, its size and what consumes it; - sub-analyses are in data order and wired by `from:`, so the graph runs from the inputs through masking, detection, star selection and PSF, preparation, shape measurement and assembly to a new `release` stage that points at run1-snap3 and v2.0.0 (its decisions are sp_validation's); - universes/baseline_run1.yaml pins run 1 as it ran: the ten production commits agree on every decision, and run 1 differs from develop only in shape_measurement.defect_flagging (#973); - three PSF decisions under data pressure are recorded on their own: psf_sampling (split out of psf_model_complexity, #989), psf_chromaticity and psf_rendering. No behaviour change: tags are comments. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JK7o9DgyMMqdmBBf6gXL7h --- CLAUDE.md | 7 +- astra.yaml | 570 ++++++++++++------ .../psfex_interp_package/psfex_interp.py | 2 + universes/baseline_run1.yaml | 86 +++ universes/committed.yaml | 3 + workflow/config/cfis/default.psfex | 4 +- 6 files changed, 496 insertions(+), 176 deletions(-) create mode 100644 universes/baseline_run1.yaml diff --git a/CLAUDE.md b/CLAUDE.md index 47795c0d6..1fd518512 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -143,7 +143,12 @@ where the change lives — and *scientific* decisions in `astra.yaml`, below. consequential scientific choice embedded in the code and committed configs, with its rationale, alternatives and selected default. `universes/committed.yaml` pins the option the committed configuration selects for every decision. -`@sc [decision:]` tags live at implementing code/config sites; optional +Each catalogue version or trial is a universe beside it, pinning the options +that version ran: `universes/baseline_run1.yaml` is run 1, the pipeline behind +the v2.0.0 catalogue. The record's root `inputs:` are the survey data the +pipeline reads (DR6 tiles, exposures, tile catalogues, masks, the image), and +its sub-analyses run in data order, wired by `from:`, from masking to the +release. `@sc [decision:]` tags live at implementing code/config sites; optional `Values:` sentences assert committed values within those tagged sites. The rationale stays in ASTRA, while local `@sc` contracts hold site-specific constraints. `tests/unit/test_decisions.py` checks tag syntax, bidirectional diff --git a/astra.yaml b/astra.yaml index e336ef639..ba4316bcc 100644 --- a/astra.yaml +++ b/astra.yaml @@ -53,28 +53,108 @@ tags: [shapepipe, weak-lensing, unions, codebase-record] container: ghcr.io/cosmostat/shapepipe:develop inputs: - - id: tile_images + - id: dr6_tile_stacks + label: DR6 r-band tile stacks type: data - source: CFIS/UNIONS r-band MegaPipe tile stacks and single-exposure image/weight/flag triplets (workflow/config.yaml) + source: vos:cfis/tiles_DR6/CFIS..r.fits and CFIS..r.weight.fits.fz description: >- - Tiles and the exposures that built them; each exposure carries its - instrument flag image. + The MegaPipe DR6 r-band coadd of each 0.5° CFIS tile and its weight + map: 400 MB image (10k × 10k float32) and a median 126 MB weight per + tile, about 12 TB for run 1's 22,901 tiles. Galaxies are detected and + measured on these, and their primary-header HISTORY cards list the + exposures each stack was built from, which is where the exposure list + comes from. Read by tile_get_images (config_tile_Git.ini), then + tile_uncompress, tile_find_exposures and tile_detect. Version: "DR6", + nothing finer. Fir fetched each file with vcp and recorded its SHA-256 + after the fetch (INPUTS.json of each batch); Nibi symlinked a local + mirror (/project/def-mjhudson/unions-wl/tiles), whose agreement with + CADC is not recorded. No file is checked against an upstream checksum. + - id: unions_tile_catalogues + label: UNIONS DR6 tile catalogues + type: data + source: vos:cfis/tiles_DR6/CFIS..r.cat + description: >- + MegaPipe's SExtractor catalogue of each DR6 tile (median 7.3 MB; about + 0.17 TB for run 1). tile_detect joins ShapePipe's own detections to it + by mutual nearest neighbour within 1 px and takes its NUMBER, so + TILE_UNIQUE_ID and the PhotoPipe join (TILE_ID, NUMBER) = (tile, SeqNr) + come from it, and detections with no partner are dropped + (detection.tile_detection). Read by tile_get_catalogue + (config_tile_Gic.ini) into MATCH_CATALOGUE (config_tile_Sx.ini). + - id: dr6_exposures + label: DR6 exposures, weights and flag images + type: data + source: vos:cfis/pitcairn/p.fits.fz, vos:cfis/weights/p.weight.fits.fz, vos:cfis/flags/p.flag.fits.fz + description: >- + The Elixir-processed 40-CCD MegaCam exposures behind each tile, with + their weight maps and instrument flag images: medians 339 MB, 15 MB and + 16 MB per exposure, 16,872 exposures and about 6.3 TB in run 1. The + PSF is modelled on them and ngmix fits their postage stamps; the flag + image is the only mask that reaches pixels (masking.pixel_mask_source). + Read by exp_get_images (config_exp_Gie.ini), exp_split + (config_exp_Sp.ini), exp_psf, exp_maps and tile_vignets. Fir fetched + them from CADC; Nibi symlinked /project/def-mjhudson/unions-wl/exposures. + - id: tile_list + label: Run-1 tile list + type: data + source: run1-snap3 MANIFEST.json tiles (22,901 ids); a subset of auxdir/CFIS/tiles_202604/tiles_r.txt (23,114) + description: >- + The 22,901 DR6 tiles run 1 processed, cut into HEALPix nside-4 cells + and batches of about 25 tiles: 16,123 ran on Nibi and 6,778 on Fir + (fir-tiles.txt in the Fir production kit). The exposure list is not an + input: tile_find_exposures reads it from the tile headers. Which rule + dropped the other 213 tiles of tiles_r.txt is not recorded. - id: healsparse_masks + label: DR6 sky-fixed mask ladder (dr6-2026-09-29) type: data - source: UNIONS healsparse mask products (e.g. mask_ugriz_nside131072_n4.hsp) + source: vos:cfis/weak_lensing/ShapePipe/masks/ (ladder dr6-2026-09-29; Fir copy /project/def-waerbeke/cdaley/fir-assets/masks/dr6-2026-09-29/) description: >- - Sky-fixed mask maps, built outside ShapePipe and queried at object - positions; how they are used is the masking sub-analysis. + Eleven boolean healsparse maps (nside 131072, True = masked), one per + bit of the UNIONS mask: 1 and 2 star halos, 4 star bodies, 8 manual, + 1024 MaxiMask, and 16, 32, 64, 128, 256, 2048 for no u, g, r, i, + Subaru z or Pan-STARRS z data. Made by the mask group (Mike Hudson) and + declared final on 29 Sep 2026. make_cat queries them at each object's + XWIN_WORLD/YWIN_WORLD into MASK__ columns + (config_tile_Mc.ini MASK_EXT_PATHS); nothing in ShapePipe cuts on them + (masking.sky_mask_application). Every Fir batch records the same + SHA-256s (ASSETS.json); a re-query of these maps on 14 tiles from every + commit and both sites matches the catalogue's mask columns exactly. + - id: container_image + label: ShapePipe runtime image + type: data + source: shapepipe-develop-240b37e4.sif, sha256 94a791efd3de4eb585e95b5bb5c014f7ae3f5d3771bb46b41dffa4728ab43032 + description: >- + The Apptainer image that supplies SExtractor, PSFEx and the Python + stack (816 MB, built from develop 240b37e4 on 28 Sep 2026). Run 1 ran + each campaign's own ShapePipe source on top of it through PYTHONPATH, + so the binaries and libraries are this image's and the code is the + campaign's commit (universes/baseline_run1.yaml). Fir verified the + SHA-256 before every batch; Nibi is inferred to have used the same + file, from which Fir's copy was made. outputs: + - id: psf_models + from: star_selection_psf.psf_model + - id: tile_detections + from: detection.tile_sexcat + - id: shapes + from: shape_measurement.ngmix_cat - id: final_cat type: data format: hdf5 description: >- - Per-tile shear catalogue family, the terminal science product - (make_cat_runner). - inputs: [tile_images, healsparse_masks] + The shear catalogue: every tile's final_cat merged across campaigns. + Run 1's is run1-snap3/final_cat_latest.hdf5 (449 GB, 772,677,301 + objects on 22,901 tiles; vos:cfis/weak_lensing/ShapePipe/v2.x/run1-snap3/, + Fir data/v2.x/run1-snap3/). The decisions here act across the chain. + inputs: [dr6_tile_stacks, dr6_exposures, unions_tile_catalogues, healsparse_masks, tile_list, container_image] decisions: [per_unit_completeness, postage_stamp_size, photometric_zeropoint] + - id: star_catalogue + from: catalogue_assembly.star_catalogue + - id: coverage_maps + from: masking.exposure_maps + - id: calibrated_catalogue + from: release.calibrated_catalogue decisions: @@ -215,11 +295,9 @@ analyses: stage cuts on. inputs: - id: exposure_flags - type: data - source: per-CCD instrument flag images split from each exposure (exp_split family) + from: ../dr6_exposures - id: sky_masks - type: data - source: UNIONS healsparse mask maps + from: ../healsparse_masks outputs: - id: masked_measurement_inputs type: data @@ -429,14 +507,15 @@ analyses: values. inputs: - id: tile_stack - type: data - source: MegaPipe r-band tile stack + weight (uncompressed, merged headers) + from: ../dr6_tile_stacks + - id: tile_catalogue + from: ../unions_tile_catalogues outputs: - id: tile_sexcat type: data format: fits description: Per-tile SExtractor LDAC catalogue with per-epoch CCD membership. - inputs: [tile_stack] + inputs: [tile_stack, tile_catalogue] decisions: [tile_detection, detection_threshold_policy, deblending_policy, background_model, @@ -841,150 +920,6 @@ analyses: exact: 'We do the extraction on stacked images which provide a better signal-to-noise ratio, and most artifacts have a reduced amplitude with respect to single exposures' location: { page: 5 } - # ═════════════════════════════════════════════════════════════════════════ - preparation: - description: >- - How exposures, astrometry, epoch lists and stamps are prepared before - anything is measured. - inputs: - - id: exposure_files - type: data - source: delivered CFIS exposure triplets (image/weight/flag MEF) + tile stacks - outputs: - - id: epoch_stamps - type: data - format: sqlite - description: Per-object multi-epoch vignets + per-CCD WCS log feeding ngmix. - inputs: [exposure_files] - decisions: - [astrometric_solution_source, ccd_split_extent, - epoch_provenance_from_tile_history, object_position_columns, - stamp_positioning_and_padding] - decisions: - astrometric_solution_source: - label: Astrometry taken verbatim from delivered per-CCD headers - rationale: >- - split_exp builds WCS(header) from each delivered CCD header, and - merge_headers stores these per-tile. Every committed world-to-pixel - step on exposures uses that solution: epoch membership, - multi-epoch stamp placement and OFFSET, tile-side PSF interpolation - positions, and the per-epoch ngmix Jacobian. [HARDCODED] No - astrometric re-derivation or refinement exists. A re-fit would shift - stamp centres and Jacobians and could change epoch membership. - default: delivered_headers - options: - delivered_headers: - label: WCS(header) verbatim, stored at split time - insights: [guinot22_gaia_astrometry] - astrometric_refit: - label: Joint astrometric re-solution - description: Not implemented. - ccd_split_extent: - label: All 40 MegaCam HDUs split and carried as candidate epochs - rationale: >- - Any HDU count other than N_HDU raises; every CCD is a candidate - epoch wherever the WCS lands it. - Values: - SPLIT_EXP_RUNNER.N_HDU = 40. - default: all_40_hdus - options: - all_40_hdus: - label: 40 HDUs, hard-fail on any other count - insights: [guinot22_forty_chips] - exclude_ccd_subset: - label: Exclude a subset of CCDs as epochs - description: Not implemented. - epoch_provenance_from_tile_history: - label: Epoch sets parsed from tile FITS HISTORY cards - rationale: >- - The tile's primary-header HISTORY cards are its exposure list, and - two readers parse the same cards. find_exposures takes the file name - in column COLNUM, strips the extension and deduplicates. EXP_PREFIX - is blank, so 2243881p keeps its p. This list decides which exposures - are retrieved, split and merged into the tile's WCS log. - make_post_process re-parses the HISTORY copied into the catalogue - (the digits before an optional p) and builds the EPOCH HDUs and - N_EPOCH that the stamps and ngmix use. It raises if a HISTORY - exposure is missing from the WCS log. A tile whose header or HISTORY - cannot be read fails; it never gets an empty exposure list. - Values: - FIND_EXPOSURES_RUNNER.COLNUM = 3. - default: history_parse - options: - history_parse: - label: HISTORY column 3, no prefix stripped, deduplicated - object_position_columns: - label: Windowed centroids (XWIN/YWIN) define every position - rationale: >- - PSF interpolation sites, tile and multi-epoch stamp centres, epoch - membership and the catalogue position all use the tile SExtractor - run's windowed centroid, in data and image simulations alike: in pixels - for tile stamps and exposure-side PSF validation, in world - coordinates for tile-side PSF interpolation and multi-epoch stamps. - Windowed, isophotal and model centroids differ systematically for - blends and asymmetric galaxies, and the centroid feeds the position - seed and the centroid prior. - Values: - config_tile_PiViVi_psfex.ini#PSFEX_INTERP_RUNNER.POSITION_PARAMS = - XWIN_WORLD,YWIN_WORLD; - VIGNETMAKER_RUNNER.POSITION_PARAMS = XWIN_WORLD,YWIN_WORLD; - VIGNETMAKER_RUNNER.COORD = SPHE; - config_exp_psfex.ini#PSFEX_INTERP_RUNNER.POSITION_PARAMS = - XWIN_IMAGE,YWIN_IMAGE. - default: xwin_windowed - options: - xwin_windowed: - label: Windowed centroids everywhere - isophotal_barycentre: - label: Isophotal barycentre (X_IMAGE/Y_IMAGE) - excluded: true - excluded_reason: >- - Noisier than the windowed centroid and pulled by asymmetric or - deblend-clipped footprints; on the DR6 image of tile 186.307 - it sits 0.16 px (median) and 1.6 px (p99) from it for - 20 < MAG_AUTO < 24.5, and the image simulations measure the - windowed one. - stamp_positioning_and_padding: - label: Nearest-pixel stamp extraction with zero padding - rationale: >- - [HARDCODED] stamps are cut around the pixel nearest the object's - position, with no sub-pixel interpolation; the sub-pixel remainder - is stored as the stamp's OFFSET, which ngmix uses as the Jacobian - origin (shape_measurement.centroid_source), so extraction and - centroid prior share one rounding. Multi-epoch stamps map the tile - world coordinate through the stored per-CCD WCS. Stamps overrunning - an image edge are kept, zero-filled outside the image; a stamp - centre that rounds outside the image raises and fails the vignet - run for the whole tile. - default: round_and_zero_pad - options: - round_and_zero_pad: - label: Nearest-pixel extraction, zero padding, no edge rejection - prior_insights: - guinot22_gaia_astrometry: - claim: >- - The astrometric solution the analysis relies on is the upstream - MegaPipe/Gaia DR2 calibration, accurate to within 20 mas; no - astrometric re-fit inside the pipeline is described. - created_at: "2022-04-01T00:00:00Z" - evidence: - - id: ev_guinot22_astrometry - doi: "10.48550/arXiv.2204.04798" - quote: - exact: 'An astrometric calibration within 20 mas was achieved using the Gaia DR2 observations' - location: { page: 2 } - guinot22_forty_chips: - claim: >- - Star selection and PSF modelling are carried out independently on - each of the 40 MegaCam chips, with no chip excluded. - created_at: "2022-04-01T00:00:00Z" - evidence: - - id: ev_guinot22_forty_chips - doi: "10.48550/arXiv.2204.04798" - quote: - exact: 'is performed independently on each of the 40 chips that constitute the MegaCAM' - location: { page: 3 } - # ═════════════════════════════════════════════════════════════════════════ star_selection_psf: description: >- @@ -992,8 +927,7 @@ analyses: models are good enough to use. inputs: - id: exposure_sexcat - type: data - source: per-CCD exposure SExtractor catalogues (default_exp.sex run) + from: ../masking.masked_measurement_inputs outputs: - id: psf_model type: data @@ -1005,7 +939,8 @@ analyses: decisions: [star_selection_box, psf_train_validation_split, psfex_candidate_vetting, psf_modelling_software, - psf_model_complexity, psf_acceptance_thresholds] + psf_model_complexity, psf_sampling, psf_chromaticity, + psf_rendering, psf_acceptance_thresholds] decisions: star_selection_box: label: Stellar-locus selection, magnitude window and FWHM window scaled to the locus @@ -1186,7 +1121,7 @@ analyses: label: PSFEx pixel basis with degree-2 spatial variation per CCD rationale: >- A pixel basis with polynomial variation in XWIN/YWIN, fit per CCD - at native sampling. PSF_ACCURACY is the fractional accuracy PSFEx + (its sampling is psf_sampling). PSF_ACCURACY is the fractional accuracy PSFEx assumes for PSF pixel values; per the PSFEx documentation it enters the fit weights, and so how closely the model follows bright stars. Model flexibility trades overfitting against PSF leakage, the @@ -1200,7 +1135,6 @@ analyses: PSF_ACCURACY = 0.01; BASIS_NUMBER = 20; PSFVAR_DEGREES = 2; - PSF_SAMPLING = 1; PSFVAR_KEYS = XWIN_IMAGE,YWIN_IMAGE; PSFVAR_GROUPS = 1,1; MEF_TYPE = INDEPENDENT. @@ -1208,10 +1142,86 @@ analyses: options: pixel_basis_deg2_per_ccd: label: PIXEL basis, degree 2, per CCD - insights: [guinot22_psf_no_oversampling] deg3: label: Degree-3 spatial variation description: Needs more stars per CCD than the acceptance gate guarantees. + psf_sampling: + label: PSFEx model sampled on the native pixel grid + rationale: >- + PSFEx tabulates the model at one MegaCam pixel (0.187") per model + pixel, the published choice not to oversample (Guinot+22). Below + about 0.55" seeing the PSF FWHM is under three pixels and a + native-pixel model is undersampled: on the September 2022 + sub-0.55" nights stars come out up to 4% larger than the model, + and the PSF-leakage slope in T_PSF disappears when those stars are + removed (shapepipe#989). Oversampling by 2 doubles the model stamp + (PSF_SIZE 101 for the same 9.5") and needs the consumers to + render the model back onto native pixels (psf_rendering), so the + two change together; the ShapePipe patch testbed on Fir runs this + variant. No study supports native sampling at the sharpest + seeing. + Values: + PSF_SAMPLING = 1. + default: native + options: + native: + label: One model pixel per image pixel + insights: [guinot22_psf_no_oversampling] + oversampled_2: + label: PSF_SAMPLING 0.5, two model pixels per image pixel + description: >- + Needs PSF_SIZE 101 and psfex_interp rendering onto native + pixels; not implemented in the committed chain. + auto: + label: PSF_SAMPLING 0, PSFEx chooses from the seeing + description: >- + Per-CCD sampling; every consumer must then read the sampling + from the model header. + psf_chromaticity: + label: Achromatic PSF model + rationale: >- + [HARDCODED] The PSFEx model varies only with position on the CCD + (PSFVAR_KEYS XWIN_IMAGE,YWIN_IMAGE): it carries no colour term, so + a galaxy is deconvolved with the PSF of the stars that trained the + model, whatever its colour. The r-band PSF is chromatic: on + colour-purified run-1 PSF stars, star-minus-model size falls 0.69% + per magnitude of g−i at fixed r, and PSF stars (median g−i 1.3 to + 2.1) are redder than the lensing galaxies (0.9 to 1.3), so the + model is too large for galaxies by about 0.0–0.3%, part of the + 0.5% size excess (shapepipe#956). DES Y6 fits a PSF linear in g−i + per CCD and evaluates it at the galaxy's colour. No choice was + made here: PSFEx was taken as it comes, and ShapePipe's exposure + catalogues carry no colours to add a term with. + default: achromatic + options: + achromatic: + label: Position-only variation, no colour term + colour_linear: + label: PSF linear in g−i per CCD, evaluated at the galaxy colour + description: >- + Needs star and galaxy colours (PhotoPipe) inside the exposure + chain; not implemented. + psf_rendering: + label: Interpolated PSF taken as the model's centred stamp + rationale: >- + [HARDCODED] psfex_interp evaluates the model's polynomial at the + object's CCD position and returns the sum of the basis images, + centred on the stamp, at the model's own sampling. It neither + shifts the model to the object's sub-pixel phase nor resamples it + onto image pixels, so the PSF ngmix deconvolves with has the + centring of the model, not of the object, and this holds only + because psf_sampling is native. No study of the phase convention + exists; the ShapePipe patch testbed runs a phase-rendered variant + on Fir. + default: centred_model_stamp + options: + centred_model_stamp: + label: Basis sum at model sampling, centred + object_phase_native_pixels: + label: Rendered onto image pixels at the object's sub-pixel phase + description: >- + Required by an oversampled model; not implemented in the + committed chain. psf_acceptance_thresholds: label: Per-CCD PSF-model quality gate rationale: >- @@ -1346,6 +1356,153 @@ analyses: exact: 'The PSFEx parameters we used are presented in Table 1. We have chosen not to over-sample the PSF models.' location: { page: 5 } + # ═════════════════════════════════════════════════════════════════════════ + preparation: + description: >- + How exposures, astrometry, epoch lists and stamps are prepared before + anything is measured. + inputs: + - id: exposure_files + from: ../dr6_exposures + - id: tile_sexcat + from: ../detection.tile_sexcat + - id: psf_model + from: ../star_selection_psf.psf_model + outputs: + - id: epoch_stamps + type: data + format: sqlite + description: Per-object multi-epoch vignets + per-CCD WCS log feeding ngmix. + inputs: [exposure_files, tile_sexcat, psf_model] + decisions: + [astrometric_solution_source, ccd_split_extent, + epoch_provenance_from_tile_history, object_position_columns, + stamp_positioning_and_padding] + decisions: + astrometric_solution_source: + label: Astrometry taken verbatim from delivered per-CCD headers + rationale: >- + split_exp builds WCS(header) from each delivered CCD header, and + merge_headers stores these per-tile. Every committed world-to-pixel + step on exposures uses that solution: epoch membership, + multi-epoch stamp placement and OFFSET, tile-side PSF interpolation + positions, and the per-epoch ngmix Jacobian. [HARDCODED] No + astrometric re-derivation or refinement exists. A re-fit would shift + stamp centres and Jacobians and could change epoch membership. + default: delivered_headers + options: + delivered_headers: + label: WCS(header) verbatim, stored at split time + insights: [guinot22_gaia_astrometry] + astrometric_refit: + label: Joint astrometric re-solution + description: Not implemented. + ccd_split_extent: + label: All 40 MegaCam HDUs split and carried as candidate epochs + rationale: >- + Any HDU count other than N_HDU raises; every CCD is a candidate + epoch wherever the WCS lands it. + Values: + SPLIT_EXP_RUNNER.N_HDU = 40. + default: all_40_hdus + options: + all_40_hdus: + label: 40 HDUs, hard-fail on any other count + insights: [guinot22_forty_chips] + exclude_ccd_subset: + label: Exclude a subset of CCDs as epochs + description: Not implemented. + epoch_provenance_from_tile_history: + label: Epoch sets parsed from tile FITS HISTORY cards + rationale: >- + The tile's primary-header HISTORY cards are its exposure list, and + two readers parse the same cards. find_exposures takes the file name + in column COLNUM, strips the extension and deduplicates. EXP_PREFIX + is blank, so 2243881p keeps its p. This list decides which exposures + are retrieved, split and merged into the tile's WCS log. + make_post_process re-parses the HISTORY copied into the catalogue + (the digits before an optional p) and builds the EPOCH HDUs and + N_EPOCH that the stamps and ngmix use. It raises if a HISTORY + exposure is missing from the WCS log. A tile whose header or HISTORY + cannot be read fails; it never gets an empty exposure list. + Values: + FIND_EXPOSURES_RUNNER.COLNUM = 3. + default: history_parse + options: + history_parse: + label: HISTORY column 3, no prefix stripped, deduplicated + object_position_columns: + label: Windowed centroids (XWIN/YWIN) define every position + rationale: >- + PSF interpolation sites, tile and multi-epoch stamp centres, epoch + membership and the catalogue position all use the tile SExtractor + run's windowed centroid, in data and image simulations alike: in pixels + for tile stamps and exposure-side PSF validation, in world + coordinates for tile-side PSF interpolation and multi-epoch stamps. + Windowed, isophotal and model centroids differ systematically for + blends and asymmetric galaxies, and the centroid feeds the position + seed and the centroid prior. + Values: + config_tile_PiViVi_psfex.ini#PSFEX_INTERP_RUNNER.POSITION_PARAMS = + XWIN_WORLD,YWIN_WORLD; + VIGNETMAKER_RUNNER.POSITION_PARAMS = XWIN_WORLD,YWIN_WORLD; + VIGNETMAKER_RUNNER.COORD = SPHE; + config_exp_psfex.ini#PSFEX_INTERP_RUNNER.POSITION_PARAMS = + XWIN_IMAGE,YWIN_IMAGE. + default: xwin_windowed + options: + xwin_windowed: + label: Windowed centroids everywhere + isophotal_barycentre: + label: Isophotal barycentre (X_IMAGE/Y_IMAGE) + excluded: true + excluded_reason: >- + Noisier than the windowed centroid and pulled by asymmetric or + deblend-clipped footprints; on the DR6 image of tile 186.307 + it sits 0.16 px (median) and 1.6 px (p99) from it for + 20 < MAG_AUTO < 24.5, and the image simulations measure the + windowed one. + stamp_positioning_and_padding: + label: Nearest-pixel stamp extraction with zero padding + rationale: >- + [HARDCODED] stamps are cut around the pixel nearest the object's + position, with no sub-pixel interpolation; the sub-pixel remainder + is stored as the stamp's OFFSET, which ngmix uses as the Jacobian + origin (shape_measurement.centroid_source), so extraction and + centroid prior share one rounding. Multi-epoch stamps map the tile + world coordinate through the stored per-CCD WCS. Stamps overrunning + an image edge are kept, zero-filled outside the image; a stamp + centre that rounds outside the image raises and fails the vignet + run for the whole tile. + default: round_and_zero_pad + options: + round_and_zero_pad: + label: Nearest-pixel extraction, zero padding, no edge rejection + prior_insights: + guinot22_gaia_astrometry: + claim: >- + The astrometric solution the analysis relies on is the upstream + MegaPipe/Gaia DR2 calibration, accurate to within 20 mas; no + astrometric re-fit inside the pipeline is described. + created_at: "2022-04-01T00:00:00Z" + evidence: + - id: ev_guinot22_astrometry + doi: "10.48550/arXiv.2204.04798" + quote: + exact: 'An astrometric calibration within 20 mas was achieved using the Gaia DR2 observations' + location: { page: 2 } + guinot22_forty_chips: + claim: >- + Star selection and PSF modelling are carried out independently on + each of the 40 MegaCam chips, with no chip excluded. + created_at: "2022-04-01T00:00:00Z" + evidence: + - id: ev_guinot22_forty_chips + doi: "10.48550/arXiv.2204.04798" + quote: + exact: 'is performed independently on each of the 40 chips that constitute the MegaCAM' + location: { page: 3 } + # ═════════════════════════════════════════════════════════════════════════ shape_measurement: description: >- @@ -1353,8 +1510,7 @@ analyses: choices are fixed in code, so silent defaults concentrate here. inputs: - id: vignets - type: data - source: multi-epoch galaxy, weight, flag, background and background-RMS vignets + interpolated PSFs + from: ../preparation.epoch_stamps outputs: - id: ngmix_cat type: data @@ -2307,17 +2463,37 @@ analyses: detection catalogue and PSF quantities. inputs: - id: ngmix_chunks - type: data - source: per-tile ngmix catalogue chunks + tile sexcat + PSF diagnostics + from: ../shape_measurement.ngmix_cat + - id: tile_sexcat + from: ../detection.tile_sexcat + - id: mask_columns + from: ../masking.masked_measurement_inputs + - id: psf_model + from: ../star_selection_psf.psf_model outputs: - id: tile_final_cat type: data format: hdf5 - description: The assembled per-tile science catalogue (final_cat family). - inputs: [ngmix_chunks] + description: >- + The assembled per-tile science catalogue (final_cat family), + written by tile_make_cat to products_dir/tiles///. + final_cat_merge stacks a campaign's tiles into + final_cat_.hdf5, and the cross-campaign build (sp_latest.py) + into final_cat_latest.hdf5 (the root final_cat). + inputs: [ngmix_chunks, tile_sexcat, mask_columns, psf_model] decisions: [star_galaxy_classification, tile_overlap_handling, failure_sentinels] + - id: star_catalogue + type: data + format: hdf5 + description: >- + Every exposure's psfex_interp validation catalogue (held-out and + training stars, star and PSF-model moments per CCD), stacked by + star_cat_merge. Run 1's is run1-snap3/full_starcat_latest.hdf5 + (1.7 GB, 11,194,784 stars), released as v2.0.0 catalogs/stars/ and + catalogs/psf/. + inputs: [psf_model] decisions: star_galaxy_classification: label: Star/galaxy separation deferred out of the pipeline @@ -2407,3 +2583,51 @@ analyses: quote: exact: 's + 2σs > 0.0003' location: { page: 5 } + + # ═════════════════════════════════════════════════════════════════════════ + release: + description: >- + From ShapePipe's merged catalogue to the v2.0.0 release + (vos:cfis/weak_lensing/ShapePipe/v2.x/v2.0.0/, README.md there): the + cross-campaign snapshot run1-snap3, then sp_validation's selection, + metacal response and weights, the PhotoPipe join and the HATS + catalogues. ShapePipe makes none of these choices, so this record + holds none of their decisions: the selection cuts (size, S/N, flags, + mask bits 4, 8, 64 and 1024) are in catalogs/config_mask.yaml and the + recipe in provenance/calibrated_recipe.yaml, and their record is + sp_validation's (branch assay/decision-record). They are here so the + chain reads to its end. + inputs: + - id: merged_catalogue + from: ../catalogue_assembly.tile_final_cat + - id: star_catalogue + from: ../catalogue_assembly.star_catalogue + - id: coverage_maps + from: ../masking.exposure_maps + outputs: + - id: comprehensive_catalogue + type: data + format: parquet + description: >- + Every run-1 object (772,677,301) with every ShapePipe column and + the PhotoPipe DR6 photometry and photo-z, joined on + (TILE_ID, NUMBER): v2.0.0 catalogs/comprehensive/, HATS at + HEALPix order 5. + inputs: [merged_catalogue] + - id: calibrated_catalogue + type: data + format: parquet + description: >- + The calibrated cosmic-shear sample, 191,016,178 galaxies with + calibrated e1, e2, weight w_des and tomographic bin: v2.0.0 + catalogs/calibrated/ (HATS), with the response and additive bias + in catalogs/response.json. + inputs: [merged_catalogue, coverage_maps] + - id: psf_star_catalogues + type: data + format: parquet + description: >- + The PSF catalogue (5,565,959 stars) and the star catalogue + (11,194,784 stars, by EXPOSURE): v2.0.0 catalogs/psf/ and + catalogs/stars/. + inputs: [star_catalogue] diff --git a/src/shapepipe/modules/psfex_interp_package/psfex_interp.py b/src/shapepipe/modules/psfex_interp_package/psfex_interp.py index 5e7877c9c..a514e14bb 100644 --- a/src/shapepipe/modules/psfex_interp_package/psfex_interp.py +++ b/src/shapepipe/modules/psfex_interp_package/psfex_interp.py @@ -413,6 +413,8 @@ def interpsfex(self, dotpsfpath, pos): Use PSFEx generated model to perform spatial PSF interpolation. + @sc [decision:star_selection_psf.psf_rendering] + @sc [decision:star_selection_psf.psf_acceptance_thresholds,label:gate] psf-gate-path-specific-output Validation logs a rejected gate and skips writing validation output; the multi-epoch science path logs the same sentinel and skips that CCD diff --git a/universes/baseline_run1.yaml b/universes/baseline_run1.yaml new file mode 100644 index 000000000..a133ef75d --- /dev/null +++ b/universes/baseline_run1.yaml @@ -0,0 +1,86 @@ +id: baseline_run1 +description: >- + Run 1 of ShapePipe v2 as it ran, the pipeline behind run1-snap3 and the + v2.0.0 catalogue: 22,901 DR6 tiles in 969 campaigns on Nibi and Fir, + 17-27 Oct 2026, from ten integration/smk-g17..g19 commits (61b6255f for + 11,767 tiles, then 7f68451e, aad8cbce, 5df1e79c, de2b00f5, a169b3dc, + ab4c2934, 255d4392, ba0d7032, 84e842dd), each run on the image + shapepipe-develop-240b37e4.sif with the run config blend_handling uberseg, + defect_fill interpolate, defect_weighting fourfold_zero. The ten commits + make the same choice on every decision here. They differ only in the + N_EPOCH definition of the 237 smk-g17 tiles (rewritten afterwards to the + PSF-validated count), the tile pairing guard (no tile lost) and older + coverage-map fragments (rebuilt). The baseline differs from develop + (universes/committed.yaml) in one decision: run 1 predates the + per-detection defect columns (shape_measurement.defect_flagging, #973). + Develop also writes per-branch metacal shape errors (#1003), a column + change outside the record. +decisions: + per_unit_completeness: exact_counts + postage_stamp_size: px_51 + photometric_zeropoint: fixed_30_tiles_header_exposures +analyses: + masking: + decisions: + pixel_mask_source: instrument_flags_only + psf_star_mask_veto: instrument_flags_only + sky_mask_application: catalogue_columns + pointing_square: main_array_hull + nexp_map_valid_psf_ccds: valid_psf_ccds + defect_map_from_flags: count_flagged_pixels + detection: + decisions: + tile_detection: unions_catalogue + detection_threshold_policy: megapipe_tiles + deblending_policy: megapipe_tiles + background_model: auto_megapipe_tiles + weight_map_usage: map_weight + zero_weight_interpolation: interp_all + spurious_detection_cleaning: clean_1 + blend_photometry_mask_type: correct + saturation_level: header_saturate + photometry_parameters: kron_25_35 + detection_source_mode: sx_nomask_single_image + epoch_membership_ccd_bounds: trimmed_bounds_33_2080 + preparation: + decisions: + astrometric_solution_source: delivered_headers + ccd_split_extent: all_40_hdus + epoch_provenance_from_tile_history: history_parse + object_position_columns: xwin_windowed + stamp_positioning_and_padding: round_and_zero_pad + star_selection_psf: + decisions: + star_selection_box: locus_scaled_box + psf_train_validation_split: split_80_20_seeded + psfex_candidate_vetting: builtin_defaults + psf_modelling_software: psfex + psf_model_complexity: pixel_basis_deg2_per_ccd + psf_sampling: native + psf_chromaticity: achromatic + psf_rendering: centred_model_stamp + psf_acceptance_thresholds: stars22_chi2_2 + shape_measurement: + decisions: + ngmix_seed_mode: position_seed + galaxy_model: gauss + fit_initialisation: prior_guess_t025_ntry5_2 + fit_priors: gpriorba04_flat + metacal_scheme: five_types_step001_fitgauss + centroid_source: wcs + epoch_flux_rescaling: fscale + psf_epoch_averaging: galaxy_weight_sum + galaxy_pixel_weights: rms_vignet_weights + psf_likelihood_noise: psf_noise_1em5 + megacam_ccd_flip: megapipe_flip + defect_fill: interpolate + defect_flagging: stamp_wide_only + blend_handling: uberseg + defect_weighting: fourfold_zero + epoch_masked_fraction_cut: ten_percent + central_defect_veto: fixed_radii + catalogue_assembly: + decisions: + star_galaxy_classification: deferred_downstream + tile_overlap_handling: no_dedup_in_pipeline + failure_sentinels: sentinel_values diff --git a/universes/committed.yaml b/universes/committed.yaml index 13b5e3503..774ee87ea 100644 --- a/universes/committed.yaml +++ b/universes/committed.yaml @@ -41,6 +41,9 @@ analyses: psfex_candidate_vetting: builtin_defaults psf_modelling_software: psfex psf_model_complexity: pixel_basis_deg2_per_ccd + psf_sampling: native + psf_chromaticity: achromatic + psf_rendering: centred_model_stamp psf_acceptance_thresholds: stars22_chi2_2 shape_measurement: decisions: diff --git a/workflow/config/cfis/default.psfex b/workflow/config/cfis/default.psfex index 840f1ddfd..830be202d 100644 --- a/workflow/config/cfis/default.psfex +++ b/workflow/config/cfis/default.psfex @@ -13,7 +13,7 @@ BASIS_SCALE 1.0 # Gauss-Laguerre beta parameter NEWBASIS_TYPE NONE # Create new basis: NONE, PCA_INDEPENDENT # or PCA_COMMON NEWBASIS_NUMBER 8 # Number of new basis vectors -# @sc [decision:star_selection_psf.psf_model_complexity] +# @sc [decision:star_selection_psf.psf_sampling] PSF_SAMPLING 1. # Sampling step in pixel units (0.0 = auto) PSF_PIXELSIZE 1.0 # Effective pixel size in pixel step units @@ -37,7 +37,7 @@ PHOTFLUXERR_KEY FLUXERR_AUTO # Catalogue parameter for photometric error #----------------------------- PSF variability ------------------------------- -# @sc [decision:preparation.object_position_columns,decision:star_selection_psf.psf_model_complexity] +# @sc [decision:preparation.object_position_columns,decision:star_selection_psf.psf_model_complexity,decision:star_selection_psf.psf_chromaticity] PSFVAR_KEYS XWIN_IMAGE,YWIN_IMAGE # Catalogue or FITS (preceded by :) params # @sc [decision:star_selection_psf.psf_model_complexity] PSFVAR_GROUPS 1,1 # Group tag for each context key From 7e8654f36bbbf7631f002a5b4512e4107dc03ac1 Mon Sep 17 00:00:00 2001 From: Cail Daley Date: Sat, 21 Nov 2026 19:31:23 -0700 Subject: [PATCH 2/6] astra: correct the PSF sampling and colour evidence, the tile list and the release wiring Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JK7o9DgyMMqdmBBf6gXL7h --- astra.yaml | 55 ++++++++++++++++++------------------ universes/baseline_run1.yaml | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/astra.yaml b/astra.yaml index ba4316bcc..6bd34825e 100644 --- a/astra.yaml +++ b/astra.yaml @@ -97,13 +97,14 @@ inputs: - id: tile_list label: Run-1 tile list type: data - source: run1-snap3 MANIFEST.json tiles (22,901 ids); a subset of auxdir/CFIS/tiles_202604/tiles_r.txt (23,114) + source: auxdir/CFIS/tiles_202604/tiles_r.txt (22,901 ids; run1-snap3 MANIFEST.json tiles) description: >- - The 22,901 DR6 tiles run 1 processed, cut into HEALPix nside-4 cells - and batches of about 25 tiles: 16,123 ran on Nibi and 6,778 on Fir - (fir-tiles.txt in the Fir production kit). The exposure list is not an - input: tile_find_exposures reads it from the tile headers. Which rule - dropped the other 213 tiles of tiles_r.txt is not recorded. + The 22,901 DR6 tiles run 1 processed: the 23,114 r-band DR6 tiles less + 32 dateline duplicates and 181 tiles at Dec >= 82.5 (#969). Cut into + HEALPix nside-4 cells and batches of about 25 tiles, 16,123 ran on + Nibi and 6,778 on Fir (fir-tiles.txt in the Fir production kit). The + exposure list is not an input: tile_find_exposures reads it from the + tile headers. - id: healsparse_masks label: DR6 sky-fixed mask ladder (dr6-2026-09-29) type: data @@ -1150,11 +1151,9 @@ analyses: rationale: >- PSFEx tabulates the model at one MegaCam pixel (0.187") per model pixel, the published choice not to oversample (Guinot+22). Below - about 0.55" seeing the PSF FWHM is under three pixels and a - native-pixel model is undersampled: on the September 2022 - sub-0.55" nights stars come out up to 4% larger than the model, - and the PSF-leakage slope in T_PSF disappears when those stars are - removed (shapepipe#989). Oversampling by 2 doubles the model stamp + about 0.5" seeing (2.7 px FWHM) a native-pixel model is + undersampled, and on run 1's sharpest exposures stars come out up + to 4% larger than the model (#956, #989). Oversampling by 2 doubles the model stamp (PSF_SIZE 101 for the same 9.5") and needs the consumers to render the model back onto native pixels (psf_rendering), so the two change together; the ShapePipe patch testbed on Fir runs this @@ -1173,22 +1172,24 @@ analyses: Needs PSF_SIZE 101 and psfex_interp rendering onto native pixels; not implemented in the committed chain. auto: - label: PSF_SAMPLING 0, PSFEx chooses from the seeing + label: PSF_SAMPLING 0, PSFEx's automatic sampling description: >- - Per-CCD sampling; every consumer must then read the sampling - from the model header. + With SAMPLE_AUTOSELECT N, PSFEx assumes a nominal 6 px FWHM and + picks 1.28 px, coarser than native (#989). psf_chromaticity: label: Achromatic PSF model rationale: >- - [HARDCODED] The PSFEx model varies only with position on the CCD - (PSFVAR_KEYS XWIN_IMAGE,YWIN_IMAGE): it carries no colour term, so - a galaxy is deconvolved with the PSF of the stars that trained the - model, whatever its colour. The r-band PSF is chromatic: on + The PSFEx model varies only with position on the CCD (PSFVAR_KEYS + XWIN_IMAGE,YWIN_IMAGE): it carries no colour term, so a galaxy is + deconvolved with the PSF of the stars that trained the model, + whatever its colour. The r-band PSF is chromatic: on colour-purified run-1 PSF stars, star-minus-model size falls 0.69% - per magnitude of g−i at fixed r, and PSF stars (median g−i 1.3 to - 2.1) are redder than the lensing galaxies (0.9 to 1.3), so the - model is too large for galaxies by about 0.0–0.3%, part of the - 0.5% size excess (shapepipe#956). DES Y6 fits a PSF linear in g−i + per magnitude of g−i at fixed r (UNIONS star-selection study, Nov + 2026, not yet in an issue). PSF stars (median g−i 1.3 to 2.1) are + redder than the lensing galaxies (0.9 to 1.3), so the 0.5% model + size excess measured on faint stars (#956) is largely colour, and + what is left at galaxy colours is uncertain until a colour-aware + model or star simulations with SEDs measure it. DES Y6 fits a PSF linear in g−i per CCD and evaluates it at the galaxy's colour. No choice was made here: PSFEx was taken as it comes, and ShapePipe's exposure catalogues carry no colours to add a term with. @@ -2602,8 +2603,6 @@ analyses: from: ../catalogue_assembly.tile_final_cat - id: star_catalogue from: ../catalogue_assembly.star_catalogue - - id: coverage_maps - from: ../masking.exposure_maps outputs: - id: comprehensive_catalogue type: data @@ -2622,12 +2621,14 @@ analyses: calibrated e1, e2, weight w_des and tomographic bin: v2.0.0 catalogs/calibrated/ (HATS), with the response and additive bias in catalogs/response.json. - inputs: [merged_catalogue, coverage_maps] + inputs: [comprehensive_catalogue] - id: psf_star_catalogues type: data format: parquet description: >- The PSF catalogue (5,565,959 stars) and the star catalogue (11,194,784 stars, by EXPOSURE): v2.0.0 catalogs/psf/ and - catalogs/stars/. - inputs: [star_catalogue] + catalogs/stars/. The PSF catalogue is extracted from the merged + shape catalogue, the star catalogue from the stacked validation + catalogues. + inputs: [star_catalogue, merged_catalogue] diff --git a/universes/baseline_run1.yaml b/universes/baseline_run1.yaml index a133ef75d..b4202714c 100644 --- a/universes/baseline_run1.yaml +++ b/universes/baseline_run1.yaml @@ -2,7 +2,7 @@ id: baseline_run1 description: >- Run 1 of ShapePipe v2 as it ran, the pipeline behind run1-snap3 and the v2.0.0 catalogue: 22,901 DR6 tiles in 969 campaigns on Nibi and Fir, - 17-27 Oct 2026, from ten integration/smk-g17..g19 commits (61b6255f for + 10-27 Oct 2026, from ten integration/smk-g17..g19 commits (61b6255f for 11,767 tiles, then 7f68451e, aad8cbce, 5df1e79c, de2b00f5, a169b3dc, ab4c2934, 255d4392, ba0d7032, 84e842dd), each run on the image shapepipe-develop-240b37e4.sif with the run config blend_handling uberseg, From 4d266c8389a411c8ec168d31d295d503ffddfed3 Mon Sep 17 00:00:00 2001 From: Cail Daley Date: Sat, 21 Nov 2026 19:38:30 -0700 Subject: [PATCH 3/6] astra: root lineage through the stages, and the diagnostics each decision is judged by Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JK7o9DgyMMqdmBBf6gXL7h --- astra.yaml | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/astra.yaml b/astra.yaml index 6bd34825e..113808fcd 100644 --- a/astra.yaml +++ b/astra.yaml @@ -140,6 +140,8 @@ outputs: from: detection.tile_sexcat - id: shapes from: shape_measurement.ngmix_cat + - id: tile_catalogues + from: catalogue_assembly.tile_final_cat - id: final_cat type: data format: hdf5 @@ -148,7 +150,7 @@ outputs: Run 1's is run1-snap3/final_cat_latest.hdf5 (449 GB, 772,677,301 objects on 22,901 tiles; vos:cfis/weak_lensing/ShapePipe/v2.x/run1-snap3/, Fir data/v2.x/run1-snap3/). The decisions here act across the chain. - inputs: [dr6_tile_stacks, dr6_exposures, unions_tile_catalogues, healsparse_masks, tile_list, container_image] + inputs: [tile_catalogues, tile_list, container_image] decisions: [per_unit_completeness, postage_stamp_size, photometric_zeropoint] - id: star_catalogue from: catalogue_assembly.star_catalogue @@ -156,6 +158,48 @@ outputs: from: masking.exposure_maps - id: calibrated_catalogue from: release.calibrated_catalogue + # The diagnostics each decision is judged by. They are made per universe on + # a patch of DR6 by the ShapePipe patch testbed (27 south-cap tiles chosen + # to span sharp and typical seeing), and are not yet bound here. + - id: psf_residuals + label: PSF model residuals on reserve stars + type: figure + format: png + description: >- + Star-minus-model size and ellipticity on the 20% reserve stars held + out of the PSFEx fit, against flux, seeing, g−i colour and position on + the CCD. Judges star selection, PSF sampling, chromaticity and model + complexity. + inputs: [star_catalogue] + - id: rho_tau_statistics + label: ρ and τ statistics + type: figure + format: png + description: >- + The ρ statistics of PSF-model residuals and the τ correlations of + galaxy shapes with them, the additive PSF systematics the shear + inherits. Run 1's all-survey values are in the v2.0.0 data vector + (data_vector/SP_v2.0_tomo.sacc). + inputs: [star_catalogue, final_cat] + - id: galaxy_sample + label: Selected galaxies + type: table + format: csv + description: >- + The number, size and S/N distribution of galaxies with a shape + measurement, per tile: what a change to detection, masking or + shape measurement does to the sample. + inputs: [final_cat] + - id: shape_shifts + label: Shape shifts against the baseline + type: figure + format: png + description: >- + Object-matched differences in calibrated shape and PSF quantities + between this universe and baseline_run1, with the metacal response, + against S/N and size. In baseline_run1 it is the reproduction check + against run1-snap3. + inputs: [final_cat] decisions: From 0e3626f7454a032880e5a530913dbc4275efaaa8 Mon Sep 17 00:00:00 2001 From: Cail Daley Date: Sun, 22 Nov 2026 06:42:01 -0700 Subject: [PATCH 4/6] CLAUDE.md: Snakemake keeps running production while lc reproduces it Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01JK7o9HfQT1WTzw4mcuYUWh --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 1fd518512..1f839bd40 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -158,6 +158,11 @@ an implementation site, run `python -m tests.helpers.decisions [:]`; your branch touches and whether their record changed (CI posts this list on every PR). The format is ASTRA. +**Snakemake runs production.** The Snakemake workflow in `workflow/` keeps +running production while `lc` (Lightcone's command line, which runs the recipes +`astra.yaml` declares) reproduces its outputs stage by stage. Snakemake is +retired only once `lc` has been shown to do everything it does. + `uvx astra-tools@0.2.17 guide` is the briefing and `uvx astra-tools@0.2.17 spec` the field reference. The file's header states its conventions, including `[HARDCODED]` and `[LINT]`. From e5baff101973fbdabea270e6051d4b55f9375be9 Mon Sep 17 00:00:00 2001 From: Cail Daley Date: Mon, 23 Nov 2026 08:00:30 -0700 Subject: [PATCH 5/6] astra: migrate spec to ASTRA 0.1 and end at final_cat, star_catalogue and coverage_maps --- CLAUDE.md | 52 +- analyses/catalogue_assembly/astra.yaml | 117 + analyses/detection/astra.yaml | 325 +++ analyses/masking/astra.yaml | 181 ++ analyses/preparation/astra.yaml | 130 ++ analyses/shape_measurement/astra.yaml | 818 +++++++ analyses/star_selection_psf/astra.yaml | 359 +++ astra.yaml | 2855 +++--------------------- tests/helpers/decisions.py | 101 +- tests/unit/test_decisions.py | 3 +- universes/baseline_run1.yaml | 86 - universes/committed.yaml | 71 - 12 files changed, 2334 insertions(+), 2764 deletions(-) create mode 100644 analyses/catalogue_assembly/astra.yaml create mode 100644 analyses/detection/astra.yaml create mode 100644 analyses/masking/astra.yaml create mode 100644 analyses/preparation/astra.yaml create mode 100644 analyses/shape_measurement/astra.yaml create mode 100644 analyses/star_selection_psf/astra.yaml delete mode 100644 universes/baseline_run1.yaml delete mode 100644 universes/committed.yaml diff --git a/CLAUDE.md b/CLAUDE.md index 1f839bd40..373484813 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -139,33 +139,34 @@ where the change lives — and *scientific* decisions in `astra.yaml`, below. ## Scientific decisions live in `astra.yaml` -`astra.yaml` at the repo root is the pipeline's decision record: every -consequential scientific choice embedded in the code and committed configs, -with its rationale, alternatives and selected default. `universes/committed.yaml` -pins the option the committed configuration selects for every decision. -Each catalogue version or trial is a universe beside it, pinning the options -that version ran: `universes/baseline_run1.yaml` is run 1, the pipeline behind -the v2.0.0 catalogue. The record's root `inputs:` are the survey data the -pipeline reads (DR6 tiles, exposures, tile catalogues, masks, the image), and -its sub-analyses run in data order, wired by `from:`, from masking to the -release. `@sc [decision:]` tags live at implementing code/config sites; optional -`Values:` sentences assert committed values within those tagged sites. The -rationale stays in ASTRA, while local `@sc` contracts hold site-specific -constraints. `tests/unit/test_decisions.py` checks tag syntax, bidirectional -decision/site coverage, values, and test `decision` markers. To inspect tags at -an implementation site, run `python -m tests.helpers.decisions [:]`; -`--decision ` lists its sites, and `--diff origin/develop` the decisions -your branch touches and whether their record changed (CI posts this list on -every PR). The format is ASTRA. +`astra.yaml` at the repo root is the pipeline's ASTRA 0.1 decision record: +every consequential scientific choice embedded in the code and committed +configs, with its rationale, alternatives and evidence. Its `universes:` map +pins `baseline_run1` (run 1, the pipeline behind `run1-snap3` and v2.0.0) and +`committed` (current `develop`, derived from `baseline_run1`). Committed files +(`auxdir/CFIS/tiles_202604/tiles_r.txt`, `workflow/config.yaml`) are root +`inputs:`, external survey products (DR6 tiles, exposures, tile catalogues, +masks, runtime image) are root fetch `outputs:`, and six sub-analyses in +`analyses//astra.yaml` run in data order from `masking` through +`catalogue_assembly`, ending at `final_cat`, `star_catalogue` and +`coverage_maps`. `@sc [decision:]` tags live at implementing code/config +sites; optional `Values:` sentences assert committed values within those tagged +sites. The rationale stays in ASTRA, while local `@sc` contracts hold +site-specific constraints. `tests/unit/test_decisions.py` checks tag syntax, +bidirectional decision/site coverage, values, and test `decision` markers. To +inspect tags at an implementation site, run +`python -m tests.helpers.decisions [:]`; `--decision ` lists +its sites, and `--diff origin/develop` the decisions your branch touches and +whether their record changed (CI posts this list on every PR). **Snakemake runs production.** The Snakemake workflow in `workflow/` keeps running production while `lc` (Lightcone's command line, which runs the recipes `astra.yaml` declares) reproduces its outputs stage by stage. Snakemake is retired only once `lc` has been shown to do everything it does. -`uvx astra-tools@0.2.17 guide` is the briefing and -`uvx astra-tools@0.2.17 spec` the field reference. The file's header states -its conventions, including `[HARDCODED]` and `[LINT]`. +`uvx --prerelease allow astra-tools@0.3.0rc4 guide` is the briefing and +`uvx --prerelease allow astra-tools@0.3.0rc4 spec` the field reference. The +file's header states its conventions, including `[HARDCODED]` and `[LINT]`. Membership test: a different defensible choice would change which objects enter the shear catalogue, or the numbers attached to them. Detection thresholds, @@ -175,12 +176,13 @@ allocation, failure reporting, provenance) is out; it lives in the PR and in the PRD, CosmoStat/shapepipe#848. **A scientific change is not finished until the record is.** When a change moves -what the pipeline measures, amend `astra.yaml` in the same PR (add the decision, -or edit its rationale, options, Values and site tags), pin the selected option -in `universes/committed.yaml`, and say so in the PR description. +what the pipeline measures, amend `astra.yaml` (or the stage's +`analyses//astra.yaml`) in the same PR (add the decision, or edit its +rationale, options, Values and site tags), pin the selected option in the +`committed` universe of `astra.yaml`, and say so in the PR description. `tests/unit/test_decisions.py` runs in CI; a scientific change that breaks its site/value checks or leaves the record stale is unfinished. Before committing: ```bash -uvx astra-tools@0.2.17 validate +uvx --prerelease allow astra-tools@0.3.0rc4 validate --verify-evidence ``` diff --git a/analyses/catalogue_assembly/astra.yaml b/analyses/catalogue_assembly/astra.yaml new file mode 100644 index 000000000..82179b3af --- /dev/null +++ b/analyses/catalogue_assembly/astra.yaml @@ -0,0 +1,117 @@ +spec_version: 0.1.0 +label: Per-tile and star catalogue assembly +description: >- + The per-tile science catalogue: shape chunks merged and joined to the detection catalogue + and PSF quantities. +analyses: + shape_measurement: + path: ../shape_measurement + detection: + path: ../detection + masking: + path: ../masking + star_selection_psf: + path: ../star_selection_psf +outputs: + tile_final_cat: + type: data + format: hdf5 + description: >- + The assembled per-tile science catalogue (final_cat family), written by tile_make_cat + to products_dir/tiles///. final_cat_merge stacks a campaign's tiles into + final_cat_.hdf5, and the cross-campaign build (sp_latest.py) into final_cat_latest.hdf5 + (the root final_cat). + inputs: + - shape_measurement.ngmix_cat + - detection.tile_sexcat + - masking.masked_measurement_inputs + - star_selection_psf.psf_model + decisions: + - star_galaxy_classification + - tile_overlap_handling + - failure_sentinels + recipe: + command: shapepipe_run -c ../../workflow/config/cfis/config_tile_Mc.ini --out {output} + star_catalogue: + type: data + format: hdf5 + description: >- + Every exposure's psfex_interp validation catalogue (held-out and training stars, star + and PSF-model moments per CCD), stacked by star_cat_merge. Run 1's is run1-snap3/full_starcat_latest.hdf5 + (1.7 GB, 11,194,784 stars), released as v2.0.0 catalogs/stars/ and catalogs/psf/. + inputs: + - star_selection_psf.psf_model + recipe: + command: python ../../workflow/scripts/merge_star_cats.py --out {output} +decisions: + star_galaxy_classification: + label: Star/galaxy separation deferred out of the pipeline + rationale: >- + [HARDCODED] ShapePipe does no star/galaxy classification: make_cat keeps every detection, + and the catalogue carries no classification column. Separation happens downstream, in + sp_validation's size-based selection. The spread-model classifier Guinot+22 used (guinot22_spread_model_cut) + is removed from the pipeline. + options: + deferred_downstream: + label: No in-pipeline classification; catalogue ships all objects + spread_model_inline: + label: spread_model classification in make_cat + insights: + - guinot22_spread_model_cut + excluded: >- + It did not work reliably when last run, and it separates stars from galaxies worse + than the downstream classification. + tile_overlap_handling: + label: Tile-overlap duplicates neither removed nor flagged + rationale: >- + Adjacent tiles overlap, and the UNIONS per-tile catalogue spans the whole tile image, + so an object in an overlap is measured once in each tile. [HARDCODED] make_cat keeps + every row and adds TILE_ID and TILE_UNIQUE_ID (tile_id * 10**6 + NUMBER). The second + is unique per tile row, so an overlap object gets a different ID in each tile. No config + key deduplicates or flags overlap rows. sp_validation removes the duplicates by keeping + each object only inside its own tile's nominal box (classification_galaxy_overlap_ra_dec, + from TILE_ID and XWIN_WORLD/YWIN_WORLD). + options: + no_dedup_in_pipeline: + label: Ship overlap duplicates; sp_validation cuts each tile to its nominal box + overlap_flagging: + label: Flag overlap objects in the catalogue + description: Not implemented. + nearest_tile_centre: + label: Keep each object only in its nearest tile + excluded: >- + Not needed in the pipeline: the cut needs only each object's TILE_ID and position, + and sp_validation applies it downstream. Leaving it out keeps every tile-catalogue + row in the shape catalogue. + failure_sentinels: + label: Objects without shape measurements kept, with sentinel values + rationale: >- + [HARDCODED] detections with no ngmix row (no surviving epoch, or an exception during + the fit) stay in the catalogue with sentinels: sizes, fluxes and magnitudes 0, flux + and magnitude errors -1, ellipticities and their errors -10, size errors 1e30, NGMIX_N_EPOCH + 0. Their flag columns carry ngmix's own LM_FUNC_NOTFINITE bit (2**12; FLAGS_ + and NGMIX_MCAL_FLAGS) and NGMIX_MCAL_TYPES_FAIL is 5, as for a metacal type that reports + success without a finite shear, so the MCAL_FLAGS == 0 and MCAL_TYPES_FAIL == 0 cut + rejects them; NGMIX_N_EPOCH == 0 tells them apart from fitted objects. + options: + sentinel_values: + label: Keep with sentinels (flags LM_FUNC_NOTFINITE, e -10, T_ERR 1e30) + drop_unmatched: + label: Drop objects without shapes + excluded: Loses the photometry-only population and hides attrition. +prior_insights: + guinot22_spread_model_cut: + claim: >- + The published analysis selects galaxies inside the pipeline with the spread model, at + s + 2 sigma_s > 0.0003 together with s > 0 and 20 < MAG_AUTO < 26. + evidence: + - doi: 10.48550/arXiv.2204.04798 + quote: + exact: 'We then use the spread model to make the selection presented below:' + location: + value: page=5 + - doi: 10.48550/arXiv.2204.04798 + quote: + exact: s + 2σs > 0.0003 + location: + value: page=5 diff --git a/analyses/detection/astra.yaml b/analyses/detection/astra.yaml new file mode 100644 index 000000000..0ef2a3851 --- /dev/null +++ b/analyses/detection/astra.yaml @@ -0,0 +1,325 @@ +spec_version: 0.1.0 +label: Object detection +description: >- + Object detection on r-band tiles (the galaxy sample) and on single-exposure CCDs (PSF-star + candidates), both by ShapePipe's own SExtractor runs. The tile run follows the MegaPipe + parameters of Gwyn's UNIONS tile catalogue, and in committed data its detections are joined + to that catalogue (tile_detection); exposures keep ShapePipe's stock values. +analyses: + root: + path: ../.. +outputs: + tile_sexcat: + type: data + format: fits + description: Per-tile SExtractor LDAC catalogue with per-epoch CCD membership. + inputs: + - root.dr6_tile_stacks + - root.unions_tile_catalogues + decisions: + - tile_detection + - detection_threshold_policy + - deblending_policy + - background_model + - weight_map_usage + - zero_weight_interpolation + - detection_source_mode + - epoch_membership_ccd_bounds + - photometry_parameters + - spurious_detection_cleaning + - blend_photometry_mask_type + - saturation_level + recipe: + command: shapepipe_run -c ../../workflow/config/cfis/config_tile_Sx.ini --out {output} +decisions: + tile_detection: + label: Object list and NUMBER of the tile galaxy sample + rationale: >- + Both options run ShapePipe's tile SExtractor, so data and image simulations share one + detection and measurement path: windowed positions, VIGNET neighbour markers and every + SExtractor column. In real data each detection is then paired with its mutual nearest + neighbour within 1 px in Gwyn's UNIONS per-tile catalogue and takes its NUMBER, so shape, + photometry and photo-z catalogues share one object list and one ID (TILE_UNIQUE_ID); + unpaired detections leave the catalogue. The catalogue is MegaPipe's SExtractor run + on the same DR6 image with the configuration of default_tile.sex (detection_threshold_policy), + so pairs agree to 4e-5 px at the median. On tile 186.307 every one of the 41,201 detections + pairs; over eight DR6 tiles spanning a rich cluster, a bright star's halo, low latitude + and the survey edge, at least 99.7% of detections and 99.2% of catalogue objects pair. + The catalogue objects with no detection (0-0.7%, mostly fainter than MAG_AUTO 24.5) + are deblended children that ShapePipe's SExtractor leaves merged, concentrated around + very large objects; they have photometry but no shape. The join needs the tile image + to be the catalogue's release: on the DR5 image of a tile only ~95% of detections pair. + Unpaired detections still stop the run beyond both 2% and 20 objects, preserving the + check for other pixels. External-only losses never reject a tile: warn and record; no + cut is applied in the pipeline, and whether the catalogue consumer cuts on external_paired_fraction + (or catalogue_match in tile_make_cat.json) remains undecided (CosmoStat/sp_validation#444). + Hard rejection and an additive unpaired allowance both reject sparse edge tiles whose + losses are external-only (058.220: 71 external-only of 845 against an allowance of 66.9); + zero-weight or spatial exemptions would hide the losses the published counts expose. + The warning threshold is max(20, 0.02 N + 50), without the 50 if no pairs exist; it + is independent of the SExtractor guard settings. Sparse edge tiles 058.220 and 207.238 + exceed it, despite almost every detection pairing. Local correlated deblending losses + need not scale with tile population. Every joined tile records the five match counts, + external paired fraction and warning budget in its detection catalogue headers, then + in tile_detect and the published tile_make_cat.json manifest beside final_cat. Join + its unit (RRR.DDD) as a float to TILE_ID in the final catalogue to select the population + downstream. No external-only object gains a shape. PSF stars come from the exposure-level + SExtractor run in both options. Image simulations, which have no UNIONS catalogue, keep + SExtractor's own NUMBER. Values: input_types.data.tile_detection = unions_catalogue; + config_tile_Sx.ini#SEXTRACTOR_RUNNER.MATCH_RADIUS = 1.0; config_tile_Sx.ini#SEXTRACTOR_RUNNER.MATCH_MIN_FRACTION + = 0.98; config_tile_Sx.ini#SEXTRACTOR_RUNNER.MATCH_TOLERATED_UNPAIRED = 20; config_tile_Sx.ini#SEXTRACTOR_RUNNER.MATCH_EXTERNAL_UNPAIRED_ALLOWANCE + = absent. + options: + unions_catalogue: + label: Tile SExtractor joined to Gwyn's UNIONS per-tile catalogue + sextractor: + label: Tile SExtractor with its own NUMBER + detection_threshold_policy: + label: Detection significance, minimum area, matched filter + rationale: >- + Tile SExtractor uses the MegaPipe tile-catalogue threshold, minimum area and filter, + so that its galaxy sample reproduces the UNIONS catalogue whose NUMBER committed data + adopts (tile_detection). Run on the DR6 image of tile 186.307, it reproduces the DR6 + catalogue to 99.89% completeness and 100% purity with identical segmentation pixels; + the 45 misses are faint deblended children of bright parents (#929). The pixel stack + (MEMORY_PIXSTACK) holds the largest object on every tested tile, a bright star's halo + included, so no object is truncated. Unexplained: on tiles with such a large object + (a cD galaxy, a bright star's halo) MAG_AUTO and FLUX_RADIUS differ from the catalogue + by more than 1% for 2-11% of objects, most of them past the large object in SExtractor's + scan order, and on one low-latitude tile for 2% of objects spread over the tile. The + catalogue's run must differ in a setting not recorded here (memory, version); shapes + use ShapePipe's measurements and photometry the catalogue's, so for those objects the + two differ. This validates the configuration on data pixels, not detection on simulated + images. The 7x7 Gaussian of FWHM 3 px is near the CFIS average seeing of 0.65 arcsec + (about 3.5 px at 0.187 arcsec/px). Exposures only feed star selection and keep stock + values with the 3x3 FWHM 2 px kernel. The tiles differ from Guinot+22 in all three. + Values: config_tile_Sx.ini#SEXTRACTOR_RUNNER.DOT_SEX_FILE = $SP_CONFIG/default_tile.sex; + default_tile.sex#DETECT_THRESH = 1.0; default_tile.sex#ANALYSIS_THRESH = 1.0; default_tile.sex#DETECT_MINAREA + = 3; default_tile.sex#FILTER = Y; default_tile.sex#MEMORY_PIXSTACK = 3000000; config_tile_Sx.ini#SEXTRACTOR_RUNNER.DOT_CONV_FILE + = $SP_CONFIG/gauss_3.0_7x7.conv; config_exp_psfex.ini#SEXTRACTOR_RUNNER.DOT_SEX_FILE + = $SP_CONFIG/default_exp.sex; default_exp.sex#DETECT_THRESH = 1.5; default_exp.sex#ANALYSIS_THRESH + = 1.5; default_exp.sex#DETECT_MINAREA = 5; default_exp.sex#FILTER = Y; config_exp_psfex.ini#SEXTRACTOR_RUNNER.DOT_CONV_FILE + = $SP_CONFIG/default.conv. + options: + megapipe_tiles: + label: MegaPipe values on tiles; stock values on exposures + insights: + - guinot22_cfis_seeing + stock_tiles: + label: Stock ShapePipe values on tiles (1.5 sigma, minarea 5, FWHM 2 px) + insights: + - guinot22_sextractor_params + excluded: >- + Triggers spuriously on about 10% of grid-placed Sersic galaxies in image simulations, + and does not match the MegaPipe tile catalogue. + deblending_policy: + label: Deblending contrast + rationale: >- + Tiles use the MegaPipe DEBLEND_MINCONT; exposures use a lower one, the value Guinot+22 + lists. Both share DEBLEND_NTHRESH. Contrast sets object count, centroids, and blend + contamination in shapes; matching image simulations must preserve the stage-specific + settings. Values: default_tile.sex#DEBLEND_MINCONT = 0.002; default_exp.sex#DEBLEND_MINCONT + = 0.001; default_tile.sex#DEBLEND_NTHRESH = 32; default_exp.sex#DEBLEND_NTHRESH = 32. + options: + megapipe_tiles: + label: MINCONT 0.002 tiles / 0.001 exposures + insights: + - guinot22_sextractor_params + mincont_5em4_tiles: + label: MINCONT 0.0005 on tiles + excluded: >- + Part of the stock tile parameter set rejected in favour of the MegaPipe values (see + detection_threshold_policy). + background_model: + label: Background estimation and photometric background + rationale: >- + Both passes use SExtractor AUTO backgrounds: tiles with the MegaPipe mesh and filter + sizes and a LOCAL photometric background, exposures with a finer mesh and a GLOBAL one. + ngmix subtracts the exposure BACKGROUND map from each epoch and weights its pixels by + BACKGROUND_RMS (shape_measurement.galaxy_pixel_weights). The header background path + is off. Residual sky offsets propagate into thresholds, fluxes, completeness and shapes. + Values: default_tile.sex#BACK_TYPE = AUTO; default_tile.sex#BACK_SIZE = 512; default_tile.sex#BACK_FILTERSIZE + = 9; default_tile.sex#BACKPHOTO_TYPE = LOCAL; BACKPHOTO_THICK = 30; default_exp.sex#BACK_TYPE + = AUTO; default_exp.sex#BACK_SIZE = 64; default_exp.sex#BACK_FILTERSIZE = 3; default_exp.sex#BACKPHOTO_TYPE + = GLOBAL; config_exp_psfex.ini#SEXTRACTOR_RUNNER.BKG_FROM_HEADER = False; config_tile_Sx.ini#SEXTRACTOR_RUNNER.BKG_FROM_HEADER + = False. + options: + auto_megapipe_tiles: + label: AUTO everywhere; MegaPipe mesh and LOCAL photometry on tiles + manual_zero_tiles: + label: Tile background fixed to 0, trusting the stack subtraction + excluded: >- + Part of the stock tile parameter set rejected in favour of the MegaPipe values (see + detection_threshold_policy). + weight_map_usage: + label: Weight map as inverse variance for detection + rationale: >- + MAP_WEIGHT on both passes (SExtractor default NONE): the per-pixel variance sets the + effective SNR and so the detection set. RESCALE_WEIGHTS and WEIGHT_GAIN keep their SExtractor + defaults. Guinot+22 keeps every non-tabulated parameter at its default, which would + mean no weight map. Values: default_tile.sex#WEIGHT_TYPE = MAP_WEIGHT; default_exp.sex#WEIGHT_TYPE + = MAP_WEIGHT; default_tile.sex#RESCALE_WEIGHTS = Y; default_exp.sex#RESCALE_WEIGHTS + = Y; default_tile.sex#WEIGHT_GAIN = Y; default_exp.sex#WEIGHT_GAIN = Y; config_tile_Sx.ini#SEXTRACTOR_RUNNER.WEIGHT_IMAGE + = True; config_exp_psfex.ini#SEXTRACTOR_RUNNER.WEIGHT_IMAGE = True. + options: + map_weight: + label: MAP_WEIGHT + no_weight: + label: No weight map (SExtractor default) + insights: + - guinot22_sextractor_params + zero_weight_interpolation: + label: Interpolation across zero-weight pixels + rationale: >- + INTERP_TYPE ALL on both passes (SExtractor default NONE): SExtractor invents flux across + zero-weight pixels, changing detections and photometry near masked regions. Matching + image simulations must use the same interpolation operator; this is not a calibrated + pixel repair. Values: default_tile.sex#INTERP_TYPE = ALL; default_exp.sex#INTERP_TYPE + = ALL; default_tile.sex#INTERP_MAXXLAG = 16; default_tile.sex#INTERP_MAXYLAG = 16; default_exp.sex#INTERP_MAXXLAG + = 16; default_exp.sex#INTERP_MAXYLAG = 16. + options: + interp_all: + label: INTERP_TYPE ALL + no_interpolation: + label: INTERP_TYPE NONE + spurious_detection_cleaning: + label: Cleaning of spurious detections + rationale: >- + CLEAN on both passes deletes detections consistent with being wings of a brighter neighbour, + a post-deblend change to the object list. Keep the same cleaning prescription in matching + image simulations. Values: default_tile.sex#CLEAN_PARAM = 1.0; default_exp.sex#CLEAN_PARAM + = 1.0; default_tile.sex#CLEAN = Y; default_exp.sex#CLEAN = Y. + options: + clean_1: + label: CLEAN Y, CLEAN_PARAM 1.0 + blend_photometry_mask_type: + label: Neighbour pixels in blend photometry + rationale: >- + MASK_TYPE CORRECT on both passes replaces neighbour pixels by their mirror across the + object centre during photometry, changing blend fluxes and windowed moments. This SExtractor + photometry choice is separate from ngmix's neighbour-pixel weighting decision. Values: + default_tile.sex#MASK_TYPE = CORRECT; default_exp.sex#MASK_TYPE = CORRECT. + options: + correct: + label: MASK_TYPE CORRECT + blank: + label: MASK_TYPE BLANK + saturation_level: + label: Saturation level read from each image's header + rationale: >- + Each SExtractor pass takes the image's saturation level from its SATURATE header card + and sets FLAGS bit 4 on objects with saturated pixels. Neither .sex file sets SATUR_LEVEL, + so where the card is absent SExtractor falls back to its built-in level (50000 ADU per + its documentation). Delivered exposures carry the card (every CCD of 2114045p: 65535) + and split_exp keeps each CCD's header; a sampled tile (CFIS.186.307) has 9558.7. The + PSF-star masks require FLAGS == 0, so the level can remove bright stars from the PSF + sample. Changing the card or pinning a fixed level requires checking the resulting bright-star + selection. Values: default_exp.sex#SATUR_KEY = SATURATE; default_tile.sex#SATUR_KEY + = SATURATE; MASK:star_selection.FLAGS = "== 0"; MASK:preselect.FLAGS = "== 0"; MASK:flag.FLAGS + = "== 0"; default_tile.sex#SATUR_LEVEL = absent; default_exp.sex#SATUR_LEVEL = absent. + options: + header_saturate: + label: SATURATE header card; SExtractor default level where absent + fixed_level: + label: Fixed SATUR_LEVEL set in the .sex files + photometry_parameters: + label: Kron and aperture photometry definitions + rationale: >- + Stock Kron, aperture and flux-fraction settings; no rationale recorded. On the exposure + pass MAG_AUTO is the axis of the star-selection magnitude windows and FLUX_AUTO is PSFEx's + photometric normalisation, so a different Kron factor moves stars across those cuts. + The reported apertures and flux-fraction measurements must match the simulated catalogue + they are compared with. Values: default_tile.sex#PHOT_AUTOPARAMS = 2.5,3.5; default_exp.sex#PHOT_AUTOPARAMS + = 2.5,3.5; default_tile.sex#PHOT_APERTURES = 5; default_exp.sex#PHOT_APERTURES = 5; + default_tile.sex#PHOT_FLUXFRAC = 0.5; default_exp.sex#PHOT_FLUXFRAC = 0.5; PHOTFLUX_KEY + = FLUX_AUTO. + options: + kron_25_35: + label: Kron 2.5/3.5, aperture 5 px, FLUXFRAC 0.5 + detection_source_mode: + label: Single-image, unflagged detection on the r-band tile + rationale: >- + No detection image, no flag image, and the default_noimaflags.param column list: tiles + have no instrument flag image and no detection coadd exists, so detection sees every + tile pixel and the tile catalogue carries no IMAFLAGS_ISO; final_cat.param, the merge's + exact allow-list, does not request it. Without a detection image sextractor_runner calls + SExtractor in single-image mode, which on tile 186.307 reproduces the UNIONS catalogue's + MAG_AUTO to 0.01 mag for all but 0.03% of objects. Dual-image mode with the same image + twice is not equivalent: it changes the background, MAG_AUTO and FLUX_RADIUS of a fifth + of the objects (#936). Values: SEXTRACTOR_RUNNER.DETECTION_IMAGE = False; SEXTRACTOR_RUNNER.FLAG_IMAGE + = False. + options: + sx_nomask_single_image: + label: Unflagged single-image r-band detection + insights: + - guinot22_stacked_detection + masked_tile: + label: Detection on a tile masked by rasterised sky masks + description: Not implemented; no tile pixel mask exists (see masking.pixel_mask_source). + dual_image_coadd: + label: Dual-image mode with a detection coadd + description: Not implemented; no UNIONS detection coadd exists. + epoch_membership_ccd_bounds: + label: Which exposure CCDs an object belongs to (N_EPOCH) + rationale: >- + `all_world2pix(..., 0)` returns 0-based pixels, and the strict test accepts `33 < x + < 2080`. In 1-based FITS coordinates this is x=35 through x=2080 inclusive: it trims + DATASEC columns 33 and 34 but admits its upper endpoint, column 2080. [HARDCODED] The + comparisons are strict in make_post_process; CCD_SIZE sets only the bounds. A WCS inversion + failure skips that CCD, lowering N_EPOCH, which caps how many exposures enter each galaxy's + multi-epoch fit. This geometric count remains internal; the final catalogue's N_EPOCH + counts only epochs with a validated PSF. Image simulations' CCDs are trimmed to 2048x4612 + with no overscan, so their bounds are 0 < x < 2047, 0 < y < 4611 (input_types.image_sims + ccd_size, exported as SP_CCD_SIZE): under the data bounds an object at 2048 < x < 2080 + gains an epoch on pixels that do not exist, and one at x < 33 loses a real one. Values: + SEXTRACTOR_RUNNER.CCD_SIZE = ${SP_CCD_SIZE:-33,2080,1,4612}; input_types.image_sims.ccd_size + = 0,2047,0,4611; SEXTRACTOR_RUNNER.MAKE_POST_PROCESS = True. + options: + trimmed_bounds_33_2080: + label: x in (33,2080), y in (1,4612), strict + inclusive_bounds: + label: Same bounds, inclusive + description: Not implemented; make_post_process uses strict comparisons. +prior_insights: + guinot22_sextractor_params: + claim: >- + The published tile detection uses DETECT_THRESH 1.5, DETECT_MINAREA 10, the default + 3x3 filter and DEBLEND_MINCONT 0.001, with every other SExtractor parameter at its default. + evidence: + - doi: 10.48550/arXiv.2204.04798 + quote: + exact: >- + Table 2. SExtractor parametrisation. All other parameters are kept to their default + values. + location: + value: page=5 + - doi: 10.48550/arXiv.2204.04798 + quote: + exact: DEBLEND_MINCONT 0.001 + location: + value: page=5 + - doi: 10.48550/arXiv.2204.04798 + quote: + exact: DETECT_MINAREA 10 + location: + value: page=5 + guinot22_cfis_seeing: + claim: CFIS r-band data have an average seeing of 0.65 arcsec. + evidence: + - doi: 10.48550/arXiv.2204.04798 + quote: + exact: is taking r-band data with an average seeing of 0.65 arcsec + location: + value: page=1 + guinot22_stacked_detection: + claim: >- + Source extraction in the published analysis is performed on the stacked tile images, + for signal-to-noise and because artefacts are suppressed relative to single exposures. + evidence: + - doi: 10.48550/arXiv.2204.04798 + quote: + exact: >- + We do the extraction on stacked images which provide a better signal-to-noise ratio, + and most artifacts have a reduced amplitude with respect to single exposures + location: + value: page=5 diff --git a/analyses/masking/astra.yaml b/analyses/masking/astra.yaml new file mode 100644 index 000000000..9911b3195 --- /dev/null +++ b/analyses/masking/astra.yaml @@ -0,0 +1,181 @@ +spec_version: 0.1.0 +label: Masking and coverage maps +description: >- + Which external masks reach the measurement, and where. The instrument flag image delivered + with each exposure is the only one that reaches pixels. Sky-fixed masks (star halos and + bodies, manual regions, missing bands) are healsparse maps built and designed outside ShapePipe, + which only queries them at object positions into catalogue columns that no stage cuts on. +analyses: + root: + path: ../.. +outputs: + masked_measurement_inputs: + type: data + format: fits + description: >- + Exposure detection catalogues carrying IMAFLAGS_ISO (and MASK_EXT when maps are configured), + the flag stamps ngmix reads, and the final catalogue's MASK__ columns. + inputs: + - root.dr6_exposures + - root.healsparse_masks + decisions: + - pixel_mask_source + - psf_star_mask_veto + - sky_mask_application + recipe: + command: shapepipe_run -c ../../workflow/config/cfis/config_exp_psfex.ini --out {output} + exposure_maps: + type: data + format: hsp + description: >- + npoint_.hsp, ntaken_.hsp, nexp_.hsp and nflagged_.hsp at the mask + ladder's resolution: filled main-array pointings, all CCD DATASEC exposures, validated-PSF + CCD exposures, and flagged CCD pixel centres of validated CCDs per sky pixel. Products; + nothing in the workflow reads them. + inputs: + - root.dr6_exposures + decisions: + - pointing_square + - nexp_map_valid_psf_ccds + - defect_map_from_flags + recipe: + command: python ../../workflow/scripts/make_exposure_maps.py --out {output} +decisions: + pointing_square: + label: Filled main-array pointing coverage, excluding ears + rationale: >- + npoint is deliberately smooth pointing coverage, the v2 counterpart of v1.X's npoint3 + >= 3 cut. CCD tiling, gaps, ears and dithers produce patterned imaging-area counts instead. + The convex hull of DATASEC outer corners (half a pixel beyond pixel centres) of present + CCDs 0–35 is computed in a tangent plane about the exposure centre, mapped back to RA/Dec, + and rasterized by sky-pixel centre inclusion. CCDs 36–39 are ears outside the main 4x9 + array and are excluded. Every fragment contributes regardless of PSF success; gaps are + filled. + options: + main_array_hull: + label: Convex hull of present CCDs 0–35, gaps filled and ears excluded + ccd_tiling: + label: Individual CCD DATASEC footprints including gaps and ears + excluded: Measures taken imaging area (ntaken), not smooth pointing coverage. + nexp_map_valid_psf_ccds: + label: The exposure count covers only CCDs with a valid PSF model + rationale: >- + exp_maps takes the CCDs whose validation_psf catalogue exp_persist packed (psfex_interp + writes it only when the fit succeeds) and marks the sky pixels whose centres lie inside + each CCD's corner polygon. The CCDs of one exposure do not overlap, so summing fragments + counts exposures that can contribute a PSF-corrected epoch. ntaken counts all present + CCD DATASEC footprints, ears included, without the PSF requirement; ntaken - nexp measures + epochs lost to CCD-level PSF failure at each pixel. Both use centre-in-polygon inclusion + and count each exposure once even at overlapping footprint edges. + options: + valid_psf_ccds: + label: Count exposures whose CCD has a valid PSF model + all_ccds: + label: Use all CCD coverage for nexp rather than separately in ntaken + excluded: >- + Counts epochs that cannot contribute a shape, overstating depth exactly where the + PSF fit failed. + defect_map_from_flags: + label: Instrument flags counted per sky pixel, inside the imaging area + rationale: >- + The per-CCD flag images otherwise never leave the pixel domain, so a footprint built + from CCD corners would include defective pixels. exp_maps bins the centre of every nonzero-flag + pixel inside DATASEC into the sky pixel it falls in, and nflagged sums the counts over + exposures (~74 MegaCam pixels per sky pixel). The overscan border (flag 3, 3.6% of a + split) lies outside DATASEC and outside the coverage polygon. On exposures 2603236/2603237 + the remaining flags are 0.28% of the imaging pixels; any-touch rasterization of them + masks 2.2% of the sky, because single-pixel columns and cosmics widen to 1.6", so the + map keeps the count and leaves the threshold to the consumer (nflagged > 0 is the any-touch + mask). + options: + count_flagged_pixels: + label: Count flagged CCD pixels per sky pixel, summed over exposures + any_touch_boolean: + label: Boolean mask of every sky pixel a flagged pixel touches + excluded: >- + Widens one-pixel defects to the 1.6" sky pixel and loses how much of each sky pixel + is flagged; recoverable from the count as nflagged > 0. + pixel_mask_source: + label: Of the external masks, only the instrument flag image reaches pixels + rationale: >- + On exposures SExtractor reads the split flag image, producing IMAFLAGS_ISO, which the + PSF star selection requires to be zero. The multi-epoch vignet run cuts flag stamps + from the same image; ngmix gives flagged pixels weight 0 and drops epochs more than + 10% flagged (shape_measurement.defect_fill, shape_measurement.epoch_masked_fraction_cut). + Tiles have no flag image, and ShapePipe's tile SExtractor run requests no IMAFLAGS_ISO + (detection.detection_source_mode). Neighbour pixels are masked separately, from the + -1e30 markers SExtractor writes into the tile VIGNET and the coadd segmentation map + (shape_measurement.blend_handling). Sky-fixed masks never touch pixels: a star halo + changes no stamp. Values: config_exp_psfex.ini#SEXTRACTOR_RUNNER.FLAG_IMAGE = True; + VIGNETMAKER_RUNNER.ME_IMAGE_PATTERN = flag, image, weight, background, background_rms. + options: + instrument_flags_only: + label: Instrument flags gate pixels; sky masks stay at catalogue level + rasterised_sky_masks: + label: Rasterise healsparse masks into the pixel flags + insights: + - farrens22_pipeline_masks + excluded: >- + Sky-fixed masks say where an object sits, not that its pixels are corrupted, so + acting on them is an analysis decision. Rasterising would bake one mask version + into every shape. + psf_star_mask_veto: + label: PSF-star candidates rejected on instrument flags only + rationale: >- + Of the masks, star selection cuts only on IMAFLAGS_ISO. mask_query sits between SExtractor + and setools in the exposure chain; when MASK_PATHS names maps it writes MASK_EXT (0 + clean, nonzero flagged, off-coverage clean) onto each CCD's catalogue. MASK_PATHS ships + commented out, so the module passes catalogues through without MASK_EXT. The intended + map is the UNIONS star-body product (bit 2); halo bits 0 and 1 are left out because + halos say nothing about whether a star is a good PSF sample. Values: MASK:star_selection.IMAFLAGS_ISO + = "== 0"; MASK:preselect.IMAFLAGS_ISO = "== 0"; MASK:flag.IMAFLAGS_ISO = "== 0"; MASK:star_selection.MASK_EXT + = absent; MASK:preselect.MASK_EXT = absent; MASK:flag.MASK_EXT = absent. + options: + instrument_flags_only: + label: IMAFLAGS_ISO == 0; no sky map queried + star_body_veto: + label: Also reject candidates on the star-body map (MASK_EXT == 0) + description: >- + Set MASK_PATHS to the star-body map and add MASK_EXT == 0 beside each IMAFLAGS_ISO + cut in star_selection.setools (one line per mask block). Querying without the cut + records MASK_EXT and changes no star. + star_body_and_halo_veto: + label: Also reject candidates inside star halos + excluded: >- + Halos flag objects for the final catalogue; a star inside another star's halo is + not thereby a bad PSF sample. + sky_mask_application: + label: Sky masks written as catalogue columns; any cut is downstream + rationale: >- + The final catalogue ships every detected object. MASK_EXT_PATHS lists label:path pairs, + and make_cat queries each healsparse map at the object's windowed position and writes + the map value verbatim into a MASK_