Repository navigation
The calibrated v2 sample, built by sp_validation and checked against its snapshot - #490
Open
cailmdaley wants to merge 30 commits into
Open
cailmdaley wants to merge 30 commits into
cailmdaley wants to merge 30 commits into
Conversation
…' into feat/calibrated-sample-build
… feat/calibrated-sample-build # Conflicts: # src/sp_validation/tests/test_column_schema.py
sp_validation.sample reads a snapshot's shapes (the v2 collection), selects with the committed mask config, sums the weight-table moments and response sums over HEALPix pixels, and writes the calibrated HATS catalogue with OBJECT_ID and a record of the snapshot it was built from. - response: the DES table is fitted from per-cell moments, and the response from per-cell sums, both additive over chunks of a catalogue. - metacal: global_response=False stops after the branch selections and the per-object shear response. - galaxy: the tile-overlap cut takes the survey's tile set, so a chunk of a catalogue finds its neighbours. - io: an entry that names a snapshot is checked against its catalogue's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9GGvpp2uq6JnvoG4Pa
…k an entry's snapshot at cosmo_val start Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9GGvpp2uq6JnvoG4Pa
…EADME and orchestrator decision Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9GGvpp2uq6JnvoG4Pa
…d what the comparison writes Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9GGvpp2uq6JnvoG4Pa
… feat/calibrated-sample-build # Conflicts: # docs/source/stages.md # src/sp_validation/tests/test_column_schema.py
…n counts NaN and missing rows, NUMBER keeps its type The rule declares only the build's last file, so Snakemake's removal of declared outputs cannot reach catalogs/calibrated and the build's own refusal to overwrite holds on the workflow route. Tests pin the per-tile manifest check, unpaired rows and NaN in the comparison, the survey statistics, and the response sums on nonfinite coordinates. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9GGvpp2uq6JnvoG4Pa
…import guard walks subpackages
… feat/calibrated-sample-build # Conflicts: # docs/source/stages.md
cailmdaley
added a commit
that referenced
this pull request
Nov 14, 2026
…is a rebuild that records one (#490)
…wrappers leave The n(z) (nz_*.py, its recipe, calibrate_nz.py, tests, README section and the TOM_BIN_ID change to the Gaussian-sims script) came in with the earlier collection branch and is #468's; the assembly wrappers are replaced by #493's recipe and rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cailmdaley
changed the base branch from
develop
to
feat/hats-collection-index
November 15, 2026 14:25
cailmdaley
added a commit
that referenced
this pull request
Nov 15, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # config/calibration/nz/v2.yaml # docs/source/stages.md # scripts/calibration/README.md # scripts/calibration/calibrate_nz.py # src/sp_validation/nz/calibration.py # src/sp_validation/nz/ensemble.py # src/sp_validation/tests/test_column_schema.py # src/sp_validation/tests/test_nz_calibration.py # src/sp_validation/tests/test_nz_ensemble.py # src/sp_validation/tests/test_nz_inputs.py
cailmdaley
changed the base branch from
feat/hats-collection-index
to
develop
November 15, 2026 15:52
…ple build Conflicts resolved with #425's response.py and calibration.py as the truth; io.py and cosmo_val/core.py keep the sample's snapshot check beside #425's weight check and additive_bias import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESEcatXjL8bDkTC5c
…ir rows A chunk accumulated over the tiles it holds stays small; gather places each into the full label set in place, so a catalogue read pixel by pixel never builds a dense per-chunk array over every tile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESEcatXjL8bDkTC5c
Each pixel accumulates response.Sums over the tiles it holds (Cuts and table_edges from the metacal block, the dat cuts as preselection); Sums.gather adds them into every snapshot tile; fit_table, estimate and the refitted delete-one-tile jackknife give the table, R, c_e and their covariance; each pixel is written with response.calibrate and the table's weights. New product catalogs/response_sums.npz keeps the sums, grouped by TILE_KEY. Tests compare the build with response.calibrate_catalogue on all rows at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESEcatXjL8bDkTC5c
…ibrated sample port The n(z) modules are develop's (#468) and stay. response.py is #425's. In the dr6_catalogue record, #425's response, weight, table, uncertainty and additive-bias decisions are the definitions; the sample's weights_and_response becomes sample_wide_calibration (one table and one R for the whole sample, from sums that add over pixels), and #425's additive_bias takes the sample's note on patch scatter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESEcatXjL8bDkTC5c
#425's weight_table decision pins response.calibrate_catalogue#des_min_count, the default of metacal.get("des_min_count", 3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESEcatXjL8bDkTC5c
cailmdaley
changed the base branch from
develop
to
feat/consistent-response-weights
November 15, 2026 18:14
cailmdaley
added a commit
that referenced
this pull request
Nov 15, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sp_validation.sample.bins passes over the collection once, gives every preselected row its TOM_BIN_ID from its photometry with the n(z) stage's saved model (fixed across metacal branches), accumulates response.Sums per (tile, bin) with the release's cuts, edges and weight table, and writes each bin's response.record under "bins" in catalogs/response.json. It stops unless every tom_bin.parquet galaxy with an object ID is selected with its released bin (the galaxies it does not name by ID being as many as its rows without one), and unless the bins' sums add to response_sums.npz. Rule bin_responses (workflow/rules/calibrate.smk), script scripts/calibration/bin_responses.py, synthetic tests, docs, ASTRA note. Co-Authored-By: Claude Opus <noreply@anthropic.com>
…mo_val, scripts pass) into the calibrated sample build Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9E2jzNjuJU8HV3b13n
…sample-on-unified-response
…sample-on-unified-response
…librated sample build Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1 # Conflicts: # scratch/cdaley/unions_astra/analyses/dr6_catalogue/astra.yaml # src/sp_validation/cosmo_val/core.py # src/sp_validation/io.py
… response bins.run measures a record for every bin, bin 0 (no bin) included, then rewrites the catalogue: each row gets its TOM_BIN_ID from nz/tom_bin.parquet and e = R_k^-1 (g - c_e,k), g recovered from the shear and the calibration the file carries, so a second run leaves it as it is. A record with bins says the catalogue carries each row's bin's R and c_e. The sample's record names its weights. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1
…etakes the sample's survey statistics Every file and then the record are staged before any is installed, and a run that finds a staged record installs it first, so an interrupted run cannot leave a catalogue its record does not describe. Object IDs come from TILE_ID and NUMBER, as the sample build makes them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1
…uild Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1
…ne weight table for the sample Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1
…uild Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1
…uild Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1 # Conflicts: # scratch/cdaley/unions_astra/analyses/dr6_catalogue/astra.yaml
…s calibration Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1
cailmdaley
added a commit
that referenced
this pull request
Nov 23, 2026
…les hold, calibrated-sample provenance, fetch manifest without local paths and with a fresh checksum list survey_stats.py needs sp_validation.response (#490) and goes with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9FJPrhcYFM7drXAZcJ
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The calibrated v2 sample is now built by sp_validation itself, from one recipe and one Snakemake rule, and the build reproduces the released
v2.0.0catalogue object by object. Closes #480.It also calibrates each galaxy with the response of its own tomographic bin.
The bins' responses are 0.855, 0.859, 0.832 and 0.776 against 0.787 for the whole sample, so one R for everything puts the shear of bins 1–3 high by 6–9%.
Once the n(z) stage has assigned the bins, a second step measures each bin's R and c and rewrites the catalogue's
e1,e2with them.Open, and to settle before merging: whether the per-bin calibrated shear is written into the catalogue, as here, or the catalogue keeps one calibration and each bin's response is applied when a statistic is measured, as DES Y3 does. The numbers are the same either way. The release on VOSpace is not changed by this PR.
Stacked on #425, which defines the weights, response, c and m once in
sp_validation.response; this PR builds the sample with that module and reads the HATS collection of #493 (merged).Why
The released sample (191,016,178 galaxies on 22,901 tiles) was built by run scripts outside the repository, against two sp_validation checkouts that are not develop. Nothing checked its tile set against the ShapePipe snapshot, which is how the first version missed a ~540 deg² wedge (#480).
What changed
sp_validation.sample: the build as library code.pipeline.run(recipe, output, workers)reads the collection's shapes one HEALPix pixel at a time, cuts tile overlaps against the whole snapshot's tile set, applies the selection, sums the moments that give the DES weight table and the global response and additive bias, then writes each pixel calibrated, withOBJECT_ID. It writes no comprehensive intermediate.comparepairs two calibrated catalogues on the DR6 object ID (OBJECT_ID, or computed fromTILE_IDandNUMBER; on position when neither gives one) and reports the largest difference per column.config/calibration/sample/v2.yamlnames the snapshot, shapes, selection config and release directory.workflow/calibrate/Snakefile(or the main workflow, when its config has acalibrateblock) runs it in the image, optionally followed by the comparison. The commands are inscripts/calibration/README.md.cat_config.yamlentry names the snapshot it expects undershear.snapshot, and cosmo_val stops at start if the catalogue records a different one.sp_validation.response, summed pixel by pixel. Besides the catalogue, the build writescatalogs/response_sums.npz(the per-tile sums the response is estimated from) and the tile-jackknife covariance of R inresponse.json.sp_validation.sample.binsand the rulebin_responses: the response of each tomographic bin. One pass over the collection gives every preselected galaxy its bin from its photometry with the n(z) stage's saved model, held fixed across the metacal branches, and reduces the rows to sums per (tile, bin) with the sample's weight table held fixed. It stops unless the bins are those ofnz/tom_bin.parquetand the bins' sums add to the sample's. Each bin's record (R, its shear and selection parts, c, tile-jackknife covariance) goes intocatalogs/response.jsonunderbins, the galaxies in no bin included as bin 0. The step then rewrites the catalogue: each row gets itsTOM_BIN_IDande = R_k⁻¹(g − c_k)with its own bin's R_k and c_k. The rewrite is staged whole and installed together with the record, so an interrupted run cannot leave a catalogue its record does not describe.dr6_catalogueASTRA record, with their alternatives.Why Snakemake and not Lightcone. Lightcone (lc 0.5.1) does not run recipes in an existing image: it builds its own, which apptainer cannot do on Fir.
lc initalso turns the project into a git-annex dataset, which every clone of this repository would inherit. A Snakemake rule runs in the same image as every validation rule. The ASTRA record keeps Lightcone as the alternative.Validation
Rebuilt from 03d5cc1 (on #425's
sp_validation.response; 3 min on 60 cores on Fir) and compared withdata/v2.x/v2.0.0/catalogs/calibrated:OBJECT_IDand 26 on exact position (the release'sNUMBER = −1rows); none in only one catalogue.SIZE_RATIO,SNR,N_EPOCH,TILE_KEYare identical. |Δe| ≤ 3e-14, |Δw|/w ≤ 1.1e-14 (tolerance 1e-10); R agrees to 1e-16.scripts/calibration/README.mdon a fresh working directory, without reading source, and got the same 191,016,178 rows withagree: true(6.5 min on 16 cores). The nine places it had to guess are now written into the README.test_sample.py,test_sample_record.py): the chunked build equals in-memorymetacalon synthetic data; an end-to-end HATS run; the snapshot guards (manifest SHA, status, per-tile counts); compare with missing rows and NaN; response sums with non-finite coordinates. Fast suite on this branch: 882 passed.Per-bin calibration
Means of the diagonal; tile-jackknife errors are 1–4 × 10⁻⁴. The selection part is 2–5% of R and changes sign between bins.
The bins step run on a copy of the release (4 minutes on 64 cores, reading the 772,677,301-object collection and rewriting the 191,016,178-row catalogue):
TOM_BIN_IDare identical to the release in all 1,817 files, and the new shear equals R_k⁻¹(R_all e + c_all − c_k) of the released shear to 2 × 10⁻¹⁶.Not checked: the build on a tile set other than run1-snap3, a rebuild on another machine, the response of the bin assignment itself (a galaxy's bin is held fixed across the metacal branches), and the same per-bin step on mocks.
Caveats
SP_v2.0.0entry now names its snapshot, and the released catalogue records none, so cosmo_val on that entry fails until the release'scatalogs/calibratedis replaced by a rebuild. Onedgethis onecat_config.yamlblock is left out until then.SP_v2.0.0entry here describes the per-bin calibrated catalogue (itscov_thσ_e values are those of the per-bin shear). The catalogue now in the release is calibrated with the whole sample's R.OBJECT_ID, which the release lacks, and noTOM_BIN_ID; the bins step adds it.— Claude (Opus, then Fable) on behalf of Cail
🤖 Generated with Claude Code
https://claude.ai/code/session_01JK7o9ESjsJpK9G5wRraxC1