I'm using cobaya to sample over As and would like to additionally output sigma8 in my chains. But I'm having some difficulty doing this. I tried "get_sigma8" in pycamb as in boxes 8 and 9 here:
https://camb.readthedocs.io/en/latest/CAMBdemo.html
Running the following code:
model = get_model(info)
theory = model.likelihood.theory
pars = theory.camb.CAMBparams()
theory.camb.get_results(pars)
I got CAMBValueError: Parameter values not set on the last line.
Is there perhaps another method to get sigma8?
Calculating sigma8 in cobaya
-
- Posts: 11
- Joined: November 07 2019
- Affiliation: UC Berkeley
-
- Posts: 11
- Joined: October 01 2019
- Affiliation: unige
Re: Calculating sigma8 in cobaya
To put sigma8 in your chains you just add it as a derived parameter in the info dictionary:
params = odict([
["logAs", {"prior": {"min": lnAs_min, "max": lnAs_max}, "ref": {"dist": "norm", "loc": lnAs_central, "scale": 1.67162852e-02}, "proposal": 1.67162852e-02}],.......
["As", {"value": lambda logAs: 1e-10*np.exp(logAs), "latex": r"A_s"}],
["sigma8", {"derived": True, "latex": r"\sigma_8"}]])
(....... represents other parameters you want to put)
Then in the info:
info = {
"likelihood": .....,
"theory": {"camb": {"extra_args": {"accurate_massive_neutrino_transfers": True, "redshifts": [0.], "nonlinear": True, "kmax": 10., "dark_energy_model": "ppf", "WantTransfer": True}}},
"params": params,
"sampler": {"evaluate": {None}}, #{"mcmc": {"burn_in": 100, "max_samples": 20000, "max_tries": 400, "learn_proposal": True, "covmat": chains_dir+starting_covmat}},
"timing": True,
"resume": True,
#"debug": True,
"output": .....}
where "redshifts" are the redshifts where you want to calculate sigma8.
This is how I've done it. I do not know if there are other ways, but from what I understood cobaya developers want to you use the functions that they give you to get parameters, without accessing specific attributes of the theory.
Let me know if it is not clear!
params = odict([
["logAs", {"prior": {"min": lnAs_min, "max": lnAs_max}, "ref": {"dist": "norm", "loc": lnAs_central, "scale": 1.67162852e-02}, "proposal": 1.67162852e-02}],.......
["As", {"value": lambda logAs: 1e-10*np.exp(logAs), "latex": r"A_s"}],
["sigma8", {"derived": True, "latex": r"\sigma_8"}]])
(....... represents other parameters you want to put)
Then in the info:
info = {
"likelihood": .....,
"theory": {"camb": {"extra_args": {"accurate_massive_neutrino_transfers": True, "redshifts": [0.], "nonlinear": True, "kmax": 10., "dark_energy_model": "ppf", "WantTransfer": True}}},
"params": params,
"sampler": {"evaluate": {None}}, #{"mcmc": {"burn_in": 100, "max_samples": 20000, "max_tries": 400, "learn_proposal": True, "covmat": chains_dir+starting_covmat}},
"timing": True,
"resume": True,
#"debug": True,
"output": .....}
where "redshifts" are the redshifts where you want to calculate sigma8.
This is how I've done it. I do not know if there are other ways, but from what I understood cobaya developers want to you use the functions that they give you to get parameters, without accessing specific attributes of the theory.
Let me know if it is not clear!
-
- Posts: 11
- Joined: November 07 2019
- Affiliation: UC Berkeley
Re: Calculating sigma8 in cobaya
Thank you, this solved my problem!