-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #580 from kif/578_edf_fast
Fix `fast_read_data` when reading the last line
- Loading branch information
Showing
4 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ | |
__contact__ = "[email protected]" | ||
__license__ = "MIT" | ||
__copyright__ = "ESRF" | ||
__date__ = "01/06/2022" | ||
__date__ = "20/08/2024" | ||
|
||
import os | ||
import re | ||
|
@@ -1339,6 +1339,8 @@ def fast_read_roi(self, filename, coords=None): | |
Method reading Region of Interest of another file based on metadata available in current EdfImage. | ||
The aim is performances, ... but only supports uncompressed files. | ||
:param filename: name of another file with the same structure. | ||
:paran coords: 2 tuple of slices (RECOMMANDED) or a 4 tuple (NOT RECOMMANDED, cryptic fabian convention) | ||
:return: ROI-data from another file using positions from current EdfImage | ||
:rtype: numpy 2darray | ||
""" | ||
|
@@ -1365,6 +1367,9 @@ def fast_read_roi(self, filename, coords=None): | |
with open(filename, "rb")as f: | ||
f.seek(start) | ||
raw = f.read(size) | ||
if len(raw)<size: | ||
# Pad with zero until the right size | ||
raw+=b"\x00"*(size-len(raw)) | ||
try: | ||
data = numpy.frombuffer(raw, dtype=self.bytecode).copy() | ||
data.shape = -1, d1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ | |
__contact__ = "[email protected]" | ||
__license__ = "MIT" | ||
__copyright__ = "ESRF" | ||
__date__ = "04/05/2021" | ||
__date__ = "20/08/2024" | ||
|
||
import os | ||
import logging | ||
|
@@ -169,6 +169,7 @@ def make_slice(self, coords): | |
the latter are immutable, meaning the roi can be cached | ||
""" | ||
assert len(coords) == 4 | ||
coords = list(coords) | ||
if len(coords) == 4: | ||
# fabian edfimage preference | ||
if coords[0] > coords[2]: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters