lenspyx.lensing

See examples/demo_lenspyx.ipynb for example calls of this couple of routines

lenspyx.lensing.alm2lenmap(alm, dlms, geometry: tuple[str, dict] = ('healpix', {'nside': 2048}), epsilon=1e-07, verbose=0, nthreads: int = 0, pol=True)[source]

Computes lensed CMB maps from their alm’s and deflection field alm’s.

Parameters:
  • alm – undeflected map healpy alm array or sequence of arrays

  • dlms

    The spin-1 deflection, in the form of one or two arrays.

    The two arrays are the gradient and curl deflection healpy alms:

    \(\sqrt{L(L+1)}\phi_{LM}\) with \(\phi\) the lensing potential

    \(\sqrt{L(L+1)}\Omega_{LM}\) with \(\Omega\) the lensing curl potential

    The curl can be omitted if zero, resulting in principle in slightly faster transforms

  • geometry (optional) – sphere pixelization, tuple with geometry name and argument dictionary, defaults to Healpix with nside 2048

  • epsilon (optional) – target accuracy of the result (defaults to 1e-7)

  • verbose (optional) – If set, prints a bunch of timing and other info. Defaults to 0.

  • nthreads (optional) – number of threads to use (defaults to os.cpu_count())

  • pol (optional) – if True, input arrays are interpreted as T and E if there are two, T E B if there are 3, otherwise performs only spin-0 transforms. Defaults to True.

Returns:

lensed maps, each an array of size given by the number of pixels of input geometry. T, Q, U if pol and there 2 or 3 input arrays, otherwise spin-0 maps

lenspyx.lensing.alm2lenmap_spin(gclm: ndarray, dlms: ndarray, spin: int, geometry: tuple[str, dict] = ('healpix', {'nside': 2048}), epsilon: float = 1e-07, verbose=0, nthreads: int = 0)[source]

Computes a deflected spin-weight lensed CMB map from its gradient and curl modes and deflection field alm.

Parameters:
  • gclm – undeflected map healpy gradient (and curl, if relevant) modes (e.g. polarization Elm and Blm).

  • dlms

    The spin-1 deflection, in the form of one or two arrays.

    The two arrays are the gradient and curl deflection healpy alms:

    \(\sqrt{L(L+1)}\phi_{LM}\) with \(\phi\) the lensing potential

    \(\sqrt{L(L+1)}\Omega_{LM}\) with \(\Omega\) the lensing curl potential

    The curl can be omitted if zero, resulting in principle in slightly faster transforms

  • spin (int >= 0) – spin-weight of the maps to deflect (e.g. 2 for polarization).

  • geometry (optional) – sphere pixelization, tuple with geometry name and argument dictionary, defaults to Healpix with nside 2048

  • epsilon (optional) – target accuracy of the result (defaults to 1e-7)

  • verbose (optional) – If set, prints a bunch of timing and other info. Defaults to 0.

  • nthreads (optional) – number of threads to use (defaults to os.cpu_count())

Returns:

lensed maps for input geometry (real and imaginary parts), arrays of size given by the number of pixels of input geometry

Note

If curl modes are zero (deflection and/or alm’s to lens), they can be omitted, which can result in slightly faster transforms

lenspyx.lensing.synfast(cls: dict, lmax=None, mmax=None, geometry=('healpix', {'nside': 2048}), epsilon=1e-07, nthreads=0, alm=False, seed=None, verbose=0)[source]

Generate a set of lensed maps from scratch according to input spectra

Parameters:
  • cls (dict) –

    dict of spectra and cross-spectra with keys of the form ‘TT’, ‘TE’, ‘EE’, etc. Recognized field keys are:

    ’T’ (or ‘t’): spin-0 intensity
    ’E’ (or ‘e’): E-polarization
    ’B’ (or ‘e’): B-polarization
    ’P’ (or ‘p’): lensing potential
    ’O’ (or ‘o’): lensing curl potential

    The arrays must be the \(C_\ell\), not \(D_\ell\)

    If the auto-spectrum ‘AA’ is not present the ‘A’ field is assumed to be zero. If neither ‘P’ and ‘O’ are present then the output maps are not lensed.

  • lmax (int, optional) – band-limit of the unlensed alms, infered from length of cls by default

  • mmax (int, optional) – maximum m of the unlensed alms, defaults to lmax

  • geometry (tuple, optional) – tuple of geometry name and parameters (defaults to healpix at nside 2048)

  • epsilon (float, optional) – desired accuracy of the output map (exec. time only has a weak dependence on this)

  • nthreads (int, optional) – number of threads used for non-uniform SHTs, defaults to os.cpu_count

  • alm (bool, optional) – returns also unlensed alms if True

  • seed (int, optional) – random generator seed for reproducible results, defaults to None

  • verbose (bool, optional) – some timing info if set, defaults to zero

Returns:

Dictionary with lensed maps, which contains ‘T’ if ‘TT’ were present in the input cls and non-zero,

and ‘QU if ‘EE’ or ‘BB’ were present and non-zero.

if alm is set to True, returns the unlensed alms, together with a string indicating the ordering