2

私は astropy.cosmology で作業しようとしています。ドキュメントにあるように、ハッブル パラメーター メソッドを使用すると、単位付きの値が得られるはずです - astropy.cosmology documentation

しかし、それはここに見られるように私にただの数を与えます -

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'
>>> 

問題は何ですか?

4

1 に答える 1

7

数量のサポートは Astropy 0.3 で追加されたため (ここを参照)、表示されているのは Astropy 0.2.x の予想される動作です。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)

次のこともできることに注意してください。

In [8]: from astropy.cosmology import Planck13

In [9]: print Planck13.H(10**6)
6.47883897961e+11 km / (Mpc s)

これはより簡潔です。

于 2014-02-04T15:05:49.250 に答える