Saving Cls and mpk from cobaya

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Tristan L Smith
Posts: 28
Joined: November 14 2005
Affiliation: Swarthmore
Contact:

Saving Cls and mpk from cobaya

Post by Tristan L Smith »

I am interested in running cobaya with a specific set of cosmological parameters and having it save the Cls and matter power spectrum. Is there a quick way to do this?
Tristan L Smith
Posts: 28
Joined: November 14 2005
Affiliation: Swarthmore
Contact:

Re: Saving Cls and mpk from cobaya

Post by Tristan L Smith »

After poking around a bit, I found a way to do this:

Code: Select all

import cobaya
import numpy as np
from cobaya.yaml import yaml_load
from cobaya.model import get_model

yaml_file='./XXX.yaml' #your yaml file

info = yaml_load(yaml_file)
model = get_model(info)

point = dict(zip(model.parameterization.sampled_params(),model.prior.sample(ignore_external=True)[0]))

logposterior = model.logposterior(point, as_dict=True)

Cls = model.provider.get_Cl(ell_factor=True)

np.savez('Cls.npz',  Cls)
Tristan L Smith
Posts: 28
Joined: November 14 2005
Affiliation: Swarthmore
Contact:

Re: Saving Cls and mpk from cobaya

Post by Tristan L Smith »

and I forgot to add that I put

Code: Select all

sampler:
  evaluate:
in my yaml file.
Post Reply