CAMB-Python Interface
CAMB-Python Interface
I thought I'd put this up, on the off-chance it's of use to someone.
I've written a code to generate bindings for CAMB so you can call its main functions directly from the Python programming language.
This makes it easy, for example, to quickly generate power spectra for many different parameters combinations, and then plot them nicely, all in the same script. It's also useful for interactively exploring parameter spaces.
It's simple to add new parameters to it, if you've modified something in CAMB.
Code and instructions available here.
Please send any bugs/requests to jaz (at) astro.ox.ac.uk
Joe
I've written a code to generate bindings for CAMB so you can call its main functions directly from the Python programming language.
This makes it easy, for example, to quickly generate power spectra for many different parameters combinations, and then plot them nicely, all in the same script. It's also useful for interactively exploring parameter spaces.
It's simple to add new parameters to it, if you've modified something in CAMB.
Code and instructions available here.
Please send any bugs/requests to jaz (at) astro.ox.ac.uk
Joe
-
- Posts: 16
- Joined: March 31 2009
- Affiliation: IPhT CEA-Saclay
- Contact:
CAMB-Python Interface
Hi Joe,
Thanks a lot, this is very useful :)
I don't know if anybody else has a problem compiling the Python code on a Mac? The "f2py" command complained that the CAMB library ("libcamb.a") had a problem. I found that one first needs to add a table of contents to the library before running "f2py". This is done with the "ranlib" command. So I added a line
before calling "f2py" in the end of "generatePyCamb.py".
By the way, I finally put my new version of GetDist_py up: http://www.physi.ch/lukas/Code.html. This is a version of GetDist (CosmoMC May 2010) which generates Python/PyLab scrips aside or instead of the usual Matlab scripts.
Lukas
Thanks a lot, this is very useful :)
I don't know if anybody else has a problem compiling the Python code on a Mac? The "f2py" command complained that the CAMB library ("libcamb.a") had a problem. I found that one first needs to add a table of contents to the library before running "f2py". This is done with the "ranlib" command. So I added a line
Code: Select all
system('make all && ranlib libcamb.a')
By the way, I finally put my new version of GetDist_py up: http://www.physi.ch/lukas/Code.html. This is a version of GetDist (CosmoMC May 2010) which generates Python/PyLab scrips aside or instead of the usual Matlab scripts.
Lukas
-
- Posts: 3
- Joined: April 02 2013
- Affiliation: ICRAR UWA
CAMB-Python Interface
Hi thanks so very much for this!
I was just in the middle of making my own version of the same thing - then thought "hey just wait a minute, someone may have done this already!"
I'll check it out and let you know if it works for me. I'm using Mac OSX as well.
I was just in the middle of making my own version of the same thing - then thought "hey just wait a minute, someone may have done this already!"
I'll check it out and let you know if it works for me. I'm using Mac OSX as well.
-
- Posts: 3
- Joined: April 02 2013
- Affiliation: ICRAR UWA
CAMB-Python Interface
Hi again,
It all worked well! I am using March2013 version of camb and the only thing I had to change for it to work was to change the library link to -lcamb_recfast rather than just -lcamb (I guess the name has changed in the last while).
I am looking to use this code within another project of mine which is a flexible program to find the halo mass function. Wold it be okay if I copied your link to the code?
It all worked well! I am using March2013 version of camb and the only thing I had to change for it to work was to change the library link to -lcamb_recfast rather than just -lcamb (I guess the name has changed in the last while).
I am looking to use this code within another project of mine which is a flexible program to find the halo mass function. Wold it be okay if I copied your link to the code?
CAMB-Python Interface
Hi all,
There is an updated version of this code, available at:
https://github.com/joezuntz/pycamb
(special thanks to github user rainwoodman for packaging and similar improvements!)
There is an updated version of this code, available at:
https://github.com/joezuntz/pycamb
(special thanks to github user rainwoodman for packaging and similar improvements!)