Skip to content

Problem with data reading h5py

Ok, when we use blissenv on max ID10 computer:

everything works like this and we can read datasets:

In [1]: import h5py
In [2]: import os
In [3]: path1=r'/data/visitor/sc5146/id10/A1_MgCl2_10nM_sample1/A1_MgCl2_10nM_sample1_0001/
                 scan0004/mpx_cdte_22_eh1_0000.h5'
   ...:
   ...: path2=r'/data/id10b/inhouse/2021_04/blc12921/id10/eh1_exp_2021_04_28_alignment/
                 eh1_exp_2021_04_28_alignment_0001/scan0017/mpx_si_51_0000.h5'
   ...:
   ...: with h5py.File(os.path.join(path1),mode='r') as F:
   ...:     image1=F['entry_0000']['instrument']['mpx_cdte_22_eh1']['data'][()]
   ...:
   ...: with h5py.File(os.path.join(path2),mode='r') as F:
   ...:     image2=F['entry_0000']['instrument']['mpx_si_51']['data'][()]
   ...:

Now we do this same on anaconda installed on beamline computer with windows:

import h5py
import os

path1=r'Y:\sc5146\id10\A1_MgCl2_10nM_sample1\A1_MgCl2_10nM_sample1_0001
           \scan0004\mpx_cdte_22_eh1_0000.h5'
path2=r'Z:\inhouse\2021_04\blc12921\id10\eh1_exp_2021_04_28_alignment
           \eh1_exp_2021_04_28_alignment_0001\scan0017\mpx_si_51_0000.h5'

with h5py.File(os.path.join(path1),mode='r') as F:
    image1=F['entry_0000']['instrument']['mpx_cdte_22_eh1']['data'][()]

with h5py.File(os.path.join(path2),mode='r') as F:
    image2=F['entry_0000']['instrument']['mpx_si_51']['data'][()]


Traceback (most recent call last):

  File "<ipython-input-4-3a371234b16d>", line 8, in <module>
    image2=F['entry_0000']['instrument']['mpx_si_51']['data'][()]
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "C:\ProgramData\Anaconda3\lib\site-packages\h5py\_hl\dataset.py", line 573, in __getitem__
    self.id.read(mspace, fspace, arr, mtype, dxpl=self._dxpl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5d.pyx", line 182, in h5py.h5d.DatasetID.read
  File "h5py\_proxy.pyx", line 130, in h5py._proxy.dset_rw
  File "h5py\_proxy.pyx", line 84, in h5py._proxy.H5PY_H5Dread

OSError: Can't read data (can't open directory)

Why we cannot open the second dataset under path2 ????
The structure of the dataset is recognized but the matrix cannot be read:

image2=F['entry_0000']['instrument']['mpx_si_51']['data']

image2
<HDF5 dataset "data": shape (1, 256, 1284), type "<i4">

image2[()]
*** OSError: Can't read data (can't open directory)
Edited by Cyril Guilloud