From c5ac6346bc90627b36f50acfbca0e0c5fb1bb563 Mon Sep 17 00:00:00 2001 From: Wim Pomp Date: Mon, 17 Oct 2022 20:16:28 +0200 Subject: [PATCH] - make it work on Linux again too --- README.md | 2 +- issfile/__init__.py | 9 +++++---- setup.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 17d06bf..faebfb6 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Metadata is also saved in the tiffs in the description tag. with IssFile(file) as iss: image = iss.get_image(c=1, t=5) - carpet = iss.get_carpet(c=1, t=5) + carpet, (time, x, y, z) = iss.get_carpet(c=1, t=5) plt.figure() plt.imshow(image) diff --git a/issfile/__init__.py b/issfile/__init__.py index dc34247..82d1118 100644 --- a/issfile/__init__.py +++ b/issfile/__init__.py @@ -17,7 +17,7 @@ class TiffFile(IJTiffFile): if 'processes' not in kwargs: kwargs['processes'] = 'all' super().__init__(*args, **kwargs) - self.iss = iss + self.iss = pickle.dumps(iss) # force iss to be transferred to other processes in pickled state self.bar = bar def __getstate__(self): @@ -27,6 +27,8 @@ class TiffFile(IJTiffFile): self.bar.update() def compress_frame(self, frame): + if isinstance(self.iss, bytes): + self.iss = pickle.loads(self.iss) if frame[0]: frame, metadata = self.iss.get_carpet(*frame[1:]) ifd, offsets = super().compress_frame(frame.astype(self.dtype)) @@ -89,10 +91,9 @@ class IssFile: def get_image(self, c, t): assert c < self.shape[2] and t < self.shape[3], \ f'carpet {c = }, {t = } not in shape {self.shape[2]}, {self.shape[3]}' - frame = c + 2 * t * self.shape[2] + frame = int(c) + 2 * int(t) * self.shape[2] frame_bytes = self.shape[0] * self.shape[1] * self.delta data = [] - # TODO: RuntimeWarning: overflow encountered in long_scalars for big files in next line for address in range(frame * frame_bytes, (frame + 1) * frame_bytes, self.delta): self.data.seek(address) data.append(unpack('