Skip to content

[JUNGFRAU] [Correct] Fix index location for ROI instrument output

Thomas Kluyver requested to merge jf-roi-inst-index into master

Description

Yohei told me that accessing JUNGFRAU ROI data was broken - doing this resulted in an error:

run = open_run(3495, 7, data='proc')
run['FXE_XAD_JF1M/ROIPROC/JNGFR02:output']['data.roi1.data'].ndarray()
Traceback
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/software/anaconda3/2021.05/lib/python3.8/site-packages/extra_data/file_access.py in get_index(self, source, group)
    314         try:
--> 315             return self._index_cache[(source, group)]
    316         except KeyError:

KeyError: ('FXE_XAD_JF1M/ROIPROC/JNGFR02:output', 'data')

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_199459/308304994.py in <module>
----> 1 run['FXE_XAD_JF1M/ROIPROC/JNGFR02:output']['data.roi1.data'].ndarray()

/software/anaconda3/2021.05/lib/python3.8/site-packages/extra_data/keydata.py in ndarray(self, roi, out)
    227             roi = (roi,)
    228 
--> 229         req_shape = self.shape[:1] + roi_shape(self.entry_shape, roi)
    230 
    231         if out is None:

/software/anaconda3/2021.05/lib/python3.8/site-packages/extra_data/keydata.py in shape(self)
     88         Finding the shape may require getting index data from several files
     89         """
---> 90         return (sum(c.total_count for c in self._data_chunks),) + self.entry_shape
     91 
     92     def select_trains(self, trains):

/software/anaconda3/2021.05/lib/python3.8/site-packages/extra_data/keydata.py in _data_chunks(self)
     56         """An ordered list of chunks containing data"""
     57         if self._cached_chunks is None:
---> 58             self._cached_chunks = sorted(
     59                 self._find_chunks(), key=lambda c: c.train_ids[0]
     60             )

/software/anaconda3/2021.05/lib/python3.8/site-packages/extra_data/keydata.py in _find_chunks(self)
     34                 continue
     35 
---> 36             firsts, counts = file.get_index(self.source, self._key_group)
     37 
     38             # Of trains in this file, which are in selection

/software/anaconda3/2021.05/lib/python3.8/site-packages/extra_data/file_access.py in get_index(self, source, group)
    315             return self._index_cache[(source, group)]
    316         except KeyError:
--> 317             ix = self._read_index(source, group)
    318             self._index_cache[(source, group)] = ix
    319             return ix

/software/anaconda3/2021.05/lib/python3.8/site-packages/extra_data/file_access.py in _read_index(self, source, group)
    325         """
    326         ntrains = len(self.train_ids)
--> 327         ix_group = self.file['/INDEX/{}/{}'.format(source, group)]
    328         firsts = ix_group['first'][:ntrains]
    329         if 'count' in ix_group:

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

/software/anaconda3/2021.05/lib/python3.8/site-packages/h5py/_hl/group.py in __getitem__(self, name)
    303                 raise ValueError("Invalid HDF5 object reference")
    304         elif isinstance(name, (bytes, str)):
--> 305             oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
    306         else:
    307             raise TypeError("Accessing a group is done with bytes or str, "

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5o.pyx in h5py.h5o.open()

KeyError: "Unable to open object (object 'data' doesn't exist)"

I'm hoping we can do this as a hotfix.

How Has This Been Tested?

I ran a new calibration of the same data with the command line, and tried the same thing:

run2 = RunDirectory('/gpfs/exfel/data/scratch/kluyvert/jf-calib-p3495-r7/')
run2['FXE_XAD_JF1M/ROIPROC/JNGFR02:output']['data.roi1.data'].ndarray()

This gave me an array, not an error.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.

Reviewers

@schmidtp @ahmedk

Merge request reports