Skip to content
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

More intuitive tooltips and manual tcBF #25

Merged
merged 11 commits into from
Sep 25, 2024
Next Next commit
add option for maximum DP in realspace integrator
  • Loading branch information
sezelt committed Aug 28, 2024
commit c9c329e72cae0f4e52a785d4b4378ecab089093f
31 changes: 31 additions & 0 deletions src/py4D_browser/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ def setup_menus(self):
self.detector_menu = QMenu("&Detector Response", self)
self.menu_bar.addMenu(self.detector_menu)

detector_mode_separator = QAction("Diffraction", self)
detector_mode_separator.setDisabled(True)
self.detector_menu.addAction(detector_mode_separator)

detector_mode_group = QActionGroup(self)
detector_mode_group.setExclusive(True)
self.detector_mode_group = detector_mode_group
Expand Down Expand Up @@ -372,6 +376,33 @@ def setup_menus(self):
detector_mode_group.addAction(detector_iCoM)
self.detector_menu.addAction(detector_iCoM)

# Detector Response for realspace selector
self.detector_menu.addSeparator()
rs_detector_mode_separator = QAction("Diffraction", self)
rs_detector_mode_separator.setDisabled(True)
self.detector_menu.addAction(rs_detector_mode_separator)

realspace_detector_mode_group = QActionGroup(self)
realspace_detector_mode_group.setExclusive(True)
self.realspace_detector_mode_group = realspace_detector_mode_group

detector_integrating_action = QAction("&Integrating", self)
detector_integrating_action.setCheckable(True)
detector_integrating_action.setChecked(True)
detector_integrating_action.triggered.connect(
partial(self.update_diffraction_space_view, True)
)
realspace_detector_mode_group.addAction(detector_integrating_action)
self.detector_menu.addAction(detector_integrating_action)

detector_maximum_action = QAction("&Maximum", self)
detector_maximum_action.setCheckable(True)
detector_maximum_action.triggered.connect(
partial(self.update_diffraction_space_view, True)
)
realspace_detector_mode_group.addAction(detector_maximum_action)
self.detector_menu.addAction(detector_maximum_action)

# Detector Shape Menu
self.detector_shape_menu = QMenu("Detector &Shape", self)
self.menu_bar.addMenu(self.detector_shape_menu)
Expand Down
12 changes: 11 additions & 1 deletion src/py4D_browser/update_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ def update_diffraction_space_view(self, reset=False):
"Rectangular",
], detector_shape

detector_response = (
self.realspace_detector_mode_group.checkedAction().text().replace("&", "")
)
assert detector_response in ["Integrating", "Maximum"], detector_response

if detector_shape == "Point":
roi_state = self.real_space_point_selector.saveState()
y0, x0 = roi_state["pos"]
Expand All @@ -288,7 +293,12 @@ def update_diffraction_space_view(self, reset=False):
f"Real Space Range: [{slice_x.start}:{slice_x.stop},{slice_y.start}:{slice_y.stop}]"
)

DP = np.sum(self.datacube.data[slice_x, slice_y], axis=(0, 1))
if detector_response == "Integrating":
DP = np.sum(self.datacube.data[slice_x, slice_y], axis=(0, 1))
elif detector_response == "Maximum":
DP = np.max(self.datacube.data[slice_x, slice_y], axis=(0, 1))
else:
raise ValueError("Detector response problem")

else:
raise ValueError("Detector shape not recognized")
Expand Down