[Numpy-discussion] Strange problem with h5py and numpy
korn at freisingnet.de
Mon Dec 27 12:58:24 EST 2010
I have a strange problem with h5py or with numpy.
I try to read a bunch of hdf files in a loop. The problem is that I get
an error at the second file because the file handle is of type <Closed
It seems the file is opened and instantaneous closed again. Meanwhile I
found the root of the evil: First I read the contents of a dataset to
the numpy array tmp. In the next step I paste this array into a bigger
one "alb_c1_tmp". The shape of tmp is (651, 1701). Everything works well
if I omit the pasting.
alb_c1_tmp = zeros([3712,3712])
c1_eu = File(filename_ch1_eu,mode='r')
tmp = c1_eu['AL-SP-BH'][:]
#Source of the evil
alb_c1_tmp[ 3012:3663, 462:2163 ] = tmp
The code as above crashes always when the second file is read. However
originally I had the boundaries of alb_c1_tmp set dynamically from
attributes of the hdf files (they are identical for all files), this
code crashed after a random number of files.
Here´s the line that caused the randomly delayed crashes:
alb_c1_tmp[ 1855 + c1_eu.attrs['LOFF'] - c1_eu.attrs['NL'] : 1855 +
c1_eu.attrs['LOFF'] , 1855 + c1_eu.attrs['COFF'] - c1_eu.attrs['NC'] :
1855 + c1_eu.attrs['COFF'] ] = tmp
Is it a bug or did I something wrong?
Python 2.6.5 (r265:79063, Oct 28 2010, 20:56:56)
Numpy-Version is probably 1.5.0
Happens under 32bit as well as under 64bit SuSE-release 11.3
More information about the NumPy-Discussion