From 1e5ff314a24e350398ffaa17bc6ff5b954a61ede Mon Sep 17 00:00:00 2001 From: Christian Becke Date: Mon, 31 Jul 2023 10:58:00 +0200 Subject: [PATCH 1/3] Fixes for EMBL beamlines at PETRA (#626) The E-32-0017 Eiger moved to P13 on 2021-5-22, where the goniometer axis no longer needs overriding. Check for that date in the MiniCBF, and check for the serial matching the date range. Co-authored-by: Christian Becke Co-authored-by: Nicholas Devenish --- newsfragments/626.feature | 1 + src/dxtbx/format/FormatCBFMini.py | 15 +++++++++++++++ src/dxtbx/format/FormatCBFMiniEigerPetraP14.py | 13 ++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 newsfragments/626.feature diff --git a/newsfragments/626.feature b/newsfragments/626.feature new file mode 100644 index 000000000..c28cc4293 --- /dev/null +++ b/newsfragments/626.feature @@ -0,0 +1 @@ +Update Format handling to reflect move of Eiger detector from PETRA P14 to P13. diff --git a/src/dxtbx/format/FormatCBFMini.py b/src/dxtbx/format/FormatCBFMini.py index 4561665fd..39060f84a 100644 --- a/src/dxtbx/format/FormatCBFMini.py +++ b/src/dxtbx/format/FormatCBFMini.py @@ -8,6 +8,7 @@ from __future__ import annotations import binascii +import datetime import os import pathlib import sys @@ -73,6 +74,20 @@ def __init__(self, image_file, **kwargs): self._raw_data = None super().__init__(image_file, **kwargs) + @staticmethod + def _get_timestamp_from_raw_header( + header: str | list[str], + ) -> datetime.datetime | None: + """Given a raw header, or lines from, attempt to extract the timestamp field""" + if isinstance(header, str): + header = header.splitlines() + timestamp = None + for record in header: + if len(record[1:].split()) <= 2 and record.count(":") == 2: + timestamp = datetime.datetime.fromisoformat(record[1:].strip()) + break + return timestamp + def _start(self): """Open the image file, read the image header, copy it into a dictionary for future reference.""" diff --git a/src/dxtbx/format/FormatCBFMiniEigerPetraP14.py b/src/dxtbx/format/FormatCBFMiniEigerPetraP14.py index 530948590..36b5cce91 100644 --- a/src/dxtbx/format/FormatCBFMiniEigerPetraP14.py +++ b/src/dxtbx/format/FormatCBFMiniEigerPetraP14.py @@ -3,6 +3,7 @@ from __future__ import annotations +import datetime import sys from dxtbx.format.FormatCBFMiniEiger import FormatCBFMiniEiger @@ -19,11 +20,21 @@ def understand(image_file): header = FormatCBFMiniEiger.get_cbf_header(image_file) + # Valid from 22nd May 2021 + expected_serial = "E-32-0129" + if timestamp := FormatCBFMiniEiger._get_timestamp_from_raw_header(header): + # We have a timestamp. Let's see what detector we should expect + + # Before 22nd May 2021 + if timestamp < datetime.datetime(2021, 5, 22): + expected_serial = "E-32-0107" + + # Find the line recording detector serial, and check for record in header.split("\n"): if ( "# detector" in record.lower() and "eiger" in record.lower() - and "E-32-0107" in record + and expected_serial in record ): return True From 9622125571a83bc8b5e417a4c167a1678531de5f Mon Sep 17 00:00:00 2001 From: DiamondLightSource-build-server Date: Wed, 9 Aug 2023 04:39:21 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Bump=20version:=203.15.1=20=E2=86=92=203.15?= =?UTF-8?q?.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index fed29b1be..0d7b0548a 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 3.15.1 +current_version = 3.15.2 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P[a-z]+)?(?P\d+)? diff --git a/setup.py b/setup.py index 1da76bbec..7c9df5585 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ # Static version number which is updated by bump2version # Do not change this manually - use 'bump2version ' -__version_tag__ = "3.15.1" +__version_tag__ = "3.15.2" setup_kwargs = { "name": "dxtbx", From 35d8d870353d17d294c4cc70cb6afb4c15dea513 Mon Sep 17 00:00:00 2001 From: DiamondLightSource-build-server Date: Wed, 9 Aug 2023 04:39:22 +0100 Subject: [PATCH 3/3] Towncrier for 3.15.2 towncrier --name "DIALS" --version 3.15.2 --- CHANGELOG.rst | 9 +++++++++ newsfragments/626.feature | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) delete mode 100644 newsfragments/626.feature diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 101191acd..2d92ab45a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,12 @@ +DIALS 3.15.2 (2023-08-09) +========================= + +Features +-------- + +- Update Format handling to reflect move of Eiger detector from PETRA P14 to P13. (`#626 `_) + + DIALS 3.15.1 (2023-06-29) ========================= diff --git a/newsfragments/626.feature b/newsfragments/626.feature deleted file mode 100644 index c28cc4293..000000000 --- a/newsfragments/626.feature +++ /dev/null @@ -1 +0,0 @@ -Update Format handling to reflect move of Eiger detector from PETRA P14 to P13.