From 00acdfc26164a54ee76b20a1ffeeb7fb72c5ae99 Mon Sep 17 00:00:00 2001 From: Graeme Winter Date: Fri, 19 Jan 2024 13:43:33 +0000 Subject: [PATCH] Check firmware version Much more sensible fix suggested by @biochem-fan - checks firmware version using packaging.version as a sane comparitor --- src/dxtbx/format/FormatNXmxEigerFilewriter.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/dxtbx/format/FormatNXmxEigerFilewriter.py b/src/dxtbx/format/FormatNXmxEigerFilewriter.py index 5b3252221..df104f06c 100644 --- a/src/dxtbx/format/FormatNXmxEigerFilewriter.py +++ b/src/dxtbx/format/FormatNXmxEigerFilewriter.py @@ -4,6 +4,7 @@ import h5py import nxmx +from packaging import version from scitbx.array_family import flex @@ -14,7 +15,6 @@ class FormatNXmxEigerFilewriter(FormatNXmx): - _cached_file_handle = None @staticmethod @@ -49,15 +49,14 @@ def _get_nxmx(self, fh: h5py.File): if nxdetector.underload_value is None: nxdetector.underload_value = 0 - # data_size is reversed - we should probably be more specific in when - # we do this, i.e. check data_size is in a list of known reversed - # values - known_safe = [ - (1082, 1035), - (4150, 4371), - ] - for module in nxdetector.modules: - if not tuple(module.data_size) in known_safe: + # older firmware versions had the detector dimensions inverted + fw_version_string = ( + fh["/entry/instrument/detector/detectorSpecific/eiger_fw_version"][()] + .decode() + .replace("release-", "") + ) + if version.parse("2022.1.2") < version.parse(fw_version_string): + for module in nxdetector.modules: module.data_size = module.data_size[::-1] return nxmx_obj