LAT_MFLike – LAT MultiFrequency Likelihood#

Synopsis:

Definition of likelihood for Simons Observatory

Authors:

Simons Observatory Collaboration PS Group

MFLike is a multi frequency likelihood code that can be interfaced with the Cobaya sampler and a theory Boltzmann code such as CAMB, CLASS or Cosmopower.

The MFLike likelihood class reads the data file (in sacc format) and all the settings for the MCMC run (such as file paths, \(\ell\) ranges, experiments and frequencies to be used, parameters priors…) from the MFLike.yaml file.

The theory \(C_{\ell}\) are then summed with the (possibly frequency integrated) foreground power spectra from the BandpowerForeground class, and modified by systematic effects and calibrations. The underlying foreground spectra are computed through fgspectra.

This class applies four kinds of systematic effects to the CMB + foreground power spectrum:
  • calibrations (global calG_all, per channel cal_exp, per field calT_exp, calE_exp)

  • polarization angles effect (alpha_exp)

  • beam chromaticity (i.e. integrating the foreground SEDs with frequency dependent beams)

  • systematic templates (e.g. T –> P leakage). In this case the dictionary systematics_template has to be filled with the correct path rootname:

    systematics_template:
      rootname: "test_template"
    

If left null, no systematic template is applied.

The values of the systematic parameters are set in the TTTEEE/TTTE/TT/EE/TE/etc.yaml files corresponding to the classes that inherit the _MFLike one. They have to be named as cal/calT/calE/alpha + _ + experiment_channel string (e.g. LAT_93/dr6_pa4_f150).

MFLike class content#

class mflike.mflike._MFLike(*args, **kwargs)[source]#

Bases: InstallableLikelihood

get_requirements() dict[source]#

Gets the foreground dictionary and theory \(D_{\ell}\) from the Boltzmann solver code used, for the \(\ell\) range up to the \(\ell_{max}\) specified in the yaml

Returns:

the dictionary of theory \(D_{\ell}\) and foregrounds

logp(**params_values) float[source]#

Computes and returns the log likelihood value. Takes as keyword arguments the parameter values. To get the derived parameters, pass a _derived keyword with an empty dictionary.

Alternatively you can just implement calculate() and save the log likelihood into state[‘logp’]; this may be more convenient if you also need to also calculate other quantities.

_loglike(cl: dict, fg_totals: list, params_values: dict) float[source]#

Computes the gaussian log-likelihood

Parameters:
  • cl – the dictionary of theory + foregrounds \(D_{\ell}\)

  • fg_totals – the dictionary of foreground arrays

  • params_values – the dictionary of all foreground + systematic parameters

Returns:

the exact loglikelihood \(\ln \mathcal{L}\)

loglike(cl: dict, fg_totals: list, **params_values) float[source]#

Computes the gaussian log-likelihood, callable independent of Cobaya.

Parameters:
  • cl – the dictionary of theory + foregrounds \(D_{\ell}\)

  • fg_totals – the dictionary of foreground arrays, can be obtained from BandpowerForeground

  • params_values – the dictionary of required foreground + systematic parameters

Returns:

the exact loglikelihood \(\ln \mathcal{L}\)

_prepare_data()[source]#

Reads the sacc data, extracts the data tracers, trims the spectra and covariance according to the \(\ell\) scales set in the input file, inverts the covariance, extracts bandpass info from the sacc file. It fills the list self.spec_meta (used throughout the code) of dictionaries with info about polarization, arrays combination, \(\ell\) range, bandpowers and \(D_{\ell}\) for each power spectrum required in the yaml.

_get_power_spectra(cl: dict, fg_totals: list, **params_values) ndarray[source]#

Gets the theory \(D_{\ell}\), adds foregrounds \(D_{\ell}\) and applies possible systematic effects through the get_modified_theory function from the BandpowerForeground class. The spectra get then binned like the data.

Parameters:
  • cl – the dictionary of theory \(D_{\ell}\)

  • fg_totals – the dictionary of foreground arrays

  • params_values_nocosmo – the dictionary of required foregrounds and systematics parameters

Returns:

the binned data vector

get_modified_theory(Dls: dict, fg_totals: list, **nuis_params) dict[source]#

Takes the theory \(D_{\ell}\), sums it to the total foreground power spectrum (possibly computed with bandpass shift and bandpass integration) computed by _get_foreground_model and applies calibration, polarization angles rotation and systematic templates.

Parameters:
  • Dls – CMB theory spectra

  • fg_totals – dictionary of foreground spectra

  • nuis_params – dictionary of nuisance and foregrounds parameters

Returns:

the CMB+foregrounds \(D_{\ell}\) dictionary, modulated by systematics

_get_gauss_data()[source]#

Get Gaussian likelihood data for use with SoLiket :return: GaussianData instance

_get_theory(**params_values) ndarray[source]#

Get theory vector (e.g. for use with SoLiket)

Returns:

binned theory vector

_calibrate_spectra(dls_dict: dict, **nuis_params) None[source]#

Calibrates the spectra in place through calibration factors at the map level:

\[ \begin{align}\begin{aligned}D^{{\rm cal}, TT, \nu_1 \nu_2}_{\ell} &= \frac{1}{ {\rm cal}^2_{G}\, {\rm cal}^{\nu_1} \, {\rm cal}^{\nu_2}\, {\rm cal}^{\nu_1}_{\rm T}\, {\rm cal}^{\nu_2}_{\rm T}}\, D^{TT, \nu_1 \nu_2}_{\ell}\\D^{{\rm cal}, TE, \nu_1 \nu_2}_{\ell} &= \frac{1}{ {\rm cal}^2_{G}\,{\rm cal}^{\nu_1} \, {\rm cal}^{\nu_2}\, {\rm cal}^{\nu_1}_{\rm T}\, {\rm cal}^{\nu_2}_{\rm E}}\, D^{TT, \nu_1 \nu_2}_{\ell}\\D^{{\rm cal}, EE, \nu_1 \nu_2}_{\ell} &= \frac{1}{ {\rm cal}^2_{G}\,{\rm cal}^{\nu_1} \, {\rm cal}^{\nu_2}\, {\rm cal}^{\nu_1}_{\rm E}\, {\rm cal}^{\nu_2}_{\rm E}}\, D^{EE, \nu_1 \nu_2}_{\ell}\end{aligned}\end{align} \]
Parameters:
  • dls_dict – the CMB+foregrounds \(D_{\ell}\) dictionary, calibrated in place

  • **nuis_params – dictionary of nuisance parameters

_get_rotated_spectra(dls_dict: dict, **nuis_params) dict[source]#

Rotates the polarization spectra through polarization angles:

\[ \begin{align}\begin{aligned}D^{{\rm rot}, TE, \nu_1 \nu_2}_{\ell} &= \cos(\alpha^{\nu_2}) D^{TE, \nu_1 \nu_2}_{\ell}\\D^{{\rm rot}, EE, \nu_1 \nu_2}_{\ell} &= \cos(\alpha^{\nu_1}) \cos(\alpha^{\nu_2}) D^{EE, \nu_1 \nu_2}_{\ell}\end{aligned}\end{align} \]

It uses the syslibrary.syslib_mflike.Rotation_alm function.

Parameters:
  • dls_dict – the CMB+foregrounds \(D_{\ell}\) dictionary

  • **nuis_params – dictionary of nuisance parameters

Returns:

dictionary of rotated CMB+foregrounds \(D_{\ell}\)

_init_template_from_file() None[source]#

Reads the systematics template from file, using the syslibrary.syslib.ReadTemplateFromFile function.

_get_template_from_file(dls_dict: dict, **nuis_params) dict[source]#

Adds the systematics template, modulated by nuis_params['templ_freq'] parameters, to the \(D_{\ell}\).

Parameters:
  • dls_dict – the CMB+foregrounds \(D_{\ell}\) dictionary

  • **nuis_params – dictionary of nuisance parameters

Returns:

dictionary of CMB+foregrounds \(D_{\ell}\) with systematics templates