查看“Astropy.io.fits”的源代码
←
Astropy.io.fits
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
>>> hdulist = fits.open('input.fits') >>> hdulist.info() ==header== *each element of an HDUList is an HDU object with .header and .data attributes, which can be used to access the header and data portions of the HDU. >>> hdulist[0].header['targname'] *To see the entire header as it appears in the FITS file (with the END card and padding stripped), simply enter the header object by itself, or print(repr(header)): *It’s also possible to view a slice of the header: >>> header[:2] *Another way to either update an existing card or append a new one is to use the Header.set() method: >>> prihdr.set('observer', 'Edwin Hubble') ==fits table 的读与写== *写 from astropy.table import Table t=Table([Bage,fzbin,Age_weight2],names=('Age','z','weights')) t.write('SFH_LMC3_out.fits',format='fits') *读 hdu = fits.open('SFH_LMC3_out.fits') hdu.info() #看看哪些hdu data=hdu[1].data data.columns #看看有那些列 Bage=data. Field('Age') ==fits文件打开过多错误== * [https://docs.astropy.org/en/stable/io/fits/appendix/faq.html#i-am-opening-many-fits-files-in-a-loop-and-getting-oserror-too-many-open-files] * fits.close() * 可能还根系统设置有关 ulimit -a ulimit -n 100000 vim /etc/security/limits.conf * 把python的软限制编程硬限制,参见 [https://bbs.huaweicloud.com/blogs/108323],下面方法貌似也不管用 import resource soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) resource.setrlimit(resource.RLIMIT_NOFILE, (hard, hard)) *lsof -p 进程id > openfiles.log命令,获得当前占用句柄的全部详情进行分析 * 实测这两个效果不好(python 3.8) :*del hdu.data :*hdu = fits.open(fits_name,memmap=False) #打开fits文件数目比较多的情况下 ==fits image读写== n = np.arange(100.0) hdu = fits.PrimaryHDU(n) hdu.writeto('new2.fits') hdu.writeto('new2.fits') *如果超过一个hdu >>> hdul = fits.HDUList([hdu]) >>> hdul.writeto('new1.fits')
返回至“
Astropy.io.fits
”。
导航菜单
个人工具
登录
命名空间
页面
讨论
大陆简体
已展开
已折叠
查看
阅读
查看源代码
查看历史
更多
已展开
已折叠
搜索
导航
首页
社群首页
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息