Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<id>]` 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 <path>[:<line>]`;
`--decision <id>` 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/<stage>/astra.yaml` run in data order from `masking` through
`catalogue_assembly`, ending at `final_cat`, `star_catalogue` and
`coverage_maps`. `@sc [decision:<id>]` 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 <path>[:<line>]`; `--decision <id>` 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,
Expand All @@ -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/<stage>/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
```
117 changes: 117 additions & 0 deletions analyses/catalogue_assembly/astra.yaml
Original file line number Diff line number Diff line change
@@ -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/<shard>/<tile>/. final_cat_merge stacks a campaign's tiles into
final_cat_<run>.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_<SHEAR>
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
Loading
Loading