我想用.fits文件(天文图像)绘制图,我遇到了两个问题,我认为它们是相关的:
使用astropy的这个例子:
from matplotlib import pyplot as plt
from astropy.io import fits
from astropy.wcs import WCS
from astropy.utils.data import download_file
fits_file = 'http://data.astropy.org/tutorials/FITS-images/HorseHead.fits'
image_file = download_file(fits_file, cache=True)
hdu = fits.open(image_file)[0]
wcs = WCS(hdu.header)
fig = plt.figure()
fig.add_subplot(111, projection=wcs)
plt.imshow(hdu.data, origin='lower', cmap='cubehelix')
plt.xlabel('RA')
plt.ylabel('Dec')
plt.show()
我可以生成这个图像:
现在我想用与图像相同的坐标绘制一些点:
^{pr2}$但是,当我这样做时:
我正在绘制像素坐标。此外,图像不再与帧大小匹配(尽管坐标看起来很好)
关于如何处理这些问题有什么建议吗?在
绘制给定的坐标很容易。你所要做的就是应用一个^{} 。在
我复制了您的示例,并添加了注释,其中我更改了一些内容,以及更改的原因。在
结果是:
请注意,如果希望画布仅显示图像的区域,请稍后再次应用限制:
^{pr2}$它给出了:
这里还有一个旁注。AstroPy有一个很好的单位支持,所以不用把arcmins和arcsecs转换成度数,你只需定义“单位”。不过,您仍然需要进行转换:
相关问题 更多 >
编程相关推荐