From 8f65b0f46d0a118ebc1a341078d2ff51c58fbdb8 Mon Sep 17 00:00:00 2001 From: stevehenke <91344068+stevehenke@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:21:49 -0500 Subject: [PATCH] implement (#94) --- ptychodus/plugins/lclsFileReaders.py | 14 ++++---------- pyproject.toml | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ptychodus/plugins/lclsFileReaders.py b/ptychodus/plugins/lclsFileReaders.py index cca43168..66da3a6e 100644 --- a/ptychodus/plugins/lclsFileReaders.py +++ b/ptychodus/plugins/lclsFileReaders.py @@ -66,6 +66,7 @@ def __init__(self) -> None: def read(self, filePath: Path) -> DiffractionDataset: dataset = SimpleDiffractionDataset.createNullInstance(filePath) + metadata = DiffractionMetadata.createNullInstance(filePath) try: with tables.open_file(filePath, mode='r') as h5File: @@ -83,16 +84,6 @@ def read(self, filePath: Path) -> DiffractionDataset: filePath=filePath, dataPath=self._dataPath, ) - - with h5py.File(filePath, 'r') as h5File: - metadata = DiffractionMetadata.createNullInstance(filePath) - contentsTree = self._treeBuilder.build(h5File) - - try: - data = h5File.get_node(self._dataPath) - except KeyError: - logger.debug('Unable to find data.') - else: metadata = DiffractionMetadata( numberOfPatternsPerArray=numberOfPatterns, numberOfPatternsTotal=numberOfPatterns, @@ -101,6 +92,9 @@ def read(self, filePath: Path) -> DiffractionDataset: filePath=filePath, ) + with h5py.File(filePath, 'r') as h5File: + contentsTree = self._treeBuilder.build(h5File) + dataset = SimpleDiffractionDataset(metadata, contentsTree, [array]) except OSError: logger.debug(f'Unable to read file \"{filePath}\".') diff --git a/pyproject.toml b/pyproject.toml index 5b325157..1a69c306 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ module = [ "pvaccess", "pvapy.*", "scipy.*", + "tables.*", "tifffile", "tike.*", ]