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

Posted:

**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
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.

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')
```

Thank you very much.