Example of using sources in Cobaya
-
- Posts: 11
- Joined: October 01 2019
- Affiliation: unige
Example of using sources in Cobaya
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,
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,
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Example of using sources in Cobaya
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.
-
- Posts: 11
- Joined: October 01 2019
- Affiliation: unige
Re: Example of using sources in Cobaya
Thank you Antony, I will try this, cross check with my code (as I found a difference with camb sources) and let you know!
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Example of using sources in Cobaya
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.
-
- Posts: 11
- Joined: October 01 2019
- Affiliation: unige
Re: Example of using sources in Cobaya
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?)
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?)
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Example of using sources in Cobaya
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).