子集和像素尺度#
可以使用 sub 功能。还有一个 celestial 方便函数,将返回只包含天轴的WCS对象。
利用效用函数可以提取天体图像的像素尺度或非天体图像的像素维数 proj_plane_pixel_scales 和 non_celestial_pixel_scales . 同样,利用效用函数可以提取天体像素区域 proj_plane_pixel_area .
具有正确WCS投影的Matplotlib打印#
这个 WCSAxes 框架以前是一个独立的包,它允许 WCS 用于在Matplotlib中定义投影。可以找到有关使用WCSAxes的更多信息 here .
import warnings
from matplotlib import pyplot as plt
from astropy.io import fits
from astropy.wcs import WCS, FITSFixedWarning
from astropy.utils.data import get_pkg_data_filename
filename = get_pkg_data_filename('tutorials/FITS-images/HorseHead.fits')
hdu = fits.open(filename)[0]
with warnings.catch_warnings():
# Ignore a warning on using DATE-OBS in place of MJD-OBS
warnings.filterwarnings('ignore', message="'datfix' made the change",
category=FITSFixedWarning)
wcs = WCS(hdu.header)
fig, ax = plt.subplots(subplot_kw=dict(projection=wcs))
ax.imshow(hdu.data, origin='lower', cmap='viridis')
ax.set(xlabel='RA', ylabel='Dec')