pymaster.bins module

class pymaster.bins.NmtBin(*, bpws, ells, lmax=None, weights=None, f_ell=None)[source]

Bases: object

NmtBin objects define the set of bandpowers used in the computation of the pseudo-\(C_\ell\) estimator. The definition of bandpowers is described in Section 2.1.3 of the NaMaster paper, and Section 3.6 of the scientific documentation. We provide several convenience constructors that cover a range of common use cases requiring fewer parameters (see NmtBin.from_nside_linear(), NmtBin.from_lmax_linear() and NmtBin.from_edges()).

Parameters:
  • ells (array) – Array of integers corresponding to different multipoles.

  • bpws (array) – Array of integers that assign the multipoles in ells to different bandpowers. All negative values will be ignored.

  • lmax (int) – Maximum \(\ell\) to be considered by these bandpowers, and by any calculation that uses them (e.g. mode-coupling matrices, band limit used when computing spherical harmonic coefficients of input maps, etc.). If None, the maximum of ells will be used.

  • weights (array) – Array of floats corresponding to the weights associated to each multipole in ells. The sum of weights within each bandpower will be automatically normalized to 1. If None, uniform weights are assumed.

  • f_ell (array) – If present, this is array represents an \(\ell\)-dependent function that will be multiplied by all pseudo-\(C_\ell\) computations carried out using this bandpower scheme.

classmethod from_nside_linear(nside, nlb, is_Dell=False, f_ell=None)[source]

Convenience constructor for HEALPix maps with linear binning, starting at \(\ell=2\), and up to \(\ell=3 N_{\rm side}-1\). Although this will also be the maximum multipole associated with this NmtBin object, only bandpowers containing a total of nlb multipoles within this range will be used (i.e. the last bin will be discarded if not complete).

Parameters:
  • nside (int) – HEALPix \(N_{\rm side}\) resolution parameter of the maps you intend to correlate.

  • nlb (int) – Integer value corresponding to a constant bandpower width. I.e. the bandpowers will be defined as consecutive sets of nlb multipoles from \(\ell=2\) with equal weights.

  • is_Dell (bool) – If True, the output of all pseudo-\(C_\ell\) computations carried out using this bandpower scheme (e.g. from decouple_cell()) will be multiplied by \(\ell (\ell + 1) / 2 \pi\) (no prefactor otherwise).

  • f_ell (array) – If present, this is array represents an \(\ell\)-dependent function that will be multiplied by all pseudo-\(C_\ell\) computations carried out using this bandpower scheme. If not None, the value of is_Dell is ignored. If provided, it must be sampled at all \(\ell\) s up to (and including) \(3 N_{\rm side}-1\).

classmethod from_lmax_linear(lmax, nlb, is_Dell=False, f_ell=None)[source]

Convenience constructor for generic linear binning, starting at \(\ell=2\), and up to \(\ell=\) lmax. Although this will also be the maximum multipole associated with this NmtBin object, only bandpowers containing a total of nlb multipoles within this range will be used (i.e. the last bin will be discarded if not complete).

Parameters:
  • lmax (int) – Integer value corresponding to the maximum multipole to be used.

  • nlb (int) – Integer value corresponding to a constant bandpower width. I.e. the bandpowers will be defined as consecutive sets of nlb multipoles from \(\ell=2\) with equal weights.

  • is_Dell (bool) – If True, the output of all pseudo-\(C_\ell\) computations carried out using this bandpower scheme (e.g. from decouple_cell()) will be multiplied by \(\ell (\ell + 1) / 2 \pi\) (no prefactor otherwise).

  • f_ell (array) – If present, this is array represents an \(\ell\)-dependent function that will be multiplied by all pseudo-\(C_\ell\) computations carried out using this bandpower scheme. If not None, the value of is_Dell is ignored. If provided, it must be sampled at all \(\ell\) s up to (and including) \(\ell_{\rm max}\).

classmethod from_edges(ell_ini, ell_end, is_Dell=False, f_ell=None)[source]

Convenience constructor for general equal-weight bands. All \(\ell\) s in the interval [ell_ini, ell_end) will be binned with equal weights across the band.

Parameters:
  • ell_ini (array) – Array of integers containing the lower edges of each bandpower.

  • ell_end (array) – Array containing the upper edges of each bandpower.

  • is_Dell (bool) – If True, the output of all pseudo-\(C_\ell\) computations carried out using this bandpower scheme (e.g. from decouple_cell()) will be multiplied by \(\ell (\ell + 1) / 2 \pi\) (no prefactor otherwise).

  • f_ell (array) – If present, this is array represents an \(\ell\)-dependent function that will be multiplied by all pseudo-\(C_\ell\) computations carried out using this bandpower scheme. If not None, the value of is_Dell is ignored. If provided, it must be sampled at all \(\ell\) s covered by ell_ini and ell_end.

get_n_bands()[source]

Returns the number of bandpowers stored in this object.

Returns:

Number of bandpowers.

Return type:

(int)

get_nell_list()[source]

Returns an array with the number of multipoles in each bandpower stored in this object.

Returns:

Number of multipoles per bandpower.

Return type:

(array)

get_ell_min(b)[source]

Returns the minimum ell value used by bandpower with index b.

Parameters:

b (int) – Bandpower index.

Returns:

Minimum \(\ell\) value.

Return type:

(int)

get_ell_max(b)[source]

Returns the maximum ell value used by bandpower with index b.

Parameters:

b (int) – Bandpower index.

Returns:

Maximum \(\ell\) value.

Return type:

(int)

get_ell_list(b)[source]

Returns an array with the multipoles in the b-th bandpower

Parameters:

b (int) – Bandpower index.

Returns:

Array of multipoles associated with bandpower b.

Return type:

(array)

get_weight_list(b)[source]

Returns an array with the weights associated with each multipole in the b-th bandpower

Parameters:

b (int) – Bandpower index.

Returns:

Weights associated to multipoles in bandpower b.

Return type:

(array)

get_effective_ells()[source]

Returns an array with the effective multipole of each bandpower. These are computed as a weighted average of the multipoles within each bin.

Returns:

Effective multipoles for each bandpower.

Return type:

(array)

bin_cell(cls_in)[source]

Bins a power spectrum into bandpowers. This is carried out as a weighted average over the multipoles in each bandpower.

Parameters:

cls_in (array) – 1 or 2-D array of power spectra.

Returns:

Array of bandpowers.

Return type:

(array)

unbin_cell(cls_in)[source]

Un-bins a set of bandpowers into a power spectrum. This is simply done by assigning a constant value for every multipole in each bandpower.

Parameters:

cls_in (array) – 1 or 2-D array of bandpowers.

Returns:

Array of power spectra.

Return type:

(array)

class pymaster.bins.NmtBinFlat(l0, lf)[source]

Bases: object

An NmtBinFlat object defines the set of bandpowers used in the computation of the pseudo-\(C_\ell\) estimator. The definition of bandpowers is described in Section 2.5.1 of the NaMaster paper, or Section 3.6 of the scientific documentation. Note that NaMaster only supports top-hat bandpowers for flat-sky power spectra.

Parameters:
  • l0 (array) – Array of floats corresponding to the lower bound of each bandpower.

  • lf (array) – Array of floats corresponding to the upper bound of each bandpower. lf should have the same shape as l0.

get_n_bands()[source]

Returns the number of bandpowers stored in this object

Returns:

Number of bandpowers.

Return type:

(int)

get_effective_ells()[source]

Returns an array with the effective multipole associated with each bandpower. These are computed as a weighted average of the multipoles within each bin.

Returns:

Effective multipoles for each bandpower.

Return type:

(array)

bin_cell(ells, cls_in)[source]

Bins a power spectrum into bandpowers. This is carried out as a weighted average over the multipoles in each bin.

Parameters:
  • ells (array) – Multipole values at which the input power spectra are sampled.

  • cls_in (array) – 1 or 2-D array of input power spectra.

Returns:

Array of bandpowers.

Return type:

(array)

unbin_cell(cls_in, ells)[source]

Un-bins a set of bandpowers into power spectra. This is simply done by assigning a constant value for every multipole in each bandpower.

Parameters:
  • cls_in (array) – 1 or 2-D array of bandpowers.

  • ells (array) – Array of multipoles at which the input power spectra are evaluated.

Returns:

Array of power spectra.

Return type:

(array)