Skip to content

Commit

Permalink
DIALS 3.15.2
Browse files Browse the repository at this point in the history
Features
--------

- Update Format handling to reflect move of Eiger detector from PETRA P14 to P13.
  • Loading branch information
DiamondLightSource-build-server committed Aug 4, 2023
2 parents 40f1c9b + 6256b65 commit ba8e15c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.15.1
current_version = 3.15.2
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<release>[a-z]+)?(?P<patch>\d+)?
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
DIALS 3.15.2 (2023-08-04)
=========================

Features
--------

- Update Format handling to reflect move of Eiger detector from PETRA P14 to P13. (`#626 <https://github.com/cctbx/dxtbx/issues/626>`_)


DIALS 3.15.1 (2023-06-29)
=========================

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Static version number which is updated by bump2version
# Do not change this manually - use 'bump2version <major/minor/patch/release>'
__version_tag__ = "3.15.1"
__version_tag__ = "3.15.2"

setup_kwargs = {
"name": "dxtbx",
Expand Down
15 changes: 15 additions & 0 deletions src/dxtbx/format/FormatCBFMini.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from __future__ import annotations

import binascii
import datetime
import os
import pathlib
import sys
Expand Down Expand Up @@ -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."""
Expand Down
13 changes: 12 additions & 1 deletion src/dxtbx/format/FormatCBFMiniEigerPetraP14.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from __future__ import annotations

import datetime
import sys

from dxtbx.format.FormatCBFMiniEiger import FormatCBFMiniEiger
Expand All @@ -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

Expand Down

0 comments on commit ba8e15c

Please sign in to comment.