From f044e739a031f4028a8887da55edd2a8c8730be3 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Fri, 6 May 2022 16:54:16 +0200 Subject: [PATCH] Adapt `counts` to new h5 file format --- pyzebra/h5.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyzebra/h5.py b/pyzebra/h5.py index 392d1ad..3ab9b6d 100644 --- a/pyzebra/h5.py +++ b/pyzebra/h5.py @@ -70,9 +70,12 @@ def read_detector_data(filepath, cami_meta=None): with h5py.File(filepath, "r") as h5f: counts = h5f["/entry1/area_detector2/data"][:].astype(np.float64) - # reshape images (counts) to a correct shape (2006 issue) n, cols, rows = counts.shape - counts = counts.reshape(n, rows, cols) + if "/entry1/experiment_identifier" in h5f: # old format + # reshape images (counts) to a correct shape (2006 issue) + counts = counts.reshape(n, rows, cols) + else: + counts = counts.swapaxes(1, 2) scan = {"counts": counts, "counts_err": np.sqrt(np.maximum(counts, 1))} scan["original_filename"] = filepath