sp_validation.cosmo_val.sacc_writers¶
Pair-native SACC writers and covariance helpers for cosmo_val products.
Each writer turns a computed statistic into a single-statistic SACC part.
Pairs are inserted in the supplied order, typically (0, 0), (0, 1), …, with
points and covariances pair-major. Covariance helpers map OneCovariance ξ± and
NaMaster iNKA matrices to the part’s point order. assemble_analysis_sacc()
combines the parts and their covariance blocks into an analysis file.
- xi_pairs_to_sacc(nz, metadata, pairs, *, grid, variances=None, covariance=None)[source]¶
One ξ± part over one or more bin pairs, on a named angular grid.
pairsis a sequence of(bins, xi):binsa source bin pair(i, j)andxia mapping withtheta,xip,ximand, optionally,theta_nom,npairs,weight. Each pair goes in as[ξ+; ξ−]in the order given, so the data vector is pair-major, and the covariance is tied to that order by position:covarianceis the dense block in it,variancesthe matching diagonal. At most one may be given.nzmust hold an n(z) for every bin the pairs name.
- 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 single-pair form of
xi_pairs_to_sacc(). The grid’s covariance comes in one of two shapes:covariance, the dense[ξ+; ξ−]-ordered block (a jackknife estimate), orvariances, the concatenated[varxip; varxim]diagonal. At most one may be given.
- onecov_xi_covariance(s, cov)[source]¶
OneCovariance’s real-space ξ± matrix
covin the insertion order ofs.OneCovariance writes ξ± type-major: every ξ+ point, then every ξ− point; within each, bin pairs
(i, j)withi <= jandioutermost, then θ ascending. A ξ± part is pair-major (xi_pairs_to_sacc()), so this finds each point ofsin OneCovariance’s order and permutescovto match. The two orders agree for a single bin pair. OneCovariance’s binkis columnkof the n(z) file, which must be the part’ssource_k.smust hold ξ± on one grid only, with the same θ points for every bin pair, as a part does.
- namaster_cl_covariance(s, cov_fits)[source]¶
Map iNKA pair-major covariance HDUs to a pseudo-Cℓ part’s order.
Each same-polarisation HDU is ordered by source pair, then increasing ℓ. Cross-polarisation blocks are zero, including across source pairs.
- pseudo_cl_to_sacc(nz, metadata, pairs, covariance=None)[source]¶
Write pair-major EE/BB/EB spectra and their bandpower windows.
Each payload contains
ell_eff, NaMaster’scl_allin row order [EE, EB, BE, BB], andwsp. Supplynsideonly for HEALPix-map spectra, to include the squared pixel window pw²(ℓ); catalogue spectra have no pixel window. Covariance follows the pair-major insertion order.
- cosebis_to_sacc(nz, metadata, pairs, scale_cut, covariance=None)[source]¶
Write each pair’s COSEBIs in [En; Bn] order at the scale cut.
Each payload contains
EnandBn. The supplied covariance follows that pair-major order and has its E×B and B×E blocks zeroed, including across pairs.
- pure_eb_to_sacc(nz, metadata, pairs, covariance=None)[source]¶
Write each pair’s
thetaand six arrays inPURE_KEYSorder.The order is
xip_E,xim_E,xip_B,xim_B,xip_amb,xim_amb; the covariance follows this order within each pair.
- rho_tau_to_sacc(nz, metadata, rho_stats, tau_by_bin, tau_cov_th_by_bin=None)[source]¶
One ρ/τ part: ρ_0…ρ_5 autos and τ_0/τ_2/τ_5 leakage.
rho_statscontainstheta,rho_{k}_p,rho_{k}_m,varrho_{k}_pandvarrho_{k}_mfor k=0,…,5. Each table intau_by_bincontainstheta,tau_{k}_p,tau_{k}_m,vartau_{k}_pandvartau_{k}_mfor k=0,2,5. ρ carries a variance diagonal. Each τ block has a variance diagonal, with its optional CovTauTh matrix scattered into its plus rows. CovTauTh has shape (3·nθ, 3·nθ), ordered k-major (0, 2, 5), plus only. Cross-bin covariances are approximated as zero.
- assemble_analysis_sacc(parts)[source]¶
Rebuild the single
{version}.saccanalysis file from parts.Each part is a single-statistic Sacc (from a
*_to_saccwriter, loaded from disk) carrying its own covariance = its block. Tracers and metadata are seeded fromparts[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 oneBlockDiagonalCovariance. Insertion order and block order therefore agree by construction — validated bysp_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
BlockDiagonalCovariancecovering every point.- Return type:
sacc.Sacc