我正在尝试使用 Astropy's Cutout2D 测试presented procedure。我的目标是使用RA和DEC为地面真实目录中的每个来源提取一个.png图像。
文件头:
>>
我使用从文档复制的这个小脚本:
<<
我明白了:
>>
我不知道为什么会这样以及如何解决。
我也尝试过重塑:
SIMPLE = T /
BITPIX = -32 /
NAXIS = 4 /
NAXIS1 = 30000 /
NAXIS2 = 30000 /
NAXIS3 = 1 /
NAXIS4 = 1 /
EXTEND = T /
BSCALE = 1.00000000000E+00 /
BZERO = 0.00000000000E+00 /
BLANK = -1 /
BUNIT = 'JY/BEAM ' /
DATE-OBS= '2000-01-01T12:00:00.0' /
CRPIX1 = 1.63840000000E+04 /
CDELT1 = -6.71387000000E-05 /
CRVAL1 = 0.00000000000E+00 /
CTYPE1 = 'RA---SIN' /
CRPIX2 = 1.63840000000E+04 /
CDELT2 = 6.71387000000E-05 /
CRVAL2 = -3.00000000000E+01 /
CTYPE2 = 'DEC--SIN' /
CRPIX3 = 1.00000000000E+00 /
CDELT3 = 4.20000000000E+08 /
CRVAL3 = 1.40000000000E+09 /
CTYPE3 = 'FREQ ' /
CRPIX4 = 1.00000000000E+00 /
CDELT4 = 1.00000000000E+00 /
CRVAL4 = 1.00000000000E+00 /
CTYPE4 = 'STOKES ' /
...
还有
hdu = fits.open(file)[0]
data=hdu.data
w = WCS(file)
position = SkyCoord(24.17*u.deg, 15.78*u.deg,frame='fk5',equinox='J2000.0'
size = u.Quantity((10,10), u.arcsec)
cutout = Cutout2D(data, posit
ion, size, fill_value=np.nan, wcs=w)
但随后我对两者的理解都相同:
Traceback (most recent call last):
File "###/Cutoff_patches.py", line 113, in <module>
cutout = Cutout2D(data, position, size, wcs=w)
File "##_venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 686, in __init__
return_position=True)
File "##_venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 211, in extract_array
shape, position, mode=mode)
File "##_venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 91, in overlap_slices
raise ValueError('"large_array_shape" and "small_array_shape" must '
ValueError: "large_array_shape" and "small_array_shape" must have the same number of dimensions.
答案 0 :(得分:0)
您可以将FITS文件缩小为2D图像,然后 Cutout2D 将更容易工作:
hdu = fits.open(file)[0]
data = hdu.data[0,0,:,:] # checkout image data
# modify header keywords
hdu.header['NAXIS'] = 2
hdu.header['WCSAXES']=2
# delete all keywords of additional axis
del hdu.header['NAXIS3']
del hdu.header['NAXIS4']
del hdu.header['CRPIX3']
...
w = WCS(hdu.header)
position = SkyCoord(24.17*u.deg, 15.78*u.deg,frame='fk5',equinox='J2000.0')
size = u.Quantity((10,10), u.arcsec)
cutout = Cutout2D(data, position, size, fill_value=np.nan, wcs=w)