sp_validation.nz.calibration¶
Provisional SOM direct calibration of source redshift distributions.
Photometry is detected when finite and between 0 and 50 magnitudes.
The map uses all ten ugriz colours and r, standardized per feature.
Each BPZ bin has its own gold mask and source-weight/calibrator-count ratios.
The spectroscopic calibration sample’s fiducial Z_B is supplied as cal_z;
photoz always means DR6 BPZ Z_B.
- features(mag)[source]¶
Return the ten ugriz colours and r magnitude, in the training order.
@sc [decision:nz.som_map]
- train(mag, side=101, epochs=60, seed=42, workers=1)[source]¶
Train a planar batch SOM with PCA initialization and Gaussian smoothing.
@sc [decision:nz.som_map]
- assign(mag, model, workers=1)[source]¶
Return map distance and cell for detected five-band magnitudes.
- group_cells(model, n_groups=2000)[source]¶
Ward-cluster map code vectors into zero-based calibration groups.
@sc [decision:nz.som_map]
- z_magnitudes(mag, offset, use_z2=True)[source]¶
Return ugriz and z-channel IDs (0 missing, 1 canonical z, 2 mapped z2).
Canonical z takes precedence; z2 + offset enters only when z is undetected. Five-column inputs contain canonical z only.
@sc [decision:nz.z2_offset]
- quantile_edges(mag, photoz, weight, *, range, count, offset)[source]¶
Return BPZ bin edges holding equal shear weight between
range.The weight is that of sources with complete photometry and BPZ inside
range(lower edge included), before any gold selection. An interior edge is the BPZ value at which the weight below it is nearest to k/count, so it is one of the values BPZ takes.@sc [decision:nz.tomographic_bins]
- source_groups(mag, photoz, weight, model, *, offset, use_z2=True, chunk=1000000, workers=1)[source]¶
Assign eligible sources to BPZ bins and SOM cells in bounded chunks.
Returns the preliminary bin, the map cell and the z channel of each source; ineligible sources have bin and cell -1. BPZ intervals include the lower edge and exclude the upper edge.
@sc [label:convention] bpz-interval-lower-inclusive Every place that bins on BPZ uses [lo, hi): sources here, the weight population of
quantile_edges(), calibrators incalibrate(), andensemble.members(). BPZ takes discrete values and the interior edges are BPZ values, so objects sit exactly on edges; a source and a calibrator on one edge must land in the same bin, or the gold test and the group weights compare different populations.
- gold_threshold(cal_z, cal_photoz, floor=0.4, nmad_factor=5)[source]¶
Compute max(floor, factor × NMAD) of unnormalized spec-z − BPZ.
@sc [decision:nz.gold_selection]
- gold_mask(source_weight, source_photoz_sum, cal_count, cal_z_sum, threshold)[source]¶
Keep supported groups whose mean spec-z and source BPZ agree within QC.
@sc [decision:nz.gold_selection]
- tom_bin_ids(prelim, group, gold)[source]¶
Return 1-based gold bin IDs, with zero for every excluded row.
@sc [label:convention] tom-bin-id-numbering TOM_BIN_ID k in 1..n_bin is the k-th BPZ bin in increasing order and 0 is a row in no bin. cosmo_val selects a bin by
TOM_BIN_ID == kand drops IDs ≤ 0, and the GLASS mocks writeb + 1.
- deposit(z, weight, grid)[source]¶
Linearly deposit mass, conserving its zeroth and first trapezoid moments.
@sc [decision:nz.grid_step] @sc [label:invariant] deposit-conserves-moments The trapezoid integrals of the deposited density over the grid equal the total weight and the weighted mean redshift exactly, on any grid, so the grid step changes a bin’s width but never its mass or mean.
- calibrate(prelim, group, weight, photoz, cal_z, cal_photoz, cal_group, edges, n_groups, grid, *, gold=None, threshold=None)[source]¶
Calibrate each bin with source shear weight / in-bin calibrator count.
With
gold=None, compute QC masks from this source sample. Supplying gold freezes the selection while recalibrating the group weights. Histograms have unit integral per bin; the writer applies mixture fractions.