Skip to content

Commit 3a3529d

Browse files
authored
Merge pull request #1122 from silx-kit/vasole-patch-2
[IO] Improve image stack handling
2 parents 88ff9f4 + b407a82 commit 3a3529d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/PyMca5/PyMcaIO/HDF5Stack1D.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ def loadFileList(self, filelist, selection, scanlist=None):
728728
xpath = scan + xSelection
729729
xDataset = hdf[xpath][()]
730730
xDatasetList.append(xDataset)
731+
try:
732+
yDataset = hdf[path][()]
733+
IN_MEMORY = True
734+
except (MemoryError, ValueError):
735+
_logger.info("Dynamic loading of images")
736+
yDataset = hdf[path]
737+
IN_MEMORY = False
731738
if mSelection is not None:
732739
nMonitorData = mDataset.size
733740
case = -1
@@ -750,7 +757,11 @@ def loadFileList(self, filelist, selection, scanlist=None):
750757
for i in range(yDataset.shape[0]):
751758
self.data[i] += yDataset[i] / mDataset
752759
else:
753-
self.data += yDataset
760+
if IN_MEMORY:
761+
self.data += yDataset
762+
else:
763+
for i in range(yDataset.shape[0]):
764+
self.data[i:i+1] += yDataset[i:i+1]
754765
else:
755766
self.info["McaIndex"] = mcaIndex
756767
if _time:

0 commit comments

Comments
 (0)