Author: Giacomo Galloni
In this repository I provide some basic examples of forecasting likelihoods for LiteBIRD. These are implemented to be used a Cobaya context (J. Torrado and A. Lewis, 2020), which encapsulates CosmoMC in a Python framework. The idea of this repository is to ease the creation of common framework among different LiteBIRDers, trying to homogenize the post-PTEP works as we recently discussed among the collaboration. The main product of this repository is the Likelihood for LiteBIRD (LiLit), which you can find here. Within LiLit, the most relevant study cases of LiteBIRD (T, E, B) are already tested and working. So, if you need to work with those, you should not need to look into the actual definition of the likelihood function, since you can proptly start running your MCMCs. Despite this, you should provide to the likelihood some file where to find the proper LiteBIRD noise power spectra, given that LiLit is implementing a simple inverse noise weighting just as a place-holder for something more realistic. As regards lensing, LiLit will need you to pass the reconstruction noise, since its computation is not coded, thus there is no place-holder for lensing.
This repository should also give to new Cobaya-users a good starting point to build upon (see this).
The repository can be found at https://github.com/ggalloni/LiLit.
To install the LiLit package it is sufficient to do:
pip install lilit
Then, to access the LiLit class, it is sufficient to import it as:
from lilit import LiLit
Finally, to use the provided functions, you should import them as:
from lilit import CAMBres2dict
If you want to start using LiLit, here are some further details on what you can do with it. Firstly, LiLit is independent of the number of fields considered and can be dynamically modified at declaration. Thus, it makes no difference if you want to use B-modes alone, or if you want to use CMB temperature, E-modes, lensing, etc. The only constraint is that the Boltzmann code you are using to provide the spectra should understand the fields you are asking to LiLit. Each of these fields may have their own
fields = ["t", "e", "b"]
# lmax = [lmaxTT, lmaxEE, lmaxBB]
lmax = [1500, 1200, 900]
# lmin = [lminTT, lminEE, lminBB]
lmin = [20, 2, 2]
# fsky = [fskyTT, fskyEE, fskyBB]
fsky = [1.0, 0.8, 0.6]
If you do not want to pass custom fiducial power spectra for the fields you requested, you can exploit the fact that LiLit will internally compute every spectra according to Planck 2018 best-fit values of the cosmological parameters. Note that if you requested B-modes, you must provide the value you want to assign to the tensor-to-scalar ratio
As regards noise, as mentioned above you should pass realistic power spectra according to what you are working on. Just as a mere place-holder, LiLit will compute the inverse-weighted noise (P. Campeti et al., 2020) over each channel of LiteBIRD (E. Allys et al., 2022).
Once you have fixed all these quantities, you are ready to define your likelihood. The only remaining things to decide are what approximation you want to use to compute the
name = exampleTEB
# using the exact likelihood approximation
exampleTEB = LiLit(name=name, fields=fields, like="exact", nl_file="/path/to/noise.pkl", lmax=lmax, fsky=fsky, debug=False)
# using the Gaussian likelihood approximation
exampleTEB = LiLit(name=name, fields=fields, like="gaussian", nl_file="/path/to/noise.pkl", lmax=lmax, fsky=fsky, debug=False)
Note that you may want to set debug to True in order to check that everything is OK.
I tried to be as modular as possible so that you can plug whatever existing function you have. Also, this should make parallelization easier if you need it.
As mentioned above, LiLit implements two kinds of likelihood approximations: the exact one and the Gaussian one. Here, I will give some details on how they are implemented and I will clarify some underlying assumption.
Firstly, let me explicitly report the formula used for this approximation, starting from the single field case:
Instead assuming to have
where for example
Here, each entry may look something like:
The handling of the field-specific
Then, for each field, the code will fill with zeros the entries corresponding to a given field if
excluded_probes = ["xz"]
These will be also sent to zero in the covariance matrix. This, together with the multipole ranges, will cause the covariance matrix to be singular. In order to avoid this, the code will check whether the determinant of the covariance is null. If so, it will identify the diagonal entries that are null and remove the correspondent row and column.
Note that the likelihood expressions above are exact in the full-sky case. In order to account for the sky cut, both the single-field and the multiple-field formulae are multiplied by a factor
The Gaussian approximation is based on the following formula:
where
Once again, the coupling between multipoles introduced by the sky cut is not taken into account. Instead, we just introduce a factor
The multi-field case is slightly more involved. The data vector is obtained from the
Thus, the covariance of this object will be a
where
In the Gaussian case, the multipole ranges and excluded probes are handled differently w.r.t. the exact case. Firstly, the range of the cross-correlation of two fields is given by the geometrical mean of the two (e.g.
Finally, the likelihood reads:
Differently from the exact likelihood case, here each field retains its own
This likelihood is still in development. At the moment, only the single-field case is implemented. It represent the generalization to account for the correlation between different multipoles. In particular, the covariance matrix must be computed externally and provided to the LiLit class (let me call it
where now
The multi-field case is still to be implemented.
Here, you can find two very simple examples of the skeleton of a single-field likelihood and a two-field one. If you are new to Cobaya, you may want to have a look at these before jumping to LiLit.
As regards the single-field likelihood, what you can find there is a very basic example of how to run Cobaya on a generic field X. Some parts of this may require additional attention before running, however this should give you an idea of how to work with this package. For instance, here I am considering a very simple case in which I do not need to pass anything to the likelihood class but the spectra, and in which the likelihood does not provide any derived parameters.
I provide also few working examples of the usage of LiLit. Some particular attention should be given to the dictionaries defined in the sampling scripts. If you are not familiar with their structure, have a look at Cobaya's documentation. Then, I customized these to maximize accordance with the fiducial Planck 2018 spectra. These also assume that you will be using CAMB (A. Lewis et al., 2000); for the CLASS (D. Blas et al., 2011) equivalent of this, refer again to documentiation, since some of the parameters are renamed. Note that Cobaya will understand whatever newly defined parameter you added to the Boltzmann code.
In the parameters block of the sampling dictionary, parameters with a prior will be interpreted as open parameters, while all the others are essentially derived ones. Cobaya will figure out by itself whether it has to ask for some of them to the theory code (CAMB) or to other parameters. Also, it will figure out what parts of the routines need certain parameters. For example, you can pass
Once you have finished preparing your sampling.py file, you can run it simply by using:
python sampling.py > log.txt
Sending the inline output to a text file might help in recovering information on how the run is going. If you want to run it parallely, you may want to use something like:
mpirun -np 4 --cpus-per-proc 4 python sampling.py > log.txt
The number of processess translates on the number of chains that will be runned simultaneously.
- cobaya
- numpy
- healpy
- pyyaml
- matplotlib
- camb
The documentation can be found at https://ggalloni.github.io/LiLit.
If you want to help developing the code, feel free to send a pull request. Also, feel free to write me so that we can discuss on eventual major developments.
For additional details on how Cobaya works, I suggest to see the documentation, which is very good to find whatever is not working in you case. If you cannot find the problem there, feel free to open an issue.