Skip to content

Commit

Permalink
Merge pull request #1703 from HEXRD/eiger-stream-v1
Browse files Browse the repository at this point in the history
Add support for eiger-stream-v1
  • Loading branch information
psavery authored May 17, 2024
2 parents 64523ed + 8dc6c41 commit e7df698
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions hexrdgui/image_file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,30 @@ def open_file(self, f, options=None):
dset = hdf.select(self.path[1])
ims = imageseries.open(None, 'array', data=dset)
elif ext in self.HDF5_FILE_EXTS:
regular_hdf5 = True
with h5py.File(f, 'r') as data:
dset = data['/'.join(self.path)]
ndim = dset.ndim
if ndim < 3:
# Handle raw two dimesional data
ims = imageseries.open(None, 'array', data=dset[()])

if ndim >= 3:
if data.attrs.get('version') == 'CHESS_EIGER_STREAM_V1':
ims_type = 'eiger-stream-v1'
registry = (
imageseries.load.registry.Registry.adapter_registry
)
if ims_type not in registry:
msg = (
'"dectris-compression" must be installed to load '
'eiger stream files'
)
raise Exception(msg)

ims = imageseries.open(f, 'eiger-stream-v1')
regular_hdf5 = False
else:
dset = data['/'.join(self.path)]
ndim = dset.ndim
if ndim < 3:
# Handle raw two dimesional data
ims = imageseries.open(None, 'array', data=dset[()])

if regular_hdf5 and ndim >= 3:
ims = imageseries.open(
f, 'hdf5', path=self.path[0], dataname=self.path[1])
elif ext == '.npz':
Expand Down Expand Up @@ -160,6 +176,11 @@ def hdf_path_exists(self, f):
return False

def hdf5_path_exists(self, f):
# If it is a special HDF5 file, just return True
with h5py.File(f, 'r') as rf:
if rf.attrs.get('version') == 'CHESS_EIGER_STREAM_V1':
return True

all_paths = []
if HexrdConfig().hdf5_path:
all_paths.append(HexrdConfig().hdf5_path)
Expand Down

0 comments on commit e7df698

Please sign in to comment.