Python 我怎样才能写出healpix地图?

Python 我怎样才能写出healpix地图?,python,healpy,pyfits,Python,Healpy,Pyfits,我正在尝试使用healpy和以下脚本以HEALPix格式编写FITS文件: import healpy as hp fname = 'COM_CMB_IQU-100-fgsub-sevem_2048_R3.00_full.fits' map1 = hp.read_map(fname, field=[0], nest=True) map2 = hp.read_map(fname, field=[1], nest=True) map3 = hp.read_map(fname, field=[2]

我正在尝试使用
healpy
和以下脚本以HEALPix格式编写FITS文件:

import healpy as hp

fname = 'COM_CMB_IQU-100-fgsub-sevem_2048_R3.00_full.fits'

map1 = hp.read_map(fname, field=[0], nest=True)
map2 = hp.read_map(fname, field=[1], nest=True)
map3 = hp.read_map(fname, field=[2], nest=True)

hp.write_map('tst1.fits', m=[map1, map2, map3], fits_IDL=False, nest=True)
这会引发以下错误:

/usr/lib/python2.7/dist-packages/healpy/fitsfunc.py:151:
PyfitsDeprecationWarning: The new_table function is deprecated as of
version 3.3 and may be removed in a future version.

Use :meth:`BinTableHDU.from_columns` for new BINARY tables or
:meth:`TableHDU.from_columns` for new ASCII tables instead.   tbhdu =
pf.new_table(cols) Traceback (most recent call last):   File
"write_fits.py", line 13, in <module>
    hp.write_map('tst1.fits',m=[map1, map2, map3], fits_IDL= False, nest= True)   File
"/usr/lib/python2.7/dist-packages/healpy/fitsfunc.py", line 153, in
write_map
     tbhdu.header.update('PIXTYPE','HEALPIX','HEALPIX pixelisation')   File "/usr/lib/python2.7/dist-packages/pyfits/header.py", line 1017,
in update
    'value, and comment string.' % idx) ValueError: Header update sequence item #0 is invalid; the item must either be a 2-tuple
containing a keyword and value, or a 3-tuple containing a keyword,
value, and comment string.
/usr/lib/python2.7/dist-packages/healpy/fitsfunc.py:151:
PyFitsDepreactionWarning:新的_表函数从开始就不推荐使用
版本3.3,并可能在将来的版本中删除。
用法:meth:`BinTableHDU.from_columns`用于新的二进制表或
:meth:`TableHDU.from_columns`用于新的ASCII表。tbhdu=
pf.new_table(cols)回溯(最近一次调用last):文件
第13行的“write_fits.py”
hp.write_-map('tst1.fits',m=[map1,map2,map3],fits_-IDL=False,nest=True)文件
“/usr/lib/python2.7/dist packages/healpy/fitsfunc.py”,第153行,in
写地图
tbhdu.header.update('PIXTYPE','HEALPIX','HEALPIX像素化')文件“/usr/lib/python2.7/dist packages/pyfits/header.py”,第1017行,
更新中
“值和注释字符串”。%idx)值错误:标题更新序列项#0无效;该项必须是2元组
包含关键字和值,或包含关键字的三元组,
值和注释字符串。

感谢您的帮助

我无法重现错误,对我来说效果很好(healpy 1.11.0,python 3.6.3)。这可能是由于旧版本的
healpy
造成的吗?回溯显示它正在使用
pyfits
,而
healpy
已经使用
astropy.io.fits
一段时间了。我建议更新
healpy
,摆脱
pyfits
,并安装
astropy