Lensing

Generates weak lensing maps in the Born approximation with tomographic support.

Convergence and shear maps from the shells, in the Born approximation.

For tomographic redshift distributions (BornLensingBuilder), or one source plane per shell (SnapshotBornLensingBuilder).

class pollux.lensing.LensingBuilder(shell_builder, nzs, tag=None, dtype=<class 'numpy.float32'>, **kwargs)[source]

Bases: MapBuilder

Base class to build convergence and shear maps from matter shells.

Parameters:
  • shell_builder (pollux.shells.ShellBuilder) – Shell builder providing matter shells and geometry.

  • nzs ({'snapshots'} or sequence) – If ‘snapshots’, produce one convergence map per shell edge (CMB-like). Otherwise, a list describing source n(z) per tomographic bin. Each entry can be a callable nz(z) or a tuple (z, n(z)).

  • tag (str or None, optional) – Name of the n(z): maps go to the 'kappa' product of the shell builder’s files with nz=tag (kappa/{tag}/, see pollux.io.files.PolluxIO), kappa/default/ when None.

  • dtype (data-type, optional) – Output dtype for kappa and shear maps.

  • **kwargs – Forwarded to pollux.map_builder.MapBuilder. The footprint is that of shell_builder, and monopole removal and the format of the maps (map_format) default to its own.

config()[source]

Return the configuration of the products, for their config.yaml (pollux.io.config.write_config()).

Returns:

product ('kappa'), parameters (builder, and n(z): 'snapshots', or their number and a hash of their values) and inputs (the shells).

Return type:

dict

compute_shear_maps(ikappas=None, smooth_Mpc=None, save_field_map=True)[source]

Compute shear (gamma1, gamma2) maps from the a_lm of convergence maps (saved by compute_alms()).

Parameters:
  • ikappas (int or array_like of int or None, optional) – Convergence map indices to process. If None, process all.

  • smooth_Mpc (float or None, optional) – Comoving Gaussian smoothing scale in Mpc of the convergence a_lm before deriving shear (angular width at the source plane, see _smooth_sigma(); only for per-shell maps, nzs='snapshots'). Shear maps are saved with the suffix _{smooth_Mpc}Mpc.

  • save_field_map (bool, optional) – With smooth_Mpc, also save the smoothed convergence map, from the same a_lm (as compute_maps_from_alms()). Default is True.

Returns:

  • If ikappas is a single int: returns a list [gamma1_map, gamma2_map], as written (map_format).

  • If ikappas is None or an iterable: returns a dict keyed by kappa index with list values [gamma1_map, gamma2_map]. Also writes maps to disk.

Return type:

list or dict

matter_power_spectrum()[source]

Return the matter power spectrum of the shell builder, for the predictions.

Returns:

That of the shell builder (pollux.statistics.maps.MapStatistics.matter_power_spectrum(), with baryons for pollux.baryons.BaryonifiedShellBuilder), None for the cosmology’s own.

Return type:

pyccl.Pk2D or None

class pollux.lensing.BornLensingBuilder(shell_builder, nzs, tag=None, dtype=<class 'numpy.float32'>, multiple_planes=False, nbar_from_maps=False, **kwargs)[source]

Bases: LensingBuilder

Convergence-map builder in the Born approximation.

Parameters:
  • shell_builder (ShellBuilder) – See LensingBuilder.

  • nzs (str | list) – See LensingBuilder.

  • tag (str | None) – See LensingBuilder.

  • dtype (np.dtype) – See LensingBuilder.

  • multiple_planes (bool, optional) – If True, compute weights using a multiple-lens-planes approximation. If False, use Limber-style integrals of tracer kernels per shell.

  • nbar_from_maps (bool, optional) – If True, estimate the mean density from the shell maps themselves. This can affect large-scale modes.

  • **kwargs – Forwarded to LensingBuilder.

config()[source]

Return the configuration of the products (LensingBuilder.config()), with the options of the builder.

Options at their defaults are left out, so that the configurations of products made before they were recorded stay valid.

Returns:

That of LensingBuilder.config(), with multiple_planes and nbar_from_maps in its parameters if True.

Return type:

dict

construct_maps(imaps=None)[source]

Construct and save convergence maps by summing weighted shells.

Parameters:

imaps (int or array_like of int or None, optional) – Indices of convergence maps to build. If None, build all.

Returns:

The maps as written (map_format): a single map if imaps is an int, else a dict keyed by map index. The shells are summed as stored (MapSum).

Return type:

ndarray or hsp.HealSparseMap, or dict

compute_weight(ishell, ikappa)[source]

Compute the shell weight contributing to a given convergence map.

Parameters:
  • ishell (int) – Shell index.

  • ikappa (int) – Convergence map index.

Returns:

Scalar weight applied to the shell density/contrast when summing into the convergence map.

Return type:

float

Notes

The convergence of map \(j\) sums the shells \(i\) with weights \(w_{ij}\). By default (Born approximation, integrating the lensing kernel \(q_j\) of CCL over each shell),

\[\kappa_j = \sum_i w_{ij}\, \delta_i, \qquad w_{ij} = \int_{\chi_i}^{\chi_{i+1}} q_j(\chi)\, d\chi, \qquad q_j(\chi) = \frac{3}{2} \Omega_m H_0^2 \frac{\chi}{a(\chi)} \int_\chi^\infty d\chi'\, n_j(\chi') \frac{\chi' - \chi}{\chi'},\]

with \(\delta_i = N_i / \bar N_i - 1\) the density contrast of the particle counts \(N_i\) per pixel (\(\bar N_i\) expected from the simulation, or the mean of the map with nbar_from_maps). With multiple_planes, each shell is a lens plane at its volume-weighted mean redshift \(z_i\), of surface density \(m_p (N_i - \bar N_i) / (\Omega_{\rm pix} D_A(z_i)^2)\), with \(m_p\) the mass of a particle and \(\Omega_{\rm pix}\) the pixel area:

\[\kappa_j = \sum_i w_{ij} (N_i - \bar N_i), \qquad w_{ij} = \frac{m_p}{\Omega_{\rm pix} D_A(z_i)^2} \frac{\int_{z_i}^{z_{\max}} n_j(z_s)\, \Sigma_{\rm crit}^{-1}(z_i, z_s)\, dz_s}{\int_0^{z_{\max}} n_j(z_s)\, dz_s},\]

or \(w_{ij} = m_p / (\Omega_{\rm pix} D_A(z_i)^2 \Sigma_{\rm crit}(z_i, z_s))\) for a single source plane at \(z_s > z_i\) (zero otherwise).

class pollux.lensing.SnapshotBornLensingBuilder(shell_builder, tag='snapshots', **kwargs)[source]

Bases: BornLensingBuilder

Born-approximation lensing builder with one convergence map per shell snapshot.

Each map uses a CMB-like lensing kernel sourced at the redshift edge of its shell, equivalent to BornLensingBuilder(..., nzs='snapshots'). Prefer constructing via pollux.shells.ShellBuilder.snapshot_lensing_builder().

Parameters:
  • shell_builder (pollux.shells.ShellBuilder) – Shell builder providing matter shells and geometry.

  • tag (str or None, optional) – Name of the output subdirectory, kappa/{tag} (default kappa/snapshots).

  • **kwargs – Forwarded to BornLensingBuilder (e.g. multiple_planes).