I'm trying to work with astropy.cosmology. As the documentation says, when I use the Hubble parameter method it should give me a value with units - astropy.cosmology documentation
But it gives me just a number as can be seen here -
ohm@ohm-ThinkCentre-M57:~/projects/mucalc$ python
Python 2.7.3 (default, Sep 26 2013, 20:08:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from astropy import cosmology
>>> cosmology.core.set_current(cosmology.Planck13)
>>> H0 = cosmology.H(10**6)
>>> print H0
647883886243.0
>>> H0.value
ERROR: AttributeError: 'numpy.float64' object has no attribute 'value' [unknown]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'numpy.float64' object has no attribute 'value'
>>>
What could be the issue?
Support for quantities was added in Astropy 0.3 (see here), so what you are seeing is the expected behavior for Astropy 0.2.x. Here is the output with 0.3:
In [1]: from astropy import cosmology
In [2]: cosmology.core.set_current(cosmology.Planck13)
In [3]: H0 = cosmology.H(10**6)
In [4]: print H0
6.47883897961e+11 km / (Mpc s)
Note that you can also do:
In [8]: from astropy.cosmology import Planck13
In [9]: print Planck13.H(10**6)
6.47883897961e+11 km / (Mpc s)
which is more concise.