Astropy'Time'对象没有属性'dtype'

问题描述 投票:0回答:1

由于更新为Astropy 4.0,因此尝试访问dtype对象的Time导致错误

'Time'对象没有属性'dtype'

我已经阅读了文档,但是找不到有关此更改或如何复制其提供的功能的说明。在更新之前,此类访问将返回Timeobject之类的值。

如何检索Astropy 4.0 float64实例的dtype

astropy dtype
1个回答
0
投票

您要从哪个版本的Astropy升级?我找不到[(已记录)] Time属性的任何最新版本。在以前的版本中:

Time.dtype

但是,有:

>>> import astropy
>>> astropy.__version__
'3.2.3'
>>> from astropy.time import Time
>>> t = Time([1, 2, 3], format='unix')
>>> t.dtype
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/embray/.virtualenvs/astropy/lib/python3.6/site-packages/astropy/time/core.py", line 1558, in __getattr__
    return self.__getattribute__(attr)
AttributeError: 'Time' object has no attribute 'dtype'

其中>>> t.value.dtype dtype('float64') 给出值的基础numpy数组(也许可以更好地记录)。

我不确定是否有Time.value,或者如果确实存在,则必须是较旧的版本。

© www.soinside.com 2019 - 2024. All rights reserved.