From cfdfc9878d3916e5372a623d43c8877c23186fd7 Mon Sep 17 00:00:00 2001 From: Patrick Avery Date: Mon, 29 Apr 2024 16:03:26 -0500 Subject: [PATCH] Fix fast powder calibration with subpanels The pick points didn't take into account subpanels... and the beam stop didn't either. Also, we needed to add a check to verify that a detector actually has points. Instruments with many subpanels sometimes do not have points... Signed-off-by: Patrick Avery --- hexrdgui/calibration/auto/powder_runner.py | 8 +++++- hexrdgui/image_canvas.py | 30 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/hexrdgui/calibration/auto/powder_runner.py b/hexrdgui/calibration/auto/powder_runner.py index a462105e0..43cf2f744 100644 --- a/hexrdgui/calibration/auto/powder_runner.py +++ b/hexrdgui/calibration/auto/powder_runner.py @@ -198,7 +198,13 @@ class CalibrationCallbacks(MaterialCalibrationDialogCallbacks): def data_xys(self): ret = {} for k, v in self.overlays[0].calibration_picks.items(): - ret[k] = np.vstack(list(v.values())) + points = list(v.values()) + if not points: + # No points on this detector + ret[k] = [] + continue + + ret[k] = np.vstack(points) return ret def draw_picks_on_canvas(self): diff --git a/hexrdgui/image_canvas.py b/hexrdgui/image_canvas.py index 664fd88bb..7fd90db30 100644 --- a/hexrdgui/image_canvas.py +++ b/hexrdgui/image_canvas.py @@ -850,6 +850,13 @@ def update_beam_marker(self): if utils.has_nan(beam_position): continue + if self.mode == ViewType.raw: + if HexrdConfig().stitch_raw_roi_images: + # Need to convert these to stitched coordinates + beam_position = self.iviewer.raw_to_stitched( + [beam_position[::-1]], + det_key)[0][0][::-1] + artist, = axis.plot(*beam_position, **style) self.beam_marker_artists.append(artist) @@ -1454,9 +1461,15 @@ def update_wppf_plot(self): def detector_axis(self, detector_name): if self.mode == ViewType.raw: - if detector_name not in self.raw_axes: + if HexrdConfig().stitch_raw_roi_images: + axes_name = self.iviewer.instr.detectors[detector_name].group + else: + axes_name = detector_name + + if axes_name not in self.raw_axes: return None - return self.raw_axes[detector_name] + + return self.raw_axes[axes_name] else: # Only one axis for all detectors... return self.axis @@ -1475,8 +1488,19 @@ def update_auto_picked_data(self): # right canvas for this detector... continue + data = xys[det_key] + if len(data) == 0: + # Nothing to draw... + continue + transform_func = transform_from_plain_cartesian_func(self.mode) - rijs = transform_func(xys[det_key], panel, self.iviewer) + rijs = transform_func(data, panel, self.iviewer) + + if self.mode == ViewType.raw: + if HexrdConfig().stitch_raw_roi_images: + # Need to convert these to stitched coordinates + rijs = self.iviewer.raw_to_stitched( + rijs[:, ::-1], det_key)[0][:, ::-1] if self.mode == ViewType.polar: rijs = apply_tth_distortion_if_needed(rijs, in_degrees=True)