Page 1 of 1

Example of using sources in Cobaya

Posted: November 07 2019
by Omar Darwish
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,

Re: Example of using sources in Cobaya

Posted: November 08 2019
by Antony Lewis
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.

Re: Example of using sources in Cobaya

Posted: November 08 2019
by Omar Darwish
Thank you Antony, I will try this, cross check with my code (as I found a difference with camb sources) and let you know!

Re: Example of using sources in Cobaya

Posted: November 08 2019
by Antony Lewis
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.

Re: Example of using sources in Cobaya

Posted: November 11 2019
by Omar Darwish
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?)

Re: Example of using sources in Cobaya

Posted: November 12 2019
by Antony Lewis
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).