Saving Cls and mpk from cobaya
Posted: April 09 2025
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?
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)
Code: Select all
sampler:
evaluate: