Repository navigation
v2 tomographic n(z): SOM calibration on ID-joined PhotoPipe photometry, with realisations - #468
Merged
Merged
Conversation
…p duplicate reweighting figure Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9G4LJE9R9mdaj4rJ4J
cailmdaley
marked this pull request as draft
November 5, 2026 12:35
The recipe moves to config/calibration/nz/, the two scripts to scripts/calibration/, and the n(z) documentation into that directory's README, which now states that step 5 matches v2 shapes positionally to the _SP_ PhotoPipe run. cosmo_val keeps only the cat_config entry that reads the n(z) file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9Fx5zo6thPkqqgBJtf
Calibrator bootstrap and a lognormal line-of-sight density through the EGS footprint, both as per-calibrator factors renormalised within each (bin, SOM group) at fixed source weight. The recipe's ensemble section writes realisations.npz beside the n(z); nz_ensemble draws from an existing calibration_arrays.npz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9GtKZcSVp2ia5BoyyF
…ight covariance Draws are recentred on the calibration's own n(z): within-group renormalisation is nonlinear and shifted the raw mean by up to 0.75σ. The density covariance uses a linear k∥ grid that resolves cos(k∥Δχ) for every pair within 500 Mpc and sets farther pairs to zero; the log grid aliased spurious correlation between distant cells. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9GtKZcSVp2ia5BoyyF
… feat/som-nz-calibration # Conflicts: # cosmo_val/cat_config.yaml # src/sp_validation/tests/test_config_paths_exist.py
Sources are the rows of SP_v2.0's catalogue, joined by exact position to the shape HATS and row for row to PhotoPipe's run on Stephen Gwyn's DR6 IDs; calibrators are the DEEP2/3 spectra PhotoPipe matched to the same photometry. The recipe trains its SOM, selects gold on every source, and writes nz_tomo, nz_nontomo, tom_bin and the realisations; it runs on Fir from data roots. The positional _SP_ join, the frozen-model path and the candide reproduction gate go. SP_v2.0 reads the new n(z). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9E3HyXLyAaxYHPJKKF
cailmdaley
changed the base branch from
develop
to
feat/stages-and-data-roots
November 9, 2026 22:31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9E3HyXLyAaxYHPJKKF
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ErD1MGimG1LQFFHih
cailmdaley
changed the base branch from
feat/stages-and-data-roots
to
develop
November 10, 2026 00:17
cailmdaley
added a commit
that referenced
this pull request
Nov 10, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ErD1MGimG1LQFFHih
At a 0.01 step the calibrated n(z) resolves the line-of-sight structure of the single EGS calibration field, which is not a property of the source population. Depositing the spectra linearly on a 0.05 grid keeps each bin's mean exactly and moves the xi+- theory (12-83 arcmin) by Delta chi2 < 0.01 without IA and 0.06 with A_IA = 1 against the 0.01 grid. The realisations follow the recipe grid; sigma<z> is unchanged at the 1e-4 level. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ErD1MGimG1LQFFHih
cailmdaley
added a commit
that referenced
this pull request
Nov 10, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9ErD1MGimG1LQFFHih
cailmdaley
marked this pull request as ready for review
November 10, 2026 01:41
Extract science columns next to the data on CANFAR, match each shape object within its tile, and write the result on the shape catalogue's own partitions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9DmGKQmTfyz6ofoLvT
The non-SP PhotoPipe files number objects by his NUMBER, as the shape catalogue does, so the merge is an exact key join and position is only a sanity check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9DmGKQmTfyz6ofoLvT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9DmGKQmTfyz6ofoLvT
Pushed by the lint gate.
…es with a known n(z) nz/mock.py draws a galaxy population with known redshifts, ugriz colours from two spectral breaks, noisy photometry and a BPZ surrogate. Rung 0 calibrates with a representative spectroscopic sample, rung 1 with one selected on r. scripts/calibration/nz_mock_ladder.py scores an ensemble of realisations at a recipe's settings: the bias of each bin's mean redshift against the truth of its own TOM_BIN_ID sources, the bootstrap term against the scatter, and the unweighted estimator beside it. test_nz_mock.py is the small version, with a negative test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9H2KHG1LgWhAcWHS9V
… feat/collection-specz-calibrated-id
This reverts commit 564df26.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9H2KHG1LgWhAcWHS9V
…, not results; README says a run's n(z) goes with its own TOM_BIN_ID Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9H2KHG1LgWhAcWHS9V
…ws; the index names its primary relative to the collection The join reads and sorts the extension's whole key column only when the keys on the rows read differ from the primary's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9EQE4s8gF6uVCUhDyr
# Conflicts: # docs/source/stages.md # src/sp_validation/tests/test_column_schema.py
Replaces the per-tile spec-z files and the survey lookup by rounded coordinates: calibrators join on OBJECT_ID like the sources, selected by survey, by the spectrum's position (the EGS; DEEP2's colour-preselected Field 2 stays out, a recorded alternative) and complete ugriz. On v2 this gives 9,917 of the previous 9,920 (one merged-object row, two objects that are not shape rows), with equal z, magnitudes and BPZ. The sources test fixture no longer writes a null OBJECT_ID, which the collection never holds.
… what tells copies of a spectrum apart
The mock galaxies (nz/mock.py), the ladder script and their test move to feat/nz-mock-ladder, which becomes its own PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The calibration writes products only and imports no matplotlib; plot_nz.py draws the same figures from a run's calibration_arrays.npz, som_model.npz, summary.json and recipe.yaml, with optional reference and published n(z) overlays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cailmdaley
added a commit
that referenced
this pull request
Nov 15, 2026
…s and footprint The release's tomographic n(z) and footprint mask moved to #468's run3 bins (edges 0.10/0.38/0.55/0.75/1.20); these are the per-bin numbers on them, measured from the release's calibrated catalogue and masks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JK7o9DrEDLK8b2mU4ennH3
The collection build and its reader now live in #489, based on develop. This branch takes #489's tree whole and keeps the n(z) on top of it: the n(z) imports OBJECT_ID from sp_validation.assembly.object_id, the stage map gets back its n(z) entries and Redshifts section, and the column test its n(z) column names. The assembly modules at their old top-level paths and the per-step wrapper scripts go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 13:41
…nce for leaving it out Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cailmdaley
added a commit
that referenced
this pull request
Nov 15, 2026
…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
added a commit
that referenced
this pull request
Nov 15, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cailmdaley
changed the base branch from
feat/hats-collection-index
to
develop
November 15, 2026 15:52
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
This PR calibrates the v2 tomographic n(z) by SOM direct calibration: the same DR6 ugriz photometry for sources and calibrators, 9,917 DEEP2/DEEP3 spectra in EGS as calibrators, four bins of equal shear weight, and a per-bin gold selection.
One committed recipe produces it from the released calibrated catalogue and the v2 collection; the release on Fir now holds this run, and
SP_v2.0.0reads it.The n(z) is fit for validation, null tests and mocks, not for parameter constraints: the calibration has no known-answer test in this PR (the n(z) mock on the real catalogue is a follow-up PR, starting from the branch
feat/nz-mock-ladder), and several limits of the single calibration field are not modelled (see Validation).Each bin's n(z) on the Δz = 0.05 grid (line), the 16–84% range of the 2,000 realisations (band), and ⟨z⟩ (dashed) with the realisations' standard deviation. The shaded region is the bin's BPZ interval. The thin grey line is the same calibration on a 0.01 grid, whose spikes are line-of-sight structure in the single calibration field.
Method
v2.0.0/catalogs/calibrated), with its shear weightw_des. Each row takes PhotoPipe's photometry (dereddened GAaP ugriz, z2 and BPZ on Stephen Gwyn's DR6 detections) from the v2 HATS collection of The v2 catalogue as a HATS collection: an index on the DR6 object ID, PhotoPipe and spec-z as extensions #493 by its DR6 object ID,OBJECT_ID= 10⁶ × tile +NUMBER. No positions are compared. The photometry is used as delivered, with no zero-point correction. Where z is undetected, the second z-band exposure (z2) fills it after a constant −0.110 mag offset.OBJECT_ID), so calibrators and sources share one photometry: 9,917 DEEP2 and DEEP3 spectra whose position lies in the EGS (7,647 DEEP2, 2,270 DEEP3; RA 213.5–216.1°, Dec 51.9–53.7°), each kept once, with complete ugriz; 18.5% are at z > 1. The field bound matters: DEEP2 also covers Field 2 (RA 252°, 3,901 matched spectra), which it preselected by colour to z > 0.7, so it stays out. Tested on this run's SOM: inside groups shared with EGS, Field 2's spectra sit higher by +0.44, +0.31, +0.14 and +0.017 in bins 1–4, so the colour cut is not absorbed by the ugriz SOM, and adding Field 2 would move bin 3's ⟨z⟩ by +0.039 (3.7σ) while leaving σ⟨z⟩ almost unchanged. The code makes no redshift-quality cut. PhotoPipe's compilation (2026-10-19) gives every DEEP2/3 entry confidence 0.99, which I read as a secure-redshift selection made upstream (not confirmed).TOM_BIN_ID = 0. The agreement test removes 0.1–1.0% of a bin's weight; groups with in-bin sources but no in-bin spectrum remove 5–16%.Every choice above is recorded as a decision, with the alternatives not taken, in
scratch/cdaley/unions_astra/analyses/nz/astra.yaml.Where the shear weight goes
54.4% of the catalogue's shear weight is in a bin. Of the rest, 30.9% has photometry with at least one band undetected, and no galaxy is lost to the join.
Left: the catalogue's shear weight, split exclusively. Right: of all shear weight, the part with PhotoPipe photometry but undetected in each band (an object can miss several; "z and z2" means both are missing).
Bin edges
The edges are computed, not chosen: equal shear weight in BPZ between 0.10 and 1.20, recomputed by every run.
Equal weight gives the four bins comparable signal-to-noise, and 0.1–1.2 is the range KiDS uses for BPZ on ugriz-like photometry.
The assignment follows KiDS (a cut on the BPZ point estimate, SOM direct calibration with a gold selection; KiDS-1000 used five fixed-width bins, Hildebrandt et al. 2021). Equal-population edges follow DES Y3 and KiDS-Legacy (Myles et al. 2021; Wright et al. 2025), though DES assigns galaxies by SOM cell and not by a photo-z.
The alternatives (fixed edges kept across releases, equal number, assignment by SOM cell, fixed width) are in the decision record.
Two properties to know:
This PR's n(z) (solid) over the n(z) now in the v2.0.0 release (dashed), with each one's BPZ edges. ⟨z⟩ moves by +0.009, +0.006, −0.009 and −0.007. Recalibrating this run's inputs at the release's edges comes within 0.001 of the release's ⟨z⟩ (panel text), so the difference is the edges, plus the SOM retrained on 9,917 rather than 9,920 spectra. An earlier run with the old calibrator loader and the release's 9,920 spectra reproduced the release's n(z) to 6 × 10⁻¹⁵ at its edges, so the ID join gives the same photometry as the position match it replaces.
The release on Fir (
data/v2.x/v2.0.0/) now holds this run:nz/,provenance/nz_*and theTOM_BIN_IDcolumn ofcatalogs/calibrated(11.2M rows change bin: 4.1M from the edges, the rest gold flips of the retrained SOM). The release'sdata_vector/SP_v2.0_tomo.saccandmasks/footprint-tomo-nside4096-ring.fitswere made from the earlier bins and have not been remade. The copy on VOSpace still holds the hand-set edges until its owner uploads.Redshift error budget
σ⟨z⟩ = 0.010, 0.006, 0.011, 0.012 per bin, 35–66% of the 0.018 Δz prior of the 2D analysis, and ⟨z⟩ is correlated between bins (ρ = 0.21–0.70), almost entirely through the EGS zero points.
As n(z) modes on v2 ξ± (12–83′, A_IA = 0;
sp_validation.nz.modesfrom #474), the ensemble's expected Δχ² is 1.00, against 0.16 for the statistical terms alone and 4.07 for independent per-bin Δz shifts with σ = 0.018.Four modes keep 99.4% of it, with Gaussian amplitudes.
This is a lower bound: spectroscopic selection and incompleteness, and any bias of the method itself, are not in it.
The draws stay centred on the calibration's n(z). The zero-point and z2 terms enter to first order, and every term except the gold factor keeps the catalogue's
TOM_BIN_IDselection. The README's "Realisations" paragraph has the method and the reason for each size.n(z) modes of the combined ensemble
Expected Δχ² left after k modes for each ensemble and for the Δz prior (left), the first three modes of the combined ensemble (top) and its mode amplitudes against N(0, 1) (bottom).
Validation
This section lists what was checked and what was not. It does not show that the n(z) is right.
No known-answer test. This PR does not run the calibration on a simulation with a known n(z), so nothing here bounds the method's own bias. That test is the follow-up PR: n(z) mocks built on the real catalogue (its photometry, weights and positions, with injected true redshifts and zero-point maps), starting from the branch
feat/nz-mock-ladder.On the data.
In the test suite. Fast suite: 788 passed. New here: the ID join against a collection built in the test (each row takes its own ID's photometry, a repeated ID is refused), the calibrator selection against a collection with a spec-z extension (survey, field, completeness, one row per spectrum), the weight accounting, the quartile edges, and the decision record against the committed recipe (with a failing case for each check).
Not checked.
Calibrators against sources, gold selection, SOM maps
Each SOM group with in-bin spectra: the gap between its mean spec-z and its sources' mean BPZ (x), and its share of the bin's weight (y). Groups right of the threshold are rejected. Groups with no in-bin spectrum can't be placed here; the panel text gives their weight.
Code
config/calibration/nz/v2.yamlnames the inputs, every choice and the output directory. It reads the calibrated catalogue and the collection (sources and calibrators alike) through the release rootunions_v2and writes to the release'snz/; the run'srecipe.yamlis the committed file byte for byte.python scripts/calibration/calibrate_nz.py config/calibration/nz/v2.yaml --workers 32 [--output DIR], 20 minutes on 16 cores on Fir. Its README has the recipe and the realisation model.sp_validation.nz:inputs(sources and calibrators),calibration(SOM, groups, bin edges, gold, weights),pipeline(the run),ensemble(realisations). It writes products only; the figures in this description were drawn from them.scratch/cdaley/unions_astra/analyses/nz/astra.yaml, with@sctags at the code and recipe lines each decision governs.nz_tomo.txt,nz_nontomo.txt,tom_bin.parquet(OBJECT_ID,TOM_BIN_ID,ZBAND, row-aligned with the catalogue;TOM_BIN_IDis 1–4 for the bins and 0 for no bin),realisations.npz, and the calibration's arrays, SOM, summary and recipe.Builds on #493 (the v2 HATS collection and its reader, merged), which this PR reads through; this PR holds only the n(z).
docs/source/stages.md(from #493) gains the n(z) entries here: the n(z) is an output of calibrate, and cosmo_val only reads the file.For review. The recipe also writes
nz_nontomo.txt, the weighted sum of the bins. It describesTOM_BIN_ID > 0rows only, and cosmo_val does not yet select those rows by itself for a non-tomographic run.Closes #455. #274 (the photo-z group's SOM n(z)) stays open; this is the placeholder it will replace.
— Claude on behalf of Cail
🤖 Generated with Claude Code
https://claude.ai/code/session_01JK7o9GUjUZg9Uvn6EsnoHu