From f9013668291ff4bd8d1725178275444d72ac2fd1 Mon Sep 17 00:00:00 2001 From: Graeme Winter Date: Tue, 13 Feb 2024 12:01:49 +0000 Subject: [PATCH] Invert rotation axis for negative scans (#694) This complements 39e463e598da05e3d7061ea98a34a81a7a68fecf. Twirling, always twirling. --- newsfragments/694.misc | 1 + src/dxtbx/format/FormatNXmx.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 newsfragments/694.misc diff --git a/newsfragments/694.misc b/newsfragments/694.misc new file mode 100644 index 000000000..fe969bda4 --- /dev/null +++ b/newsfragments/694.misc @@ -0,0 +1 @@ +NXmx: if reversed, reverse rotation axis. This is part 2 of previous commit. diff --git a/src/dxtbx/format/FormatNXmx.py b/src/dxtbx/format/FormatNXmx.py index abbca0b50..55b5879a5 100644 --- a/src/dxtbx/format/FormatNXmx.py +++ b/src/dxtbx/format/FormatNXmx.py @@ -99,11 +99,16 @@ def _start(self): scan = self._scan_model oscillation = scan.get_oscillation() - # FIXME this really should not be correct but it works in this one - # weird case if oscillation[1] < 0: + # invert the scan parameters so that the attitude of roation is positive self._scan_model.set_oscillation((-oscillation[0], -oscillation[1])) + # invert the axis direction so that the universe is aligned + axes = self._goniometer_model.get_axes() + axis = self._goniometer_model.get_scan_axis() + axes[axis] = -1 * axes[axis][0], -1 * axes[axis][1], -1 * axes[axis][2] + self._goniometer_model.set_axes(axes) + def _get_nxmx(self, fh: h5py.File): return nxmx.NXmx(fh)