cosmo-numba: B-modes and COSEBIs computations accelerated by Numba

Axel Guinot, Rachel Mandelbaum · 2026

Read cosmo-numba: B-modes and COSEBIs computations accelerated by Numba by Axel Guinot, Rachel Mandelbaum (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2603-18419.txt.

Introduction

Guinot and Mandelbaum present cosmo-numba, a Python package that speeds weak lensing computations with Numba. It computes E- and B-mode decompositions plus COSEBIs for cosmology analyses. Such decompositions serve both systematic checks and direct science work. Data volume no longer limits lensing studies; systematic errors do. Their implementation keeps both high precision and high speed, so neither becomes the bottleneck.

Catalog record

CREATORAxel Guinot, Rachel Mandelbaum
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE12944
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2603.18419

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

cosmo-numba: B-modes and COSEBIs computations accelerated by Numba Axel Guinot, Rachel Mandelbaum Abstract Summary Weak gravitational lensing is a widely used probe in cosmological analysis. It allows astrophysists to understand the content and evolution of the Universe. We are entering an era where we are not limited by the data volume but by systematic uncertainties. It is in this context that we present here a simple python-based software package to help in the computation of E-/B-mode decomposition, which can be use for systematic checks or science analysis. As we demonstrate, our implementation has both the high precision and speed required to perform this kind of analysis while avoiding a scenario wherein either numerical precision or computational time is a significant limiting factor. Statement of need The E-/B-mode composition for cosmic shear poses a significant computational challenge given the need for high precision (required to integrate oscillatory functions over a large integration range and achieve accurate results) and speed. Cosmo-numba meets this need, facilitating the computation of E-/B-mode decomposition using two methods. One of them is the Complete Orthogonal Sets of E-/B-mode Integrals (COSEBIs) as presented in P. Schneider et al. ( [ ref-Schneider_2010 ] ). The COSEBIs rely on very high precision computation requiring more than 80 decimal places. P. Schneider et al. ( [ ref-Schneider_2010 ] ) propose an implementation using mathematica . cosmo-numba uses a combination of sympy and mpmath to reach the required precision. This python version enables an easier integration within cosmological inference pipelines, which are commonly python-based, and facilitates the null tests. This software package also enables the computation of the pure-mode correlation functions presented in Peter Schneider et al. ( [ ref-Schneider_2022 ] ). Those integrals are less numerically challenging than the COSEBIs, but having a fast computation is necessary for their integration in an inference pipeline. Indeed, one can use those correlation functions for cosmological inference, in which case the large number of calls to the likelihood function will require a fast implementation. State of the field There are other implementations of the COSEBIs such as CosmoPipe 1 1 1 https://github.com/AngusWright/CosmoPipe used in the KiDS-legacy analysis ( [ ref-kids_legacy ] ). Our implemetation is characterized by the use of numba that makes the computation of the filter functions described in COSEBIs faster. Regarding the pure E-/B-mode decomposition, we have not found a similar publicly available implementation. That being said, they are classicaly used as a one-time measure for null tests in various surveys. The implementation we are presenting would enable one to use this decomposition for cosmological inference, which requires computing several integrals at each likelyhood call. While the commonly used scipy library would make the computation untractable, the speed gain by switching to numba opens new opportunities such as this one. Software design This package has been designed around two constraints: precision and speed. As it can be difficult to reach both at the same time, the code is partitioned in a way that parts requiring high precision are done using python libraries such as sympy and mpmath . In contrast, parts of the code that do not require high precision leverage the power of Just-In-Time (JIT) compilation. Numba provides significant speed up compared to a classic python implementation. As this library is intended to provide tools for cosmological computation, it was important to provide meaningful unit tests and demonstrate a full coverage of the library. Providing an accurate coverage is challenging when using numba compiled code. Our implementation allows the developer to disable compilation for the targeted part of the code when performing coverage tests. This allows us to provide both high quality unit tests and good coverage to the users. Testing setup In the following two sections we make use of fiducial shear-shear correlation functions, \xi_{\pm}(\theta) , and power spectra, P_{E/B}(\ell) . They have been computed using the Core Cosmology Library 2 2 2 https://github.com/LSSTDESC/CCL ( [ ref-Chisari_2019 ] ). The cosmological parameters are taken from Aghanim et al. ( [ ref-Planck_2018 ] ). For tests that involved covariances we are using the Stage-IV Legacy Survey of Space and Time (LSST) Year 10 as a reference. The characteristics are taken from the LSST Dark Energy Science Collaboration (DESC) Science Requirements Document (SRD) ( [ ref-LSST_SRD ] ). COSEBIs The COSEBIs are defined as: E_{n}=\frac{1}{2}\int_{0}^{\infty}d\theta\,\theta[T_{n,+}(\theta)\xi_{+}(\theta)+T_{n,-}(\theta)\xi_{-}(\theta)], (1) B_{n}=\frac{1}{2}\int_{0}^{\infty}d\theta\,\theta[T_{n,+}(\theta)\xi_{+}(\theta)-T_{n,-}(\theta)\xi_{-}(\theta)]; (2) where \xi_{\pm}(\theta) are the shear correlation functions, and T_{n,\pm} are the weight functions for the COSEBI mode n . The complexity is in the computation of the weight functions. Cosmo-numba carries out the computation of the weight functions in a logarithmic scale defined by: T_{n,+}^{\rm{log}}(\theta)=t_{n,+}^{\rm{log}}(z)=N_{n}\sum_{j=0}^{n+1}\bar{c}_{nj}z^{j}; (3) whare z=\rm{log}(\theta/\theta_{\rm{min}}) , N_{n} is the normalization for the mode n , and \bar{c}_{jn} are defined iteratively from Bessel functions (we refer the readers to P. Schneider et al. ( [ ref-Schneider_2010 ] ) for more details). We have validating our implementation against the original version in Mathematica from P. Schneider et al. ( [ ref-Schneider_2010 ] ). In Figure 1 we show the impact of the precision going from 15 decimal places, which corresponds to the precision one could achieve using float64, up to 80 decimal places, the precision used in the original Mathematica implementation. We can see that classic float64 precision would not be sufficient, and with a precision of 80 our code exactly recovers the results from the original implementation. Given that the precision comes at very little computational cost, we default to the original implementation using high precision. The impact of the precision propagated to the COSEBIs is shown in Figure 2 . We can see that using a lower precision than the default setting can incur a several percent error. Figure 1: In this figure we show the impact of the precision in the computation of the weight functions T_{\pm}^{\rm{log}} . For comparion, a precision of 15 corresponds to what would be achieved using numpy float64. The difference is computed with respect to the original Mathematica implementation presented in P. Schneider et al. ( [ ref-Schneider_2010 ] ). The figure uses symlog, with the shaded region representing the linear scale in the range [-10^{-15},10^{-15}] . Figure 2: This figure shows the difference in the COSEBIs E- and B-modes relative to the original Mathematica implementation. We see that using only 15 decimal places would lead to several percent error, making an implementation based on numpy float64 not suitable. The figure uses symlog, with the shaded region representing the linear scale in the range [-1,1] percent. COSEBIs can also be defined from the power spectrum as: E_{n}=\int_{0}^{\infty}\frac{d\ell\,\ell}{2\pi}P_{E}(\ell)W_{n}(\ell); (4) B_{n}=\int_{0}^{\infty}\frac{d\ell\,\ell}{2\pi}P_{B}(\ell)W_{n}(\ell); (5) where P_{E/B}(\ell) is the power spectrum of E- and B-modes and W_{n}(\ell) are the filter functions which can be computed from T_{n,+} as: W_{n}(\ell)=\int_{\theta_{\rm{min}}}^{\theta_{\rm{max}}}d\theta\,\theta T_{n,+}(\theta)J_{0}(\ell\theta); (6) with J_{0}(\ell\theta) the 0-th order Bessel function. The Equation 6 is a Hankel transform of order 0. It can be computed using the FFTLog algorithm presented in Hamilton ( [ ref-Hamilton_2000 ] ) implemented here in Numba . Figure 3 shows the comparison between the COSEBIs computed from \xi_{\pm}(\theta) and from C_{E/B}(\ell) . We can see that the COSEBI E- & B-modes agree very well, with at most 0.3\sigma difference with respect to the LSST Y10 covariance. We consider that using either approach would not impact the scientific

Read the complete text