Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

DIALS 3.8.3 #124

Merged
merged 1 commit into from
Feb 22, 2022
Merged
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/478.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FormatNXmx: Open nexus files in SWMR mode.
6 changes: 3 additions & 3 deletions src/dxtbx/format/FormatNXmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FormatNXmx(FormatNexus):

@staticmethod
def understand(image_file):
with h5py.File(image_file, "r") as handle:
with h5py.File(image_file, "r", swmr=True) as handle:
name = dxtbx.nexus.nxmx.h5str(FormatNXmx.get_instrument_name(handle))
# Temporarily restrict this to I19-2 while developing
if name and "I19-2" in name:
Expand All @@ -24,7 +24,7 @@ def __init__(self, image_file, **kwargs):
def _start(self):
self._static_mask = None

with h5py.File(self._image_file, "r") as fh:
with h5py.File(self._image_file, "r", swmr=True) as fh:
nxmx = dxtbx.nexus.nxmx.NXmx(fh)
nxsample = nxmx.entries[0].samples[0]
nxinstrument = nxmx.entries[0].instruments[0]
Expand Down Expand Up @@ -59,7 +59,7 @@ def get_static_mask(self, index=None, goniometer=None):

def get_raw_data(self, index):
if self._cached_file_handle is None:
self._cached_file_handle = h5py.File(self._image_file, "r")
self._cached_file_handle = h5py.File(self._image_file, "r", swmr=True)

nxmx = dxtbx.nexus.nxmx.NXmx(self._cached_file_handle)
nxdata = nxmx.entries[0].data[0]
Expand Down