drift.core.psestimation

Estimate powerspectra and forecast constraints from real data.

Functions

bandfunc_2d_cart(kpar_s, kpar_e, kperp_s, ...)

bandfunc_2d_polar(ks, ke, ts, te)

decorrelate_ps(ps, fisher)

Decorrelate the powerspectrum estimate.

decorrelate_ps_file(fname)

Load and decorrelate the powerspectrum in fname.

range_config(lst)

uniform_band(k, kstart, kend)

Classes

PSEstimation(kltrans[, subdir])

Base class for quadratic powerspectrum estimation.

PSExact(kltrans[, subdir])

PS Estimation class with exact calculation of the Fisher matrix.

class drift.core.psestimation.PSEstimation(kltrans, subdir='ps')

Bases: Reader

Base class for quadratic powerspectrum estimation.

See Tegmark 1997 for details.

bandtype

Which types of bands to use (default: polar).

Type:

{‘polar’, ‘cartesian’}

k_bandsnp.ndarray

Array of band boundaries. e.g. np.array([0.0, 0.5, ]), polar only

num_theta: integer

Number of theta bands to use (polar only)

kpar_bandsnp.ndarray

Array of band boundaries. e.g. np.array([0.0, 0.5, ]), cartesian only

kperp_bandsnp.ndarray

Array of band boundaries. e.g. np.array([0.0, 0.5, ]), cartesian only

thresholdscalar

Threshold for including eigenmodes (default is 0.0, i.e. all modes)

unit_bandsboolean

If True, bands are sections of the exact powerspectrum (such that the fiducial bin amplitude is 1).

zero_meanboolean

If True (default), then the fiducial parameters have zero mean.

Initialise a PS estimator class.

Parameters:
  • kltrans (KLTransform) – The KL Transform filter to use.

  • subdir (string, optional) – Subdirectory of the KLTransform directory to store results in. Default is ‘ps’.

delbands()

Delete power spectrum bands to save memory.

fisher_bias_m(mi)

Generate the Fisher matrix and bias for a specific m.

Parameters:

mi (integer) – m-mode to calculate for.

fisher_file()

Fetch the h5py file handle for the Fisher matrix.

Returns:

file – File pointing at the hdf5 file with the Fisher matrix.

Return type:

h5py.File

genbands()

Precompute the powerspectrum bands, including the P(k, mu) bands and the angular powerspectrum.

generate(regen=False)

Calculate the total Fisher matrix and bias and save to a file.

Parameters:

regen (boolean, optional) – Force regeneration if products already exist (default False).

make_clzz(pk)

Make an angular powerspectrum from the input matter powerspectrum.

Uses the lmax and frequencies from the telescope object.

Parameters:

pk (function, np.ndarray -> np.ndarray) – The input powerspectrum (must be vectorized).

Returns:

aps – The angular powerspectrum.

Return type:

np.ndarray[lmax+1, nfreq, nfreq]

property nbands

Number of powerspectrum bands.

num_evals(mi)

Number of eigenvalues for this m (and threshold).

Parameters:

mi (integer) – m-mode index.

Returns:

num_evals

Return type:

integer

q_estimator(mi, vec1, vec2=None, noise=False)

Estimate the q-parameters from given data (see paper).

Parameters:
  • mi (integer) – The m-mode we are calculating for.

  • vec (np.ndarray[num_kl, num_realisatons]) – The vector(s) of data we are estimating from. These are KL-mode coefficients.

  • noise (boolean, optional) – Whether we should project against the noise matrix. Used for estimating the bias by Monte-Carlo. Default is False.

Returns:

qa – Array of q-parameters. If noise=True then the array is one longer, and the last parameter is the projection against the noise.

Return type:

np.ndarray[numbands]

class drift.core.psestimation.PSExact(kltrans, subdir='ps')

Bases: PSEstimation

PS Estimation class with exact calculation of the Fisher matrix.

Initialise a PS estimator class.

Parameters:
  • kltrans (KLTransform) – The KL Transform filter to use.

  • subdir (string, optional) – Subdirectory of the KLTransform directory to store results in. Default is ‘ps’.

cacheproj(mi)

Cache projected covariances on disk.

Parameters:

mi (integer) – m-mode.

delproj(mi)

Deleted cached covariances from disk.

Parameters:

mi (integer) – m-mode.

getproj(mi, bi)

Fetch cached KL-covariance (either from disk or just calculate if small enough).

Parameters:
  • mi (integer) – m-mode.

  • bi (integer) – band index.

Returns:

klcov – Covariance in KL-basis.

Return type:

np.ndarray[nevals, nevals]

makeproj(mi, bi)

Project angular powerspectrum band into KL-basis.

Parameters:
  • mi (integer) – m-mode.

  • bi (integer) – band index.

Returns:

klcov – Covariance in KL-basis.

Return type:

np.ndarray[nevals, nevals]

drift.core.psestimation.decorrelate_ps(ps, fisher)

Decorrelate the powerspectrum estimate.

Parameters:
  • ps (np.ndarray[nbands]) – Powerspectrum estimate.

  • fisher (np.ndarrays[nbands, nbands]) – Fisher matrix.

Returns:

  • psd (np.narray[nbands]) – Decorrelated powerspectrum estimate.

  • errors (np.ndarray[nbands]) – Errors on decorrelated bands.

  • window (np.ndarray[nbands, nbands]) – Window functions for each band row-wise.

drift.core.psestimation.decorrelate_ps_file(fname)

Load and decorrelate the powerspectrum in fname.

Parameters:

fname (string) – Name of file to load.

Returns:

  • psd (np.narray[nbands]) – Decorrelated powerspectrum estimate.

  • errors (np.ndarray[nbands]) – Errors on decorrelated bands.

  • window (np.ndarray[nbands, nbands]) – Window functions for each band row-wise.