PyCAMB get_matter_power_interpolator failure

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Felipe Maldonado
Posts: 26
Joined: November 10 2016
Affiliation: FSU

PyCAMB get_matter_power_interpolator failure

Post by Felipe Maldonado » November 10 2016

I'm having trouble getting camb.get_matter_power_interpolator to work.

I copied the entire CAMB example notebook and ran every line, and it worked fine until I called the matter power spectrum interpolator:

Code: Select all

PK = camb.get_matter_power_interpolator(pars, nonlinear=True, 
    hubble_units=False, k_hunit=False, kmax=kmax,
    var1=model.Transfer_Weyl,var2=model.Transfer_Weyl, zmax=zs[-1])

#Have a look at interpolated power spectrum results for a range of redshifts
#Expect linear potentials to decay a bit when Lambda becomes important, and change from non-linear growth
plt.figure(figsize=(8,5))
k=np.exp(np.log(10)*np.linspace(-4,2,200))
zplot = [0, 0.5, 1, 4 ,20]
for z in zplot:
    plt.loglog(k, PK.P(z,k))
Which failed with the following error message:

Code: Select all

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-35-5020b52ca2b4> in <module>&#40;&#41;
     34 zplot = &#91;0, 0.5, 1, 4 ,20&#93;
     35 for z in zplot&#58;
---> 36     plt.loglog&#40;k, PK.P&#40;z,k&#41;&#41;
     37 plt.xlim&#40;&#91;1e-4,kmax&#93;&#41;
     38 plt.xlabel&#40;'k Mpc'&#41;

/usr/local/lib/python2.7/dist-packages/camb/camb.pyc in P&#40;self, z, kh, grid&#41;
   1128                 grid = not np.isscalar&#40;z&#41; and not np.isscalar&#40;kh&#41;
   1129             if self.islog&#58;
-> 1130                 return np.exp&#40;self&#40;z, np.log&#40;kh&#41;, grid=grid&#41;&#41;
   1131             else&#58;
   1132                 return self&#40;z, np.log&#40;kh&#41;, grid=grid&#41;

TypeError&#58; __call__&#40;&#41; got an unexpected keyword argument 'grid'
I copy pasted the offending code from the example notebook so I don't believe it to be wrong. Furthermore, I asked someone else to run it on their machine and it did work, which leads me to believe the problem is with my machine. We both ran CAMB 0.1.2 and Python 2.7.6 on different Linux distributions and probably different compilers, but both of us have gfortran 4.9 or newer as required,

Any guidance in this matter would be greatly appreciated.
Felipe

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

Re: PyCAMB get_matter_power_interpolator failure

Post by Antony Lewis » November 10 2016

Check you have the latest scipy?

Felipe Maldonado
Posts: 26
Joined: November 10 2016
Affiliation: FSU

Re: PyCAMB get_matter_power_interpolator failure

Post by Felipe Maldonado » November 10 2016

Antony Lewis wrote:Check you have the latest scipy?
Hi, thank you for your reply.

I updated my versions of Numpy and Scipy and now it does work.
Thank you so much for your assistance.

Felipe

Post Reply