Random fields (glass.fields)

The glass.fields module provides functionality for simulating random fields on the sphere. This is done in the form of HEALPix maps.

Functions

glass.fields.gaussian_gls(cls, *, lmax=None, ncorr=None, nside=None)

Compute Gaussian Cls for a Gaussian random field.

Depending on the given arguments, this truncates the angular power spectra to lmax, removes all but ncorr correlations between fields, and applies the HEALPix pixel window function of the given nside. If no arguments are given, no action is performed.

glass.fields.lognormal_gls(cls, shift=1.0, *, lmax=None, ncorr=None, nside=None)

Compute Gaussian Cls for a lognormal random field.

glass.fields.generate_gaussian(gls, nside, *, ncorr=None, rng=None)

Iteratively sample Gaussian random fields from Cls.

A generator that iteratively samples HEALPix maps of Gaussian random fields with the given angular power spectra gls and resolution parameter nside.

The optional argument ncorr can be used to artificially limit now many realised fields are correlated. This saves memory, as only ncorr previous fields need to be kept.

The gls array must contain the auto-correlation of each new field followed by the cross-correlations with all previous fields in reverse order:

gls = [gl_00,
       gl_11, gl_10,
       gl_22, gl_21, gl_20,
       ...]

Missing entries can be set to None.

glass.fields.generate_lognormal(gls, nside, shift=1.0, *, ncorr=None, rng=None)

Iterative sample lognormal random fields from Gaussian Cls.

glass.fields.effective_cls(cls, weights1, weights2=None, *, lmax=None)

Compute effective angular power spectra from weights.

Computes a linear combination of the angular power spectra cls using the factors provided by weights1 and weights2. Additional axes in weights1 and weights2 produce arrays of spectra.

Parameters:
cls(N,) list of array_like

Angular matter power spectra to combine, in GLASS ordering.

weights1(N, *M1) array_like

Weight factors for spectra. The first axis must be equal to the number of fields.

weights2(N, *M2) array_like, optional

Second set of weights. If not given, weights1 is used.

lmaxint, optional

Truncate the angular power spectra at this mode number. If not given, the longest input in cls will be used.

Returns:
cls(*M1, *M2, LMAX+1) array_like

Dictionary of effective angular power spectra, where keys correspond to the leading axes of weights1 and weights2.

Utility functions

glass.fields.getcl(cls, i, j, lmax=None)

Return a specific angular power spectrum from an array.

Return the angular power spectrum for indices i and j from an array in GLASS ordering.

Parameters:
clslist of array_like

List of angular power spectra in GLASS ordering.

i, jint

Combination of indices to return.

lmaxint, optional

Truncate the returned spectrum at this mode number.

Returns:
clarray_like

The angular power spectrum for indices i and j.