-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dials.image_viewer
crash when the detector swing angle is larger than 90°
#2479
Fix dials.image_viewer
crash when the detector swing angle is larger than 90°
#2479
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much!
I confirmed this fixed the problem on several HyPix datasets.
Wait. I found another related issue. |
diff --git a/src/dials/util/image_viewer/spotfinder_frame.py b/src/dials/util/image_viewer/spotfinder_frame.py
index 1937dcded..d05155e1e 100644
--- a/src/dials/util/image_viewer/spotfinder_frame.py
+++ b/src/dials/util/image_viewer/spotfinder_frame.py
@@ -1952,7 +1952,7 @@ def _basis_vector_overlay_data(self, i_expt, i_frame, experiment):
if "DXTBX_ASSERT(w_max > 0)" in str(e):
# direct beam didn't hit a panel
panel = 0
- beam_centre = detector[panel].get_ray_intersection(beam.get_s0())
+ beam_centre = detector[panel].get_bidirectional_ray_intersection(beam.get_s0())
else:
raise
beam_x, beam_y = detector[panel].millimeter_to_pixel(beam_centre) This is a workaround but this shows very long vectors extending beyond the panel. Or should we hide the vectors? |
I think the intention of the fallback to panel 0 is so that for cases where the direct beam lands between panels (CS-PAD for example) we can at least draw the blue cross in the panel gap by choosing one of the panel's coordinate systems (at it might as well be the first panel). In this case the blue cross is well outside the image as a whole. I think it would be reasonable to simply avoid calculating the basis vectors in this case. However, I'm not sure how to test for this case. |
Codecov Report
@@ Coverage Diff @@
## main #2479 +/- ##
==========================================
- Coverage 78.65% 78.62% -0.04%
==========================================
Files 606 607 +1
Lines 74244 74343 +99
Branches 10093 10119 +26
==========================================
+ Hits 58398 58451 +53
- Misses 13701 13734 +33
- Partials 2145 2158 +13 |
Perhaps this is because with a large
I see.
How about calculating the covex hull of all panels and checking whether the direct beam is within it? |
That sounds good. How about I add your change to this PR to get the image viewer working in this case, and then make a new issue regarding the basis vector display? I think there is more than one problem with it. |
Basis vector display is problematic though
Yes. That makes sense. |
…r than 90° (dials#2479) Fix the image viewer for cases where the detector is in front of the crystal.
Two workarounds required to display images when
panel.get_beam_centre_lab
raises aRuntimeError
, such as in the case of #2478