python-3.x - 如何使用真实坐标绘制 FITS 文件中的图像?

标签 python-3.x astropy fits

astropy documentation有一个关于如何从 FITS 文件绘制图像的示例。结果图上的轴对应于像素或数据点的数量。我希望轴指示银河坐标。

请注意,我的 FITS 文件的 header 指示了有关图像在天空上的位置的所有信息。如何让绘图显示真实坐标而不是像素数?

最佳答案

WCS framework provided by astropy可用于使用世界坐标进行绘图。

from astropy.wcs import WCS
from astropy.io import fits
from astropy.utils.data import get_pkg_data_filename
import matplotlib.pyplot as plt

image_file = get_pkg_data_filename('tutorials/FITS-images/HorseHead.fits')
hdu = fits.open(image_file)[0]
wcs = WCS(hdu.header)

plt.subplot(projection=wcs) 
plt.imshow(hdu.data, origin='lower') 
plt.grid(color='white', ls='solid')
plt.show()

关于python-3.x - 如何使用真实坐标绘制 FITS 文件中的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54578569/

相关文章:

python - lxml 解析原子 - 空结果?

python - 在 astropy.modeling 中绑定(bind)参数

astropy - 如何使用 Astropy ascii 表阅读器跳过行尾注释?

python - 使用 Astropy 将 3d Numpy 数组写入 FITS 文件

python - 在 python 中打开并显示适合图像

python - 从 FITS 文件头创建 Ascii 表

node.js - wifi 掉线时本地套接字绑定(bind)失败

python - 在用户定义的类中实现 GenericAlias (Python)

python - 如何绘制四个带有双 y 轴图的子图

python - 如何将像素坐标与 imshow() 命令一起使用,以便从 python 中适合图像的特定部分生成图像?