Skip to content

Commit

Permalink
Fix fast powder calibration with subpanels
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
psavery committed Apr 29, 2024
1 parent 7c79ac0 commit cfdfc98
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
8 changes: 7 additions & 1 deletion hexrdgui/calibration/auto/powder_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
30 changes: 27 additions & 3 deletions hexrdgui/image_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit cfdfc98

Please sign in to comment.