Cobaya: Using External Power Spectrum

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Umang Kumar
Posts: 6
Joined: March 15 2023
Affiliation: Ashoka University

Cobaya: Using External Power Spectrum

Post by Umang Kumar » March 15 2023

I am new to Cobaya and wish to figure out how to give an external power spectrum to CAMB from Cobaya input file (.yaml).

I have been using CAMB and setting my desired power spectrum using the method set_initial_power_function(Pk, args), where Pk is the desired power spectrum defined before as a python function.

I want to extend this to Cobaya and constrain a single parameter (say T) in my power spectrum. How should I go about doing this, specifying Cobaya to use this power spectrum?

I went through the docs but couldn't figure out how to connect my python file with Cobaya's input file.

Note: I am trying to run Cobaya from the shell, using the command cobaya-run [filename].yaml

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

Re: Cobaya: Using External Power Spectrum

Post by Antony Lewis » March 16 2023

I would probably make a new power spectrum class in CAMB (python) inheriting from SplinedInitialPower, writing your set_params method to take in your new parameter and assign the power spectrum within that function (calling inherited set_scalar_table with a spline sampling of your function).

Or you could modify CAMB's main set_params to call set_initial_power_function with your function for the current value of the parameters.

Umang Kumar
Posts: 6
Joined: March 15 2023
Affiliation: Ashoka University

Re: Cobaya: Using External Power Spectrum

Post by Umang Kumar » March 16 2023

Hi Antony!

Thanks for replying!

I understand that I can make a python file and get a table of k and Pk from my defined power spectrum function and then feed it into CAMB but what I don't understand is that, how should I interface this with Cobaya? Where and how does this python file go in the Cobaya input file?

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

Re: Cobaya: Using External Power Spectrum

Post by Antony Lewis » March 17 2023

If you modify CAMB, then you just use your new parameters just like standard CAMB parameters.

But you can also do this entirely from the Cobaya side by writing a Theory component to implement your primordial power spectrum. There's a complete example in the tests at
https://github.com/CobayaSampler/cobaya/blob/master/tests/test_cosmo_multi_theory.py#L175

Umang Kumar
Posts: 6
Joined: March 15 2023
Affiliation: Ashoka University

Re: Cobaya: Using External Power Spectrum

Post by Umang Kumar » March 17 2023

Thanks a lot! This helps!

Post Reply