sp_validation.cosmo_val.sacc_writers

Born-as-SACC writers for the cosmo_val data products.

A thin, pure layer between the cosmo_val mixins (which compute statistics as TreeCorr / NaMaster / b_modes arrays) and sp_validation.sacc_io (which knows the file layout). Each *_to_sacc function turns one already-computed statistic into a single-statistic SACC — a part — carrying that statistic’s own covariance as its one block. assemble_analysis_sacc() rebuilds the single {version}.sacc analysis file from these parts.

Everything here is single-bin today (bins=(0, 0)); the interface is tomography-native so a future round supplies real bin pairs unchanged.

xi_to_sacc(nz, metadata, theta, xip, xim, *, grid, theta_nom=None, npairs=None, weight=None, variances=None, covariance=None)[source]

One ξ± part (bins=(0, 0)) on a named angular grid.

The grid’s covariance comes in one of two shapes: covariance, the dense [ξ+; ξ−]-ordered block (a jackknife estimate), or variances, the concatenated [varxip; varxim] diagonal. At most one may be given.

pseudo_cl_to_sacc(nz, metadata, ell_eff, cl_all, wsp, covariance=None, nside=None)[source]

One pseudo-Cℓ part: EE/BB/EB with the shared bandpower window.

cl_all is NaMaster’s decoupled (4, nbp) array (EE, EB, BE, BB); the window comes from bandpower_window_from_workspace(). Supply nside only for HEALPix-map spectra, whose measured spectrum includes pw²(ℓ); catalogue-based spectra have no pixel window. covariance, when given, is the dense [EE; BB; EB]-ordered block matching insertion.

cosebis_to_sacc(nz, metadata, result, scale_cut)[source]

One COSEBIs part at the fiducial scale cut.

result is a single scale-cut result dict from b_modes.calculate_cosebis — {"En", "Bn", "cov", ...} — where cov is the [En; Bn]-ordered COSEBIs covariance.

pure_eb_to_sacc(nz, metadata, theta, eb, covariance=None)[source]

One pure-E/B part: the six sacc_io.PURE_KEYS blocks.

eb is a mapping with the six keys (xip_E … xim_amb); each array is sampled at theta. covariance, when given, is the dense block in PURE_KEYS order (matching b_modes._EB_KEYS and the insertion order).

rho_tau_to_sacc(nz, metadata, rho_stats, tau_stats, tau_cov_th=None)[source]

One ρ/τ part: ρ_0…ρ_5 autos and τ_0/τ_2/τ_5 leakage.

rho_stats / tau_stats are the shear_psf_leakage handler tables (columns theta, rho_{k}_p, varrho_{k}_p, … and the τ analogue). ρ carries a varrho diagonal; τ carries a vartau diagonal, with tau_cov_th — a (3·nbin, 3·nbin) k-major matrix over the τ-plus points only — scattered into the τ-plus rows/columns when given. tau_cov_th=None leaves the τ block fully diagonal.

_copy_data_points(dst, src)[source]

Append every data point of src into dst (tags preserved).

assemble_analysis_sacc(parts)[source]

Rebuild the single {version}.sacc analysis file from parts.

Each part is a single-statistic Sacc (from a *_to_sacc writer, loaded from disk) carrying its own covariance = its block. Tracers and metadata are seeded from parts[0] (every part describes the same catalogue version). Data points are re-added in the order the parts are given, which must be the canonical order (ξ± reporting, pseudo-Cℓ, COSEBIs, pure-E/B, ρ/τ), and the per-part blocks become one BlockDiagonalCovariance. Insertion order and block order therefore agree by construction — validated by sp_validation.sacc_io.assemble_covariance().

Parameters:

parts (sequence of sacc.Sacc) – Single-statistic parts, each with a covariance, in canonical order.

Returns:

The analysis Sacc with a BlockDiagonalCovariance covering every point.

Return type:

sacc.Sacc