pspec_likelihood.likelihood.DataModelInterface#
- class pspec_likelihood.likelihood.DataModelInterface(*, redshift, power_spectrum: tp.PowerType, window_function, covariance: tp.CovarianceType, theory_model: Callable, sys_model: Callable | None = None, cosmology: csm.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: tp.Wavenumber, kperp_bins_obs: tp.Wavenumber | None = None, kpar_bins_theory: tp.Wavenumber = _Nothing.NOTHING, kperp_bins_theory: tp.Wavenumber | None = _Nothing.NOTHING, kperp_widths_theory: tp.Wavenumber | None = None, kpar_widths_theory: tp.Wavenumber | None = None, window_integration_rule: Literal['midpoint', 'trapz', 'quad'] = 'midpoint', theory_uses_little_h=False, theory_uses_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. For now, this container assumes Gaussian measurement errors and thus only keeps track of covariances but this may change in the future.
- Parameters
cosmology (csm.FLRW) – The
astropy.cosmology.FLRWobject defining the cosmology.redshift (float) – The (mean) redshift of the measured power spectrum.
power_spectrum (tp.PowerType) – 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 (np.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.covariance (tp.CovarianceType) – 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 aspower_spectrum.kpar_bins_obs (tp.Wavenumber) – The k-parallel bins of the observation. See notes on
kperp_bins_obs. Ifkperp_bins_obsis not provided, treatkpar_bins_obsas spherically averaged.kperp_bins_obs (tp.Wavenumber | 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_obsis treated as the spherically-averaged k bins.kpar_bins_theory (tp.Wavenumber) – The k-parallel bins of the theory. See notes on
kperp_bins_theory. Ifkperp_bins_theorynot provided, treatkpar_bins_theoryas spherical.kperp_bins_theory (tp.Wavenumber | 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_theoryis treated as the spherically-averaged k bins.kperp_widths_theory (tp.Wavenumber | None) – If provided, the k-perpendicular bin widths associated with each bin. It is assumed that the bins are in the (linear-space) centre. Only required if
window_integration_ruleis not"midpoint".kpar_widths_theory (tp.Wavenumber | None) – If provided, the k-parallel bin widths associated with each bin. It is assumed that the bins are in the (linear-space) centre. Only required if
window_integration_ruleis not"midpoint".window_integration_rule (Literal['midpoint', 'trapz', 'quad']) – Converting from theory space to observational space is done by integrating the
window_function * theory_functionover k-space for a given choice of observational co-ordinates. This integral is discretized, and this parameter provides the rule by which the theory function portion of the integral is discretized. Choices are ‘midpoint’, ‘trapz’ or ‘quad’.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_namesmust be given.kis either a 2-tuple(kperp, kpar), where each of these arrays is 1D and the same length, or, iftheory_uses_spherical_kis True, a single array of|k|. The outputpis an array of the same length askperpandkpar(or simplyk), containing the power spectrum in mK^2.sys_model (Callable | None) – The callable systematics power spectrum, see
theory_modelfor details.theory_param_names (Sequence[str] | None) – If given, pass a dictionary of parameters to the
theory_modelwhose 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
Centres of the kperp bins.
The spherical k bins of the observation (the edges).
The spherical k bins of the theory (edges).
The spherical k bins of the theory (edges).