Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormatNXmxEigerFilewriter swap incorrect-looking image dimensions. #793

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/793.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``FormatNXmxEigerFilewriter``: rather than relying on a firmware version check to decide whether to swap image dimensions (which can break), do this by a lookup table.
24 changes: 15 additions & 9 deletions src/dxtbx/format/FormatNXmxEigerFilewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import h5py
import nxmx
from packaging import version

from scitbx.array_family import flex

Expand Down Expand Up @@ -49,15 +48,22 @@ def _get_nxmx(self, fh: h5py.File):
if nxdetector.underload_value is None:
nxdetector.underload_value = 0

# 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:
# Some firmware versions had the detector dimensions swapped. The correct way
# is the number of pixels along the slow axis first, then the fast axis. Here
# swap any that look like they are (fast, slow) instead.
swapped_dims = {
(4148, 4362),
(3108, 3262),
(2068, 2162),
(1028, 1062),
(4148, 512),
(2068, 512),
(1028, 512),
}
for module in nxdetector.modules:
if (tuple(module.data_size)) in swapped_dims:
module.data_size = module.data_size[::-1]

return nxmx_obj

def get_raw_data(self, index):
Expand Down
Loading