基本目标:给定一组天空坐标(ra, dec),这个Python函数应该返回以这些坐标为中心的天空的FITS图像。
详细目标:该函数将使用 astroquery 和 simbad 进行坐标查询。理想情况下,它将能够访问以 (ra, dec) 为中心的给定区域内的天体数据库。因此,还将输入一些大小参数(FoV,或半径)。但主要是,当通过浏览器在simbad上进行查询时,有一个选项可以绘制以输入坐标为中心的恒星区域,由AladinLite制作,函数应该返回这个图像(希望是FITS图像)。
我试过的。我所做的一切努力都是为了发现星体查询和simbad的使用。但我在文档中找不到任何关于如何通过 astroquery 获得 AladinLite 的图像。找到用Python直接从Aladin获取图像的方法似乎也不可能。
问题是 是否可以用Python和天体查询在浏览器版的simbad坐标查询上得到AladinLite生成的那个图像?如果可以,我怎么去做呢?
我附上了一张网页浏览器的截图,显示AladinLite生成的图像。要说明的是--我想要的是星域的图像,而不是有圈点物体等的图像。
一些伪代码。
def generate_starfield(ra, dec, FoV):
# define the sky coords
coords = SkyCoord(ra=ra, dec=dec)
# do an astroquery.simbad query using above coords
query = perform_query(coords)
# extract the image from the query generated by AladinLite
image = get_aladinlite_image(query, FoV)
return image
警告:我不是天文学的研究者,虽然我是Astropy的开发者,但我并不是真正的用户,所以如果有更有经验understanding这个问题的人想来,可能会有一些稍微好一点的方法。
但是AladinLite不是一个图像目录。 它只是一个基于Web的图像浏览和绘图的UI。 但是,它的 AladinLite 斯特拉斯堡大学的样本服务从他们的数据中获取。HiPS调查 服务。 他们通过以下方式提供这些数据 臀部2fits 基于网络的API。 我不认为AladinLite提供了一个接口,可以将所有显示的瓷砖收集到一个FITS图像中下载。 这就是hips2fits服务的目的。 顺便说一下,它在网站上指出。
我们将开发一个从 astroquery. cds上访问hips2fits的功能. 同时。本子 应该让你开始从Python脚本中查询hips2fits。
所以你的工作流程的第一部分是正确的。你将使用 astroquery
来查询Simbad。 但是你需要查询图像数据。 目前还没有专门针对Python的API,但Web API有很好的文档,所以主要是构建正确的URL的问题。 下面是我用你给出的截图中的相同坐标得出的一个工作流程示例。
>>> from astroquery.simbad import Simbad
>>> from astropy.coordinates import SkyCoord
>>> coord = SkyCoord('16 14 20.30000000 -19 06 48.1000000', unit=(u.hourangle, u.deg), frame='fk5')
>>> query_results = Simbad.query_region(coord)
>>> query_results
<Table length=3>
MAIN_ID RA DEC ... COO_QUAL COO_WAVELENGTH COO_BIBCODE
"h:m:s" "d:m:s" ...
object str13 str13 ... str1 str1 object
----------------------- ------------- ------------- ... -------- -------------- -------------------
[T64] 7 16 14 20.2881 -19 06 48.062 ... A O 2018yCat.1345....0G
IRAS 16114-1858 16 14 22.1 -19 06 14 ... E M 1988IRASP.C......0J
2MASS J16142091-1906051 16 14 20.9018 -19 06 05.195 ... A O 2018A&A...616A...1G
现在假设我想在结果中以第一个对象为中心放置一张图片(类似于网页界面上显示的AladinLite预览)。
>>> from urllib.parse import urlencode
>>> from astropy.io import fits
>>> object_main_id = query_results[0]['MAIN_ID'].decode('ascii')
>>> object_coords = SkyCoord(ra=query_results['RA'], dec=query_results['DEC'],
... unit=(u.hourangle, u.deg), frame='icrs')
>>> query_params = {
... 'hips': 'DSS',
... 'object': object_main_id,
... 'ra': object_coords[0].ra.value,
... 'dec': object_coords[0].dec.value,
... 'fov': (2 * u.arcmin).to(u.deg).value,
... 'width': 500,
... 'height': 500
... }
>>> url = f'http://alasky.u-strasbg.fr/hips-image-services/hips2fits?{urlencode(query_params)}'
>>> hdul = fits.open(url)
Downloading http://alasky.u-strasbg.fr/hips-image-services/hips2fits?hips=DSS&object=%5BT64%5D++7&ra=243.58457533549102&dec=-19.113364937196987&fov=0.03333333333333333&width=500&height=500
|==============================================================| 504k/504k (100.00%) 0s
>>> hdul.info()
>>> hdul.info()
Filename: /path/to/.astropy/cache/download/py3/ef660443b43c65e573ab96af03510e19
No. Name Ver Type Cards Dimensions Format
0 PRIMARY 1 PrimaryHDU 22 (500, 500) int16
>>> hdul[0].header
SIMPLE = T / conforms to FITS standard
BITPIX = 16 / array data type
NAXIS = 2 / number of array dimensions
NAXIS1 = 500
NAXIS2 = 500
WCSAXES = 2 / Number of coordinate axes
CRPIX1 = 250.0 / Pixel coordinate of reference point
CRPIX2 = 250.0 / Pixel coordinate of reference point
CDELT1 = -6.6666668547014E-05 / [deg] Coordinate increment at reference point
CDELT2 = 6.6666668547014E-05 / [deg] Coordinate increment at reference point
CUNIT1 = 'deg' / Units of coordinate increment and value
CUNIT2 = 'deg' / Units of coordinate increment and value
CTYPE1 = 'RA---TAN' / Right ascension, gnomonic projection
CTYPE2 = 'DEC--TAN' / Declination, gnomonic projection
CRVAL1 = 243.584534 / [deg] Coordinate value at reference point
CRVAL2 = -19.11335065 / [deg] Coordinate value at reference point
LONPOLE = 180.0 / [deg] Native longitude of celestial pole
LATPOLE = -19.11335065 / [deg] Native latitude of celestial pole
RADESYS = 'ICRS' / Equatorial coordinate system
HISTORY Generated by CDS hips2fits service - See http://alasky.u-strasbg.fr/hips
HISTORY -image-services/hips2fits for details
HISTORY From HiPS CDS/P/DSS2/NIR (DSS2 NIR (XI+IS))
现在进行绘图。 在AladinLite预览中看到的各种标记和刻度是由AladinLite查看器本身生成的,所以使用基于Python的工作流程,现在由你来提供自己的绘图。 有很多方法可以做到这一点。 你现在可以保存FITS图像,并使用任何你已有的绘图工具。 虽然对于纯Python的工作流程来说。罂粟 包是专门为天文学绘图设计的。 下面是我对这张图片所做的,只是作为一个例子。
>>> import aplpy
>>> gc = aplpy.FITSFigure(hdul)
>>> gc.show_grayscale()
INFO: Auto-setting vmin to 2.560e+03 [aplpy.core]
INFO: Auto-setting vmax to 1.513e+04 [aplpy.core]
>>> gc.show_markers(object_coords.ra, object_coords.dec, edgecolor='red',
... marker='s', s=50**2)
>>> gc.save('plot.png')
结果: