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:

  • x array

    1D array of x-coordinates (must be sorted)

  • y array

    1D array of y-coordinates (must be sorted)

  • z array

    2D array of function values, shape (len(y), len(x))

  • xq float

    Query x-coordinate

  • yq float

    Query 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:

  • mu array

    Cosine of rotation angle

  • ells array

    Multipole 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:

  • mu array

    Cosine of rotation angle

  • ells array

    Multipole values

  • n int

    Second 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:

  • mu array

    Cosine of rotation angle

  • ells array

    Multipole values

  • n int

    Second 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:

  • mu array

    Cosine of rotation angle

  • ells array

    Multipole values

  • n int

    Second 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:

  • mu array

    Cosine of rotation angle

  • ells array

    Multipole values

  • n int

    Second 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:

  • x float or array

    Query points for interpolation

  • xp_min float

    Minimum value of interpolation grid

  • xp_max float

    Maximum value of interpolation grid

  • fp array

    Function 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:

  • n int

    Number of roots desired, typically set by lmax of the lensed power spectrum.

  • tol jnp.float64

    Accuracy tolerance on the Newton root finder.

  • max_it int

    Maximum 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:

  • mu array

    Cosine of rotation angle beta

  • ells array

    Multipole values [m, m+1, m+2, …, ellmax]

  • m int

    First index (must be positive and >= abs(n))

  • n int

    Second index (must satisfy abs(n) <= m)

Returns:

array

Wigner d-matrix elements, shape (len(mu), len(ells))