Setting DE params in PyCAMB

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Post Reply
Federico Bianchini
Posts: 9
Joined: June 25 2013
Affiliation: University of Melbourne
Contact:

Setting DE params in PyCAMB

Post by Federico Bianchini » November 21 2017

Hi Antony et al,

I'm playing with the devel branch python wrapper as I want to call CAMB for different (w0,wa).

I realized that if you initialize two cosmologies as done below

Code: Select all

pars = camb.CAMBparams()
pars.set_cosmology(H0=67.5, ombh2=0.022, omch2=0.122)
pars.InitPower.set_params(As=2e-9, ns=0.95)
pars.set_dark_energy(w=-1, cs2=1., wa=0, dark_energy_model='fluid')
data = camb.get_background(pars)

pars2 = camb.CAMBparams()
pars2.set_cosmology(H0=67.5, ombh2=0.022, omch2=0.122)
pars2.InitPower.set_params(As=2e-9, ns=0.95)
pars2.set_dark_energy(w=-0.5, cs2=1., wa=0.1, dark_energy_model='ppf')
data2 = camb.get_background(pars2)
then the background quantities computed for the two cosmologies are the same, for example data.angular_diameter_distance(0.3) will be equal to data2.angular_diameter_distance(0.3).

Am I missing something trivial or is this behaviour expected?

What is the best way to initialize different cosmologies and avoid the overwriting?

Thanks for any inputs!

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

Re: Setting DE params in PyCAMB

Post by Antony Lewis » November 21 2017

If you use

Code: Select all

pars = camb.CAMBparams() 
pars.set_cosmology(H0=67.5, ombh2=0.022, omch2=0.122) 
pars.InitPower.set_params(As=2e-9, ns=0.95) 
pars.set_dark_energy(w=-1, cs2=1., wa=0, dark_energy_model='fluid') 
data = camb.get_background(pars) 
print data.angular_diameter_distance(0.3)

pars2 = camb.CAMBparams() 
pars2.set_cosmology(H0=67.5, ombh2=0.022, omch2=0.122) 
pars2.InitPower.set_params(As=2e-9, ns=0.95) 
pars2.set_dark_energy(w=-0.5, cs2=1., wa=0.1, dark_energy_model='ppf') 
data2 = camb.get_background(pars2) 
print data2.angular_diameter_distance(0.3)
you will get different numbers. Generally anything that does a new computation (like get_background) works with the most-recently set parameters (i.e. the data objects do not maintain a full copy of code state).

Federico Bianchini
Posts: 9
Joined: June 25 2013
Affiliation: University of Melbourne
Contact:

Setting DE params in PyCAMB

Post by Federico Bianchini » November 22 2017

Oh, I see that, thanks for your reply Antony.

Pardon my ignorance but is there any way to permanently dump the content of the data object? Say that I'm interested in storing some background quantity (such as the luminosity distance) for two cosmologies, should I just create two splines based on the data object?

Thanks again!

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

Re: Setting DE params in PyCAMB

Post by Antony Lewis » November 22 2017

Yes, I would just make a UnivariateSpline.

Post Reply