Shells (glass.shells)#

The glass.shells module provides functions for the definition of matter shells, i.e. the radial discretisation of the light cone.

Window functions#

class glass.shells.RadialWindow(za, wa, zeff)#

A radial window, defined by a window function.

The radial window is defined by a window function in redshift, which is given by a pair of arrays za, wa.

The radial window also has an effective redshift, stored in the zeff attribute, which should be a representative redshift for the window function.

To prevent accidental inconsistencies, instances of this type are immutable (however, the array entries may not be immutable; do not change them in place):

>>> from glass.shells import RadialWindow
>>> w1 = RadialWindow(..., ..., zeff=0.1)
>>> w1.zeff = 0.15
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: can't set attribute

To create a new instance with a changed attribute value, use the ._replace method:

>>> w1 = w1._replace(zeff=0.15)
>>> w1
RadialWindow(za=..., wa=..., zeff=0.15)
Attributes:
za(N,) array_like

Redshift array; the abscissae of the window function.

wa(N,) array_like

Weight array; the values (ordinates) of the window function.

zefffloat

Effective redshift of the window.

Methods

_replace(**kwds)

Return a new RadialWindow object replacing specified fields with new values

glass.shells.tophat_windows(zbins, dz=0.001, weight=None)#

Tophat window functions from the given redshift bin edges.

Uses the N+1 given redshifts as bin edges to construct N tophat window functions. The redshifts of the windows have linear spacing approximately equal to dz.

An optional weight function \(w(z)\) can be given using weight; it is applied to the tophat windows.

The resulting windows functions are RadialWindow instances. Their effective redshifts are the mean redshifts of the (weighted) tophat bins.

Parameters:
zbins(N+1,) array_like

Redshift bin edges for the tophat window functions.

dzfloat, optional

Approximate spacing of the redshift grid.

weightcallable, optional

If given, a weight function to be applied to the window functions.

Returns:
ws(N,) list of RadialWindow

List of window functions.

Window function tools#

glass.shells.restrict(z, f, w)#

Restrict a function to a redshift window.

Multiply the function \(f(z)\) by a window function \(w(z)\) to produce \(w(z) f(z)\) over the support of \(w\).

The function \(f(z)\) is given by redshifts z of shape (N,) and function values f of shape (…, N), with any number of leading axes allowed.

The window function \(w(z)\) is given by w, which must be a RadialWindow instance or compatible with it.

The restriction has redshifts that are the union of the redshifts of the function and window over the support of the window. Intermediate function values are found by linear interpolation

Parameters:
z, farray_like

The function to be restricted.

wRadialWindow

The window function for the restriction.

Returns:
zr, frarray

The restricted function.

glass.shells.partition(z, f, ws)#

Partition a function by a sequence of windows.

Partitions the given function into a sequence of functions restricted to each window function.

The function \(f(z)\) is given by redshifts z of shape (N,) and function values f of shape (…, N), with any number of leading axes allowed.

The window functions are given by the sequence ws of RadialWindow or compatible entries.

The partitioned functions have redshifts that are the union of the redshifts of the original function and each window over the support of said window. Intermediate function values are found by linear interpolation

Parameters:
z, farray_like

The function to be partitioned.

wssequence of RadialWindow

Ordered sequence of window functions for the partition.

Returns:
zp, fplist of array

The partitioned functions, ordered as the given windows.

Redshift grids#

glass.shells.redshift_grid(zmin, zmax, *, dz=None, num=None)#

Redshift grid with uniform spacing in redshift.

glass.shells.distance_grid(cosmo, zmin, zmax, *, dx=None, num=None)#

Redshift grid with uniform spacing in comoving distance.

Weight functions#

glass.shells.distance_weight(z, cosmo)#

Uniform weight in comoving distance.

glass.shells.volume_weight(z, cosmo)#

Uniform weight in comoving volume.

glass.shells.density_weight(z, cosmo)#

Uniform weight in matter density.