From 9fe84e83551670df429fce8c9d03d2f4c1c0e27f Mon Sep 17 00:00:00 2001 From: David Waterman Date: Thu, 13 Feb 2025 14:54:17 +0000 Subject: [PATCH 1/6] =?UTF-8?q?Add=20FormatROD=5FArc=20for=20the=20HyPix-A?= =?UTF-8?q?rc=20100=C2=B0=20and=20HyPix-Arc=20150=C2=B0=20detectors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dxtbx/format/FormatROD.py | 152 ++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/src/dxtbx/format/FormatROD.py b/src/dxtbx/format/FormatROD.py index 4bf951fd0..da448056f 100644 --- a/src/dxtbx/format/FormatROD.py +++ b/src/dxtbx/format/FormatROD.py @@ -20,12 +20,14 @@ import numpy as np +from scitbx import matrix from scitbx.array_family import flex from scitbx.math import r3_rotation_axis_and_angle_as_matrix from dxtbx.ext import uncompress_rod_TY6 from dxtbx.format.Format import Format from dxtbx.model.beam import Probe +from dxtbx.model.detector import Detector class FormatROD(Format): @@ -482,6 +484,156 @@ def decode_TY6_oneline(self, linedata, w): return ret +class FormatROD_Arc(FormatROD): + @staticmethod + def understand(image_file): + offset = 256 + general_nbytes = 512 + with FormatROD_Arc.open_file(image_file, "rb") as f: + f.seek(offset + general_nbytes + 548) + detector_type = struct.unpack(" Date: Thu, 13 Feb 2025 14:55:19 +0000 Subject: [PATCH 2/6] Fix warnings from multiplying arrays where some elements are Inf --- src/dxtbx/format/FormatROD.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dxtbx/format/FormatROD.py b/src/dxtbx/format/FormatROD.py index da448056f..bbf7e5148 100644 --- a/src/dxtbx/format/FormatROD.py +++ b/src/dxtbx/format/FormatROD.py @@ -203,13 +203,13 @@ def _start(self): self._gonio_start_angles = ( np.array(self._bin_header["start_angles_steps"]) - * np.array(self._bin_header["step_to_rad"]) + * np.nan_to_num(np.array(self._bin_header["step_to_rad"])) / np.pi * 180 ) self._gonio_end_angles = ( np.array(self._bin_header["end_angles_steps"]) - * np.array(self._bin_header["step_to_rad"]) + * np.nan_to_num(np.array(self._bin_header["step_to_rad"])) / np.pi * 180 ) From a6f4e518895d9a1aac012ff605b6c6e4d172a6df Mon Sep 17 00:00:00 2001 From: David Waterman Date: Thu, 13 Feb 2025 14:59:22 +0000 Subject: [PATCH 3/6] news --- newsfragments/xxx.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/xxx.feature diff --git a/newsfragments/xxx.feature b/newsfragments/xxx.feature new file mode 100644 index 000000000..243de412e --- /dev/null +++ b/newsfragments/xxx.feature @@ -0,0 +1 @@ +``FormatROD_Arc``: Support for Rigaku HyPix-Arc 100° and 150° curved detectors From 9d9b4523366060b72e3cf05357c4ad976fd54f68 Mon Sep 17 00:00:00 2001 From: David Waterman Date: Fri, 14 Feb 2025 09:54:49 +0000 Subject: [PATCH 4/6] Add a 2D projection for correct display in the image viewer --- src/dxtbx/format/FormatROD.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dxtbx/format/FormatROD.py b/src/dxtbx/format/FormatROD.py index bbf7e5148..5725694e4 100644 --- a/src/dxtbx/format/FormatROD.py +++ b/src/dxtbx/format/FormatROD.py @@ -579,6 +579,7 @@ def _detector(self): p.set_trusted_range((0, self._bin_header["overflow_threshold"])) p.set_pixel_size((pixel_size_x, pixel_size_y)) p.set_local_frame(fast.elems, slow.elems, origin_panel.elems) + p.set_projection_2d((-1, 0, 0, -1), (0, pd["xmin"])) self.coords[panel_name] = (xmin, ymin, xmax, ymax) # Now rotate the external panels. For the time being do the rotation around From 16dd7d406a8ed90e8a4c5978808ebd11c22e40eb Mon Sep 17 00:00:00 2001 From: DiamondLightSource-build-server Date: Fri, 14 Feb 2025 10:03:53 +0000 Subject: [PATCH 5/6] Rename newsfragments/xxx.feature to newsfragments/787.feature --- newsfragments/{xxx.feature => 787.feature} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename newsfragments/{xxx.feature => 787.feature} (100%) diff --git a/newsfragments/xxx.feature b/newsfragments/787.feature similarity index 100% rename from newsfragments/xxx.feature rename to newsfragments/787.feature From 2de24bf76a27735a805d4a671f1811ec0df82eac Mon Sep 17 00:00:00 2001 From: David Waterman Date: Wed, 19 Feb 2025 15:57:43 +0000 Subject: [PATCH 6/6] Have found the place in the ver 4 header where these camera constants are stored, so read from the header instead of hardcoding --- src/dxtbx/format/FormatROD.py | 61 +++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/src/dxtbx/format/FormatROD.py b/src/dxtbx/format/FormatROD.py index 5725694e4..7b5a6e8af 100644 --- a/src/dxtbx/format/FormatROD.py +++ b/src/dxtbx/format/FormatROD.py @@ -496,6 +496,45 @@ def understand(image_file): return True return False + @staticmethod + def _read_binary_header( + image_file, + offset=256, + nbytes=5120, + general_nbytes=512, + special_nbytes=768, + km4gonio_nbytes=1024, + statistics_nbytes=512, + history_nbytes=2048, + ): + bh = FormatROD._read_binary_header( + image_file, + offset, + nbytes, + general_nbytes, + special_nbytes, + km4gonio_nbytes, + statistics_nbytes, + history_nbytes, + ) + + # Seek to the end of the standard version 3 header and into the + # extra camera parameters section + with FormatROD_Arc.open_file(image_file, "rb") as f: + f.seek(nbytes + 268) + ix, iy, nx, ny, gapx, gapy = struct.unpack("