Strange problem with h5py and numpy

Hi, 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 HDF5 file> 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') print c1_eu tmp = c1_eu['AL-SP-BH'][:] #Source of the evil alb_c1_tmp[ 3012:3663, 462:2163 ] = tmp c1_eu.close() 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 h5py 1.3.0 Happens under 32bit as well as under 64bit SuSE-release 11.3 Kind regards! Johannes

On Mon, Dec 27, 2010 at 12:58 PM, Johannes Korn <korn@freisingnet.de> wrote:
Hi,
I have a strange problem with h5py or with numpy.
I think this question belongs on the h5py mailing list.
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 HDF5 file>
The code you posted only involves one file.

On 28.12.2010 14:46, Darren Dale wrote::
On Mon, Dec 27, 2010 at 12:58 PM, Johannes Korn<korn@freisingnet.de> wrote:
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 HDF5 file>
The code you posted only involves one file.
The code I posted is part of the inside of a loop over the files. The filename changes of course and the files are there. If I try to open a non existing file the error message is different.

On 28.12.2010 15:13, Johannes Korn wrote::
On 28.12.2010 14:46, Darren Dale wrote::
On Mon, Dec 27, 2010 at 12:58 PM, Johannes Korn<korn@freisingnet.de> wrote:
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 HDF5 file>
The code you posted only involves one file.
The code I posted is part of the inside of a loop over the files. The filename changes of course and the files are there. If I try to open a non existing file the error message is different.
Found the solution: incompatibility between HDF 1.8.5 and h5py 1.3.0. Seems that upgrade to h5py 1.3.1 beta fixed the problem
participants (2)
-
Darren Dale
-
Johannes Korn