abcmb.ABCMBTools module
Script for helper numerical tools
- abcmb.ABCMBTools.bilinear_interp(x, y, z, xq, yq)[source]
Bilinear interpolation on 2D regular grid.
Performs bilinear interpolation to evaluate function at query point (xq, yq) given values on a regular 2D grid.
Parameters:
xarray1D array of x-coordinates (must be sorted)
yarray1D array of y-coordinates (must be sorted)
zarray2D array of function values, shape (len(y), len(x))
xqfloatQuery x-coordinate
yqfloatQuery y-coordinate
Returns:
- float
Interpolated value at (xq, yq)
Notes:
Uses standard bilinear interpolation formula with four nearest grid points.
- abcmb.ABCMBTools.d00(mu, ells)[source]
Compute Wigner d-matrix elements d^ell_{00}.
Parameters:
muarrayCosine of rotation angle
ellsarrayMultipole values starting from ell=2
Returns:
- array
d^ell_{00} elements for ells >= 2
- abcmb.ABCMBTools.d1n(mu, ells, n)[source]
Compute Wigner d-matrix elements d^ell_{1n}.
Parameters:
muarrayCosine of rotation angle
ellsarrayMultipole values
nintSecond index (abs(n) <= 1)
Returns:
- array
d^ell_{1n} elements
- abcmb.ABCMBTools.d2n(mu, ells, n)[source]
Compute Wigner d-matrix elements d^ell_{2n}.
Parameters:
muarrayCosine of rotation angle
ellsarrayMultipole values
nintSecond index (abs(n) <= 2)
Returns:
- array
d^ell_{2n} elements
- abcmb.ABCMBTools.d3n(mu, ells, n)[source]
Compute Wigner d-matrix elements d^ell_{3n}.
Parameters:
muarrayCosine of rotation angle
ellsarrayMultipole values
nintSecond index (abs(n) <= 3)
Returns:
- array
d^ell_{3n} elements, zero-padded for ell < 3
- abcmb.ABCMBTools.d4n(mu, ells, n)[source]
Compute Wigner d-matrix elements d^ell_{4n}.
Parameters:
muarrayCosine of rotation angle
ellsarrayMultipole values
nintSecond index (abs(n) <= 4)
Returns:
- array
d^ell_{4n} elements, zero-padded for ell < 4
- abcmb.ABCMBTools.fast_interp(x, xp_min, xp_max, fp)[source]
Fast 1D linear interpolation for uniformly-spaced grids.
Optimized interpolation that avoids searchsorted by exploiting uniform grid spacing. Significantly faster than jnp.interp for large arrays.
Parameters:
xfloat or arrayQuery points for interpolation
xp_minfloatMinimum value of interpolation grid
xp_maxfloatMaximum value of interpolation grid
fparrayFunction values on uniform grid
Returns:
- float or array
Interpolated values at query points
Notes:
Credit: JAX issue #16182 (https://github.com/jax-ml/jax/issues/16182) Assumes fp is uniformly spaced between xp_min and xp_max.
- abcmb.ABCMBTools.gauss_legendre_weights(n, tol=1e-16, max_it=50)[source]
Iteratively finds the roots and weights for Gauss-Legendre quadrature integration between -1 and 1, given the number of roots n requested.
Parameters:
nintNumber of roots desired, typically set by lmax of the lensed power spectrum.
toljnp.float64Accuracy tolerance on the Newton root finder.
max_itintMaximum iteration on the Newton root finder.
Returns:
- (mu, w)(jnp.array, jnp.array)
The roots mu and weights w.
- abcmb.ABCMBTools.wigner_d_matrix(mu, ells, m, n)[source]
Compute Wigner d-matrix elements for rotation.
Recursively computes reduced Wigner d-matrix elements d^ell_{mn}(beta) for CMB lensing calculations using three-term recurrence relation.
Parameters:
muarrayCosine of rotation angle beta
ellsarrayMultipole values [m, m+1, m+2, …, ellmax]
mintFirst index (must be positive and >= abs(n))
nintSecond index (must satisfy abs(n) <= m)
Returns:
- array
Wigner d-matrix elements, shape (len(mu), len(ells))