Page 1 of 1

Setting DE params in PyCAMB

Posted: November 21 2017
by Federico Bianchini
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!

Re: Setting DE params in PyCAMB

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

Setting DE params in PyCAMB

Posted: November 22 2017
by Federico Bianchini
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!

Re: Setting DE params in PyCAMB

Posted: November 22 2017
by Antony Lewis
Yes, I would just make a UnivariateSpline.