Astroquery SIMBAD:获取所有帧的坐标

2024-04-18 01:59:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用Simbad类从astroquery获取所有帧的坐标,就像在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.'

我在文档中找到的关于操作votable字段的所有信息,尤其是坐标如下:

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

有没有一种方法可以获得发送一个查询到SIMBAD的所有帧的坐标?


Tags: theaddwebfieldsdecremoveraastroquery
2条回答

由于我无法确定的原因,astroquery不支持多个可配置的添加VO选项。不过,很快就会有:见this pull request。你发布的代码没有问题,只是astroquery中的一个bug。在

您可以使用^{}转换坐标,而不是从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对象:

^{pr2}$

这可以再次转换为字符串,例如hms dms格式:

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

如果要将这些列作为表中的附加列,只需添加以下内容:

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

相关问题 更多 >