transformcl — Transform angular power spectra

This is a minimal Python package for transformations between angular power spectra and correlation functions. It is currently limited to the spin zero case.

The package can be installed using pip:

pip install transformcl

Then import the package to use the functions:

import transformcl
t = transformcl.theta(cl.size)
ct = transformcl.corr(cl)

Current functionality covers the absolutely minimal use case. Please open an issue on GitHub if you would like to see anything added.

Reference

transformcl.corr(cl, closed=False)

Transform angular power spectrum to angular correlation function.

Takes an angular power spectrum with \(\mathtt{n} = \mathtt{lmax}+1\) coefficients and returns the corresponding angular correlation function in \(\mathtt{n}\) points.

The correlation function values can be computed either over the closed interval \([0, \pi]\), in which case \(\theta_0 = 0\) and \(\theta_{n-1} = \pi\), or over the open interval \((0, \pi)\).

Parameters:
cl(n,) array_like

Angular power spectrum from \(0\) to \(\mathtt{lmax}\).

closedbool

Compute correlation function over open (closed=False) or closed (closed=True) interval.

Returns:
corr(n,) array_like

Angular correlation function.

See also

transformcl.cl

the inverse operation

transformcl.theta

angles at which the correlation function is evaluated

transformcl.cl(corr, closed=False)

Transform angular correlation function to angular power spectrum.

Takes an angular function in \(\mathtt{n}\) points and returns the corresponding angular power spectrum from \(0\) to \(\mathtt{lmax} = \mathtt{n}-1\).

The correlation function must be given at the angles returned by transformcl.theta(). These can be distributed either over the closed interval \([0, \pi]\), in which case \(\theta_0 = 0\) and \(\theta_{n-1} = \pi\), or over the open interval \((0, \pi)\).

Parameters:
corr(n,) array_like

Angular correlation function.

Returns:
cl(n,) array_like

Angular power spectrum from \(0\) to \(\mathtt{lmax}\).

closedbool

Compute correlation function over open (closed=False) or closed (closed=True) interval.

See also

transformcl.corr

the inverse operation

transformcl.theta

angles at which the correlation function is evaluated

transformcl.var(cl)

Compute variance from angular power spectrum.

Given the angular power spectrum, compute the variance of the spherical random field in a point.

Parameters:
clarray_like

Angular power spectrum. Can be multidimensional, with the last axis representing the modes.

Returns:
var: float

The variance of the given power spectrum.

Notes

The variance \(\sigma^2\) of the field with power spectrum \(C_l\) is

\[\sigma^2 = \sum_{l} \frac{2l + 1}{4\pi} \, C_l \;.\]
transformcl.theta(n, closed=False)

Return the angles \(\theta_1, \ldots, \theta_n\) of the correlation function with n points.