从FITS

时间:2017-01-19 09:22:06

标签: python astropy fits libwcs

我正在尝试将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)

1 个答案:

答案 0 :(得分:0)

您最有可能想要重新调整数据而不是转换所有位置;如果数据位于赤道网格上,则无法沿星系坐标对其进行切片。 reproject是这项工作中最好的基于星座的工具。您需要设置一个Galactic标题并重新投影到该标题:

import reproject
galheader = fits.Header.fromtextfile('gal.hdr')
myfitsfile = fits.open('im1.fits')
newim, weights = reproject.reproject_interp(myfitsfile, galheader)

您还可以使用reproject.reproject_exact,它使用不同的重投影算法。

相关问题