我正在尝试将FITS文件的坐标系从其原始的赤道坐标系更改为银河坐标(以度为单位),以便使用这些坐标操作生成的FITS图像。
为此,我需要提取一个包含每个像素赤道位置的数组,以便将它们转换为所需的银河系坐标。这就是我的知识有限的地方,似乎找不出如何提取该数组。
最后,我想以如下方式根据纬度对图像进行切片:
import pyfits
f = pyfits.open("im1.fits")
h, data = f[0].header, f[0].data
#Here I would include the transformation from Equatorial to Galactic of
the position array doing something like:
coord = SkyCoord(ra, dec, frame=Galactic, unit='deg')
#This would do the slicing
from astropy.nddata import Cutout2D
from astropy import units as u
from astropy import coordinates
#Given a longitude and latitude
size = [mylon, mylat]
cut = Cutout2D(f, center, size, wcs=wcs)发布于 2017-01-27 09:14:47
您很可能希望重新整理数据,而不是变换所有位置;如果数据位于赤道网格上,则不可能沿银河系坐标对其进行切片。对于这项工作,reproject是最好的基于astropy的工具。您需要设置一个Galactic头文件,并重新投影到该文件:
import reproject
galheader = fits.Header.fromtextfile('gal.hdr')
myfitsfile = fits.open('im1.fits')
newim, weights = reproject.reproject_interp(myfitsfile, galheader)您也可以使用reproject.reproject_exact,它使用不同的重新投影算法。
https://stackoverflow.com/questions/41738042
复制相似问题