你可以做这种裁剪astropy.io.fits,虽然它不是微不足道的.由于默认astropy.io.fits使用内存映射,它应该能够处理任意大的文件(在一些实际限制内).如果您需要非python解决方案,请查看此处了解有关邮票创建的详细信息.
from astropy.io import fits
from astropy import wcs
f = fits.open('file.fits')
w = wcs.WCS(f[0].header)
newf = fits.PrimaryHDU()
newf.data = f[0].data[100:-100,100:-100]
newf.header = f[0].header
newf.header.update(w[100:-100,100:-100].to_header())
Run Code Online (Sandbox Code Playgroud)
另请参阅此pull请求,该请求实现了一个便利Cutout2D功能,尽管在astropy的已发布版本中尚未提供此功能.它的用法可以在文档中看到,修改为包含WCS:
from astropy.nddata import Cutout2D
position = (49.7, 100.1)
shape = (40, 50)
cutout = Cutout2D(f[0].data, position, shape, wcs=w)
Run Code Online (Sandbox Code Playgroud)
还有更多的例子在这里