pspec_likelihood.likelihood.DataModelInterface#

class pspec_likelihood.likelihood.DataModelInterface(*, redshift, power_spectrum: ~astropy.units.quantity.Quantity, window_function, covariance: ~astropy.units.quantity.Quantity, theory_model: ~typing.Callable, sys_model: ~typing.Callable | None = None, cosmology: ~astropy.cosmology.flrw.base.FLRW = FlatLambdaCDM(name="Planck18", H0=67.66 km / (Mpc s), Om0=0.30966, Tcmb0=2.7255 K, Neff=3.046, m_nu=[0.   0.   0.06] eV, Ob0=0.04897), kpar_bins_obs: ~astropy.units.quantity.Quantity, kperp_bins_obs: ~astropy.units.quantity.Quantity | None = None, kpar_bins_theory: ~astropy.units.quantity.Quantity = _Nothing.NOTHING, kperp_bins_theory: ~astropy.units.quantity.Quantity | None = _Nothing.NOTHING, theory_uses_little_h=False, theory_uses_spherical_k=False, obs_use_spherical_k=False, theory_param_names=None, sys_param_names=None, apply_window_to_systematics=True)[source]#

Container for power spectrum measurements and models.

This class keeps track of power-spectrum measurements (and their associated covariances and window functions) along with a theoretical model and calculations of the likelihoods given this model that propertly account for the window functions. Note that window function matrix W must properly approximate performing the integral \(P_{obs}(b, tau) = \int \int d k_\perp d k_\parallel W(b, \tau, k_\perp, k_\parallel) P_{th}(k_\perp, k_\parallel)\), since the W matrix will directly multiply the theory at the given k samples. For now, this container assumes Gaussian measurement errors and thus only keeps track of covariances but this may change in the future.

Parameters:
  • cosmology (astropy.cosmology.flrw.base.FLRW) – The astropy.cosmology.FLRW object defining the cosmology.

  • redshift (float) – The (mean) redshift of the measured power spectrum.

  • power_spectrum (astropy.units.quantity.Quantity) – The 1D or 2D power spectrum values of the observation in squared temperature units. Whether 1D or 2D, this array is 1D (i.e. flattened).

  • window_function (numpy.ndarray) – The window function that takes theory space to observational space. Must be an array whose first dimension has length equal to the power spectrum, and the second dimension has the same length as kpar_bins_theory/kperp_bins_theory. The matrix W must properly approximate performing the integral \(P_{obs}(b, tau) = \int \int d k_\perp d k_\parallel W(b, \tau, k_\perp, k_\parallel) P_{th}(k_\perp, k_\parallel)\), since the W matrix will directly multiply the theory at the given k samples.

  • covariance (astropy.units.quantity.Quantity) – The data covariance matrix. If 2D, must be a square matrix with each dimension the same length as power_spectrum. If 1D, the covariance is assumed to be diagonal, and must have the same length as power_spectrum.

  • kpar_bins_obs (astropy.units.quantity.Quantity) – The k-parallel bins of the observation. See notes on kperp_bins_obs. If kperp_bins_obs is not provided, treat kpar_bins_obs as spherically averaged.

  • kperp_bins_obs (astropy.units.quantity.Quantity | None) – If provided, the k-perpendicular bins of the observation. These provide the bin centres, and so there should be the same number as power spectrum values. If not provided, kpar_bins_obs is treated as the spherically-averaged k bins.

  • kpar_bins_theory (astropy.units.quantity.Quantity) – The k-parallel bins of the theory. See notes on kperp_bins_theory. If kperp_bins_theory not provided, treat kpar_bins_theory as spherical.

  • kperp_bins_theory (astropy.units.quantity.Quantity | None) – If provided, the k-perpendicular bins of the theory. These provide the bin centres, and so there should be the same number as the second dimension of the window function. If not provided, kpar_bins_theory is treated as the spherically-averaged k bins.

  • theory_uses_little_h (bool) – Whether the theory function accepts wavenumbers in units of h/Mpc. If False, it accepts wavenumbers in units of 1/Mpc.

  • theory_uses_spherical_k (bool) – If True, the theory function only accepts spherical k, rather than cylindrical k.

  • theory_model (Callable) – The callable theoretical power spectrum as a function of redshift and k. The signature of the function should be theory(z, k, params) -> p, where z is a float redshift,and params is a tuple of float parameters OR a dict of float parameters. If it takes a dict of parameters, theory_param_names must be given. k is either a 2-tuple (kperp, kpar), where each of these arrays is 1D and the same length, or, if theory_uses_spherical_k is True, a single array of |k|. The output p is an array of the same length as kperp and kpar (or simply k), containing the power spectrum in mK^2.

  • sys_model (Callable | None) – The callable systematics power spectrum, see theory_model for details.

  • theory_param_names (Sequence[str] | None) – If given, pass a dictionary of parameters to the theory_model whose keys are the names.

  • apply_window_to_systematics (bool) – Whether the systematics are defined in theory-space or data-space. If defined in theory-space, the window function must be applied to the resulting systematics.

Methods

__init__(*, redshift, power_spectrum, ...[, ...])

Method generated by attrs for class DataModelInterface.

apply_window_function(discretized_model)

Calculate theoretical power spectrum with data window function applied.

compute_model(theory_params, sys_params)

Compute the theory+systematics model in the data-space.

discretize_systematics(z, sys_params)

Compute the discretized systematic power.

discretize_theory(z, theory_params)

Compute the discretized power spectrum at the (k, z) of the window function.

from_uvpspec(uvp[, spw, polpair_index, ...])

Extract parameters from UVPSpec object.

Attributes

kperp_centres

Centres of the kperp bins.

nk_obs

Define attribute describing size of obs dataset.

nk_theory

Define attribute describing size of theory dataset.

spherical_kbins_obs

The spherical k bins of the observation (the edges).

spherical_kbins_theory

The spherical k bins of the theory (edges).

redshift

power_spectrum

window_function

covariance

theory_model

sys_model

cosmology

kpar_bins_obs

kperp_bins_obs

kpar_bins_theory

kperp_bins_theory

theory_uses_little_h

theory_uses_spherical_k

obs_use_spherical_k

theory_param_names

sys_param_names

apply_window_to_systematics