Astroquery SIMBAD:获取所有帧的坐标

Astroquery SIMBAD : Obtaining coordinates for all frames

我正在尝试使用来自 astroquerySimbad class 获取所有帧的坐标,就像在 SIMBAD web page 上显示的一样 (基础数据部分)

我有以下代码:

from astroquery.simbad import Simbad

def get():
    Simbad.reset_votable_fields()
    Simbad.remove_votable_fields('coordinates')

    Simbad.add_votable_fields('ra(:;A;ICRS;J2000)', 'dec(:;D;ICRS;2000)')
    Simbad.add_votable_fields('ra(:;A;FK5;J2000)', 'dec(:;D;FK5;2000)')

    table = Simbad.query_object("Betelgeuse", wildcard=False)

但我收到错误消息:

KeyError: 'ra(:;A;FK5;J2000): field already present. Fields ra,dec,id,otype, and bibcodelist can only be specified once. To change their options, first remove the existing entry, then add a new one.'

我在文档中可以找到的关于操纵可投票字段的所有内容,尤其是坐标是这样的:

http://astroquery.readthedocs.io/en/latest/simbad/simbad.html#specifying-the-format-of-the-included-votable-fields

有没有办法获取向 SIMBAD 发送一个查询的所有帧的坐标?

您可以使用 astropy.coordinates.SkyCoord 转换坐标,而不是从 SIMBAD 查询多个坐标(这对于 astroquery 似乎是不可能的)。

例如:

from astroquery.simbad import Simbad
from astropy.coordinates import SkyCoord

Simbad.reset_votable_fields()
Simbad.remove_votable_fields('coordinates')
Simbad.add_votable_fields('ra(:;A;ICRS;J2000)', 'dec(:;D;ICRS;2000)')
table = Simbad.query_object("Betelgeuse", wildcard=False)
coords = SkyCoord(ra=['{}h{}m{}s'.format(*ra.split(':')) for ra in table['RA___A_ICRS_J2000']], 
                  dec=['{}d{}m{}s'.format(*dec.split(':')) for dec in table['DEC___D_ICRS_2000']],
                  frame='icrs', equinox='J2000')

现在是可以转换为其他帧的 SkyCoord 对象:

>>> coords
<SkyCoord (ICRS): (ra, dec) in deg
    ( 88.79293875,  7.40706389)>
>>> coords.fk4
<SkyCoord (FK4: equinox=J2000.000, obstime=B1950.000): (ra, dec) in deg
    ( 88.79274075,  7.40705223)>
>>> coords.fk5
<SkyCoord (FK5: equinox=J2000.000): (ra, dec) in deg
    ( 88.79294545,  7.40705842)>

这个可以再转成字符串,比如hms dms格式:

>>> coords.fk5.to_string('hmsdms')
['05h55m10.3069s +07d24m25.4103s']

如果您希望这些作为 table 中的附加列,您只需添加这些:

>>> table['RA FK5'] = coords.fk5.ra
>>> table['DEC FK5'] = coords.fk5.dec
>>> table['FK4'] = coords.fk4.to_string('hmsdms')
>>> table
 MAIN_ID  RA___A_ICRS_J2000 DEC___D_ICRS_2000     RA FK5       DEC FK5                 FK4             
               "h:m:s"           "d:m:s"           deg           deg     
--------- ----------------- ----------------- ------------- ------------- -----------------------------
* alf Ori     05:55:10.3053     +07:24:25.430 88.7929454548 7.40705841559 05h55m10.2578s +07d24m25.388s

由于我无法确定的原因,astroquery 不支持多个可配置的添加 VO 选项。不过,它很快就会出现:请参阅 this pull request。您发布的代码没有问题,只是astroquery中的一个错误。