sp_validation.nz.ensemble¶
Realisations of the SOM n(z) calibration, every bin in each draw.
A calibrated bin is a weighted histogram of calibrator redshifts: calibrator
i in gold SOM group g of bin k carries S_kg / N_kg, the group’s source shear
weight over its number of in-bin calibrators (calibration.calibrate()).
A draw perturbs what enters that sum and recalibrates,
w_i = S_kg q_i / Σ_{j ∈ g, k} q_j,
so a gold group whose calibrators all leave it drops out, as an unsupported
group does in the calibration. Each term is switched on by its key in the
recipe’s ensemble section.
Statistical terms, through the factors q_i = m_i (1 + δ(z_i)):
bootstrap: m_i are multinomial bootstrap counts (calibrator shot noise);density: δ(z) is the galaxy density contrast along the line of sight through the spectroscopic footprint, a lognormal field on the output grid whose covariance is the nonlinear matter power seen through the footprint and each grid cell, times a linear bias squared (density_covariance()).
Systematic terms:
zero_points: a zero-point error δ of the calibration field relative to the sources, drawn as Gaussian colour offsets (u-g, g-r, r-i, i-z) with standard deviationscolour_sigmaand correlationscolour_corr, and a grey offset of standard deviationgrey. The calibrators trained the SOM, and training is translation-equivariant, so correcting their photometry by -δ moves the cells with them: every source moves by +δ against the SOM, shifting the catalogue’s weight between groups, and each calibrator’s BPZ, and so its bin, moves by -δ along its local gradient;z2_offset: an error ε in the constant that maps z2 onto z, offsetting the z band of every source measured through z2 (the calibrators have none);specz_failure: each calibrator’s redshift is, with this probability, replaced by the redshift of a random calibrator;nmad_factor: the gold-QC factor drawn uniformly from a range; gold is re-derived at that factor from the calibration’s own spectra and sources, so the bins’ source selection moves with it.
The offsets enter to first order: a draw adds half the difference between
the recalibrations at +v and -v, which cancels what is even in the offsets
(groups losing their last in-bin calibrator at either sign). Every term but
nmad_factor keeps the catalogue’s selection: the gold groups’ sources, wherever the
offsets move them, calibrated by whichever calibrators share their group.
The SOM and its groups are held fixed.
- DIRECTIONS = ('u', 'g', 'r', 'i', 'z', 'z2')¶
the calibration field’s five bands (as a source offset) and the z2 mapping.
- Type:
Offsets the source tables respond to
- group_tables(prelim, group, weight, photoz, n_bin, n_groups)[source]¶
Source weight and weighted BPZ summed per (bin, group).
- ensemble_inputs(mag, photoz, weight, prelim, channel, model, gold, *, offset, step=0.02, workers=1)[source]¶
Per-(bin, group) source tables, and the catalogue’s response to offsets.
prelimandchannelarecalibration.source_groups()of the sources at the recipe’s z2offset;goldis the calibration’s gold mask.source_weightandsource_photozsum every source with BPZ in a bin, as the gold test does.catalogue_jacobianis the derivative, in each ofDIRECTIONS, of the weight per (bin, group) of the catalogue’s own sources (those in gold at the fiducial), so the selection stays the catalogue’s while its sources move between groups. A direction is a magnitude offset of the sources against the SOM: one band for every source, or z for the sources measured through z2. Sources fill the cells densely, so the tables move linearly over a few hundredths of a magnitude; central differences at ±``step`` give the derivatives.
- photoz_gradient(mag, photoz, model, k=128)[source]¶
d BPZ / d m (n_cal, 5) of each calibrator, from its k nearest in the SOM space.
A least-squares plane of BPZ in ugriz through the neighbours.
- calibrator_weights(group, member, q, source)[source]¶
Weights (n_bin, n_cal): S_kg q_i / Σ_{j ∈ g, k} q_j.
sourceis the weight to calibrate per (bin, group), zero outside the selection; a group with weight but no in-bin calibrator drops out.
- gold_masks(z, photoz, group, member, source, source_photoz, floor, factor)[source]¶
Re-derive every bin’s gold mask, as
calibration.calibrate()does.
- band_offsets(colours, grey)[source]¶
Offsets of (u, g, r, i, z) from colour offsets (u-g, g-r, r-i, i-z) and r.
- density_covariance(grid, field, bias, cosmo, n_phi=4096, max_sep=500.0)[source]¶
Covariance of δ_g averaged over each grid cell of the footprint.
The footprint is a
field = (width, height)rectangle in degrees; each cell is the slab between midpoints of neighbouring grid redshifts. With W̃ the cell’s Fourier window,C_ij = b² ∫ d³k/(2π)³ P(k, z̄_ij) W̃_i(k) W̃_j*(k),
P the nonlinear matter power at the pair’s mean redshift. Separating the transverse window (angle-averaged, a function of k⊥χ only) leaves one integral over k⊥ and one over k∥. The first grid point (z = 0) has no volume and gets zero variance. Cells more than
max_sepMpc apart are uncorrelated.
- lognormal(cov, n_draw, rng)[source]¶
Draws of 1 + δ with covariance
covand unit mean in every cell.
- class Calibration(z: ndarray, photoz: ndarray, group: ndarray, weights: ndarray, gold: ndarray, edges: ndarray, grid: ndarray, source: ndarray, source_photoz: ndarray, jacobian: ndarray, photoz_gradient: ndarray, gold_qc: dict)[source]¶
Bases:
objectA calibration run’s state: what a draw perturbs and recalibrates.
sourceandsource_photozare the (n_bin, n_groups) tables of every source with BPZ in a bin,jacobianthe catalogue’s response inDIRECTIONS(ensemble_inputs()), andphotoz_gradienteach calibrator’s d BPZ / d m.- property member¶
- calibrate(z, q, gold, v=None)[source]¶
Unit-integral n(z) per bin of the selection
gold.vholds offsets inDIRECTIONS: the calibration field’s (u, g, r, i, z) zero-point error and the z2 mapping error. The catalogue’s sources move between groups along the Jacobian, and each calibrator’s BPZ moves by -grad·δ, the change correcting its photometry would make.
- realisations(cal, settings, density=None)[source]¶
Draws (n_draw, n_bin, n_z) and their raw mean before recentring.
settingsis the recipe’sensemblesection;densityis the covariance of δ on the grid (density_covariance()) when the density term is on. The draws are recentred so their mean is the calibration’s own n(z): the terms are zero-mean in their inputs, but the calibration is nonlinear in them, and the raw mean is returned so its offset can be reported.@sc [decision:nz.ensemble_terms]