我正在尝试使用aplpy库提供的“ show_contour”功能在Fits文件中包含X射线图像上叠加包含无线电图像的轮廓。 我的代码很简单。
“ program1”
import aplpy
import astropy.io.fits as fits
import astropy.wcs as wcs
hdul = fits.open('x-ray_image.fits')
fig = aplpy.FITSFigure(hdul[1])
fig.show_contour('radio_image.fits')
我运行program1并发生错误。 “错误消息”
WCS has more than 2 dimensions, so ``slice`` should be set
我看了radio_image.fits的wcs
file_radio = fits.open('radio_image.fits')
w = wcs.WCS(file_radio[0])
print(w)
“投放消息”
Number of WCS axes: 4
CTYPE : 'RA---SIN' 'DEC--SIN' 'FREQ' 'STOKES'
CRVAL : xxx.xxxxxxx yy.yyyyyy f s
CRPIX : 514.0 306.0 1.0 1.0
NAXIS : 1090 634 1 1
x,y,f和s实际上是数字。 我了解radio_image.fits具有三次数据。 所以我修改了program1如下
“ program2”
import aplpy
import astropy.io.fits as fits
import astropy.wcs as wcs
hdul = fits.open('x-ray_image.fits')
fig = aplpy.FITSFigure(hdul[1])
fig.show_contour('radio_image.fits',dimension=[0,1],slices=[f,s])
但是发生同样的错误
WCS has more than 2 dimensions, so ``slice`` should be set
请告诉我如何修复代码。