Cobaya: how to raise a CAMBParamRangeError or CAMBError in CAMB python scritp

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Diogo Souza
Posts: 2
Joined: July 01 2022
Affiliation: IFT UNESP

Cobaya: how to raise a CAMBParamRangeError or CAMBError in CAMB python scritp

Post by Diogo Souza » July 23 2022

Dear all,

According to the section "Modifying CAMB" (https://cobaya.readthedocs.io/en/latest/theory_camb.html?#modifying-camb) in cobaya.readthedocs we can use CAMBParamRangeError, or simply CAMBError to assign a zero likelihood when the computation of any observable would fail. In my case the observable is omega_de and the fail is omega_de<0 and the MCMC chain stop when this occurs. Therefore, to use this Cobaya functionality, what I did was to put CAMBError in the function set_params in the python module results.py. The modified results.py is

Code: Select all

    def set_params(self, params):
        """
        Set parameters from params. Note that this does not recompute anything;
        you will need to call :meth:`calc_transfers` if you change any parameters affecting the
        background cosmology or the transfer function settings.

        :param params: a :class:`~.model.CAMBparams` instance
        """
        self.Params = params
        if (self.omega_de < 0):
            raise CAMBError('omega dark energy is negative, assigning 0 likelihood')
However, that did not work and the chain stopped due to omega_de<0. I am using CAMBError at the right place?. If yes, why this is not working? If no, where is the right place to use CAMBError in order to assign a zero likelihood for omega_de<0?

Thank you very much.

Antony Lewis
Posts: 1842
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Cobaya: how to raise a CAMBParamRangeError or CAMBError in CAMB python scritp

Post by Antony Lewis » July 24 2022

You seem to be checked before any parameters are actually set in that function

Post Reply