如何使用真实坐标绘制 FITS 文件中的图像?
How to plot an image from a FITS file with real coordinates?
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()
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()