我加载了一个完整的地图
from astropy.io import fits
from astropy.wcs import wcs
mapheader = fits.getheader(MapFile, 0)
mapdata = fits.getdata(MapFile, 0)
w = wcs.WCS(mapheader)
我从中得到一个平方子映射 假设中心在RA,DEC在degrees 这可以很容易地做到使用CutOut2D
from astropy.nddata import Cutout2D
from astropy import coordinates
from astropy import units as u
center = coordinates.SkyCoord(RA*u.deg, DEC*u.deg, frame='fk5')
submap = Cutout2D(mapdata, center, size=16*u.pix, wcs=w)
submapheader = submap.wcs.to_header()
标题的相关区别在于它移动了参考像素“CRPIX”
例如,如果我调整图像的大小,我会进行插值,并从16个像素传递图像 至128像素
from scipy.misc import imresize
newsubmap = imresize(submap.data, (128,128), interp=‘cubic’)
如何更改标题以在newsubmap上获得良好的投影?你知道吗
我试着用参考像素乘以调整大小因子,在这个例子中是128,但不是那么简单
^{} 在本例中,将图像的大小调整为
(128, 128)
。根据你的陈述:我想这是这里的第一个陷阱。您真的确定要将其调整为
(128, 128)
还是要将其“放大”128倍,甚至是1.28
(请注意,imresize使用小数!)你知道吗请确保正确使用
imresize
。你知道吗所以下一步是重塑
WCS
。幸运的是WCS
允许切片,因此如果您知道原始形状和大小调整因子,这是非常容易的。你知道吗假设你有这样一个
WCS
:你可以给它一个步骤:
或者用小于1的步长进行切片以增加:
请注意,
PC
、CD
以及可能的SIP
和其他失真被忽略。你必须手动处理它们。但是CDELT
值将被处理,因此简单的FITS文件将被正确处理。你知道吗注意:我删除了
NAXIS
关键字,因为它们可能会在下一个版本中更改,所以这些关键字无论如何都不可靠。当前不处理这些,在下一版本中,只有当“start、stop和step”为整数或无时,才会处理它们。你知道吗相关问题 更多 >
编程相关推荐