Example of using sources in Cobaya

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Post Reply
Omar Darwish
Posts: 10
Joined: October 01 2019
Affiliation: damtp

Example of using sources in Cobaya

Post by Omar Darwish » November 07 2019

Hi,

I already have a code built on CAMB that calculates power spectra for different types of sources (in the Limber approximation). I discovered that camb has already camb sources, and I was able to use it.

Now, as I think this might speed up my likelihood calculation in my cosmological analysis, I tried to use source_Cl in theory needs for cobaya. But I really do not know what to do precisely. From the documentation for me it is not very clear, and I appreciate some help.

I tried different combinations of using dictionaries, for example "source_Cl": {"sources": {"source1": {"function": "spline", "bias": 1., "z": z, "W": W}}}}, but nothing... (z is redshift, W is a number count in this specific example)

Is there any proper example to use source_Cl in cobaya? For other observables it was easy to implement them from the documentation.

Thanks,

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

Re: Example of using sources in Cobaya

Post by Antony Lewis » November 08 2019

The syntax looks correct, but there may have been a bug - try the "getdist1" branch on github (until it is merged). This feature is not well tested yet.

Omar Darwish
Posts: 10
Joined: October 01 2019
Affiliation: damtp

Re: Example of using sources in Cobaya

Post by Omar Darwish » November 08 2019

Thank you Antony, I will try this, cross check with my code (as I found a difference with camb sources) and let you know!

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

Re: Example of using sources in Cobaya

Post by Antony Lewis » November 08 2019

Note you probably want to set limber=True otherwise it can be very slow. The "sources" branch now adds an explicit test example in tests/test_cosmo_camb.py, as well as allowing you to specify lmax.

Omar Darwish
Posts: 10
Joined: October 01 2019
Affiliation: damtp

Re: Example of using sources in Cobaya

Post by Omar Darwish » November 11 2019

I tried it and it works thank you Antony!

But in the end, as I cut my galaxy window function I decided to just use the code that calculates by hand angular power spectra in the Limber approximation, but using the theory products of cobaya like Pk, chi, etc... (and fixing a number of z array on which to do the interpolation. i do not think this is super important for varying cosmology). In the end the code runs faster.

** (galaxy window function with a cut, i.e. something like step function, does not work well with camb sources, giving a strange result. i think this is somehow related to the cubic interpolation?)

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

Re: Example of using sources in Cobaya

Post by Antony Lewis » November 12 2019

A pure Limber code may be faster because CAMB always uses non-Limber on large scales where it is accurate. The speed also depends a lot on settings/kmax/lmax etc. It does also require smooth source functions because it integrates by parts (e.g. to get the redshift distortions).

Post Reply