python读取fits第三方库_python-astropy.io.fits从具有多个HDU的大型fits文件中读取行

本文描述了如何使用Python的astropy.io.fits库从大型FITS文件中读取具有多个HDU的数据,特别是针对50GB大小的文件,其中包含大量对象和时间戳。通过memmap和只读取所需对象的方法,解决了内存不足的问题。
摘要由CSDN通过智能技术生成

我有一个约50GB的fits文件,其中包含多个HDU,它们都具有相同的格式:一个带有1E5对象和1E6时间戳的(1E5 x 1E6)数组. HDU描述了不同的物理属性,例如磁通,RA,DEC等.我只想从每个HDU中读取5个对象(即(5 x 1E6)阵列).

python 2.7,

糟糕的1.0.3,

linux x86_64

到目前为止,我尝试了很多发现的建议,但是没有任何效果.我最好的方法仍然是:

#the five objects I want to read out

obj_list = ['Star1','Star15','Star700','Star2000','Star5000']

dic = {}

with fits.open(fname, memmap=True, do_not_scale_image_data=True) as hdulist:

# There is a special HDU 'OBJECTS' which is an (1E5 x 1) array and contains the info which index in the fits file corresponds to which object.

# First, get the indices of the rows that describe the objects in the fits file (not necessarily in order!)

ind_objs = np.in1d(hdulist['OBJECTS'].data, obj_list, assume_unique=True).nonzero()[0] #indices of the candidates

# Second, r

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值