如何(1)批量选择hdf5文件下的所有数组,然后(2)对这些数组进行计算,最后(3)在另一个hdf5文件中批量创建新数组?
例如:
import numpy
import tables
file = openFile('file1',"r")
array1 = file.root.array1
array1_cal = (array1 <= 1)
newfile.createArray('/','array1_cal',array1_cal)
array2 = file.root.array2
array2_cal = (array2 <= 1)
newfile.createArray('/','array2_cal',array2_cal)我在一个hdf5文件和几个hdf5文件下有100+数组,如何批量处理它们?非常感谢。
发布于 2012-05-10 17:12:48
使用PyTables,您可以使用walkNodes函数递归地遍历节点。下面是一个示例:
# Recursively print all the nodes hanging from '/detector'.
print "Nodes hanging from group '/detector':"
for node in h5file.walkNodes('/detector', classname='EArray'):
data = node[:]
// do some calculation
// store new array in second file 发布于 2012-05-10 16:12:37
使用h5py,这是HDF5的Python接口。h5py允许您使用传统的HDF5和NumPy隐喻来使用Python文件、组和数据集。
请参阅http://code.google.com/p/h5py/和http://alfven.org/wp/hdf5-for-python/
https://stackoverflow.com/questions/10526636
复制相似问题