diff --git a/CLAUDE.md b/CLAUDE.md index 47795c0d6..0e60a2a30 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -139,23 +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. -`@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. - -`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]`. +`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 --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, @@ -165,12 +176,16 @@ 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: +site/value checks or leaves the record stale is unfinished. Other module tests +(e.g. `tests/module/test_ngmix_defect_fill.py`) also read `astra.yaml`, so run +the full suite (`pytest --ignore=tests/science`) inside the container after +restructuring the ASTRA spec, not only `test_decisions.py`. 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_