From 97d81766d618a72f1e78a3cc0b940f4b51881c5e Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 9 Aug 2024 14:03:25 -0400 Subject: [PATCH 1/7] simplify layer retrieval --- lcviz/plugins/coords_info/coords_info.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lcviz/plugins/coords_info/coords_info.py b/lcviz/plugins/coords_info/coords_info.py index 2f4c570..33f3956 100644 --- a/lcviz/plugins/coords_info/coords_info.py +++ b/lcviz/plugins/coords_info/coords_info.py @@ -89,10 +89,7 @@ def _cursor_fallback(): if self.dataset.selected != 'auto' and self.dataset.selected != lyr.layer.label: continue - # glue-jupyter 1.18 changed from lyr.scatter to lyr.scatter_mark - # TODO: once glue-jupyter is pinned to 1.18 or later, update this to: - # scatter = lyr.scatter_mark - scatter = getattr(lyr, 'scatter_mark', getattr(lyr, 'scatter', None)) + scatter = lyr.scatter_mark lyr_x, lyr_y = scatter.x, scatter.y if not len(lyr_x): continue From 1db512afe41ac15876d968b168b2242f0f960912 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 9 Aug 2024 14:04:53 -0400 Subject: [PATCH 2/7] debugging snackbar messages for profiling --- lcviz/plugins/coords_info/coords_info.py | 57 +++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/lcviz/plugins/coords_info/coords_info.py b/lcviz/plugins/coords_info/coords_info.py index 33f3956..b0f28fe 100644 --- a/lcviz/plugins/coords_info/coords_info.py +++ b/lcviz/plugins/coords_info/coords_info.py @@ -2,11 +2,13 @@ from glue.core.subset_group import GroupedSubset from jdaviz.configs.imviz.plugins.coords_info import CoordsInfo -from jdaviz.core.events import ViewerRenamedMessage +from jdaviz.core.events import ViewerRenamedMessage, SnackbarMessage from jdaviz.core.registries import tool_registry from lcviz.viewers import TimeScatterView, PhaseScatterView, CubeView +from datetime import datetime as dt + __all__ = ['CoordsInfo'] @@ -16,6 +18,7 @@ class CoordsInfo(CoordsInfo): _viewer_classes_with_marker = (TimeScatterView, PhaseScatterView) def __init__(self, *args, **kwargs): + self.first = True super().__init__(*args, **kwargs) # TODO: move to jdaviz if/once viewer renaming supported @@ -89,10 +92,25 @@ def _cursor_fallback(): if self.dataset.selected != 'auto' and self.dataset.selected != lyr.layer.label: continue + if self.first: + start = dt.now() scatter = lyr.scatter_mark lyr_x, lyr_y = scatter.x, scatter.y if not len(lyr_x): + self.hub.broadcast( + SnackbarMessage( + f"not len(lyr_x) for {lyr.layer.label}", + sender=self, color="warning" + ) + ) continue + if self.first: + self.hub.broadcast( + SnackbarMessage( + f"lyr.scatter_mark retrieveal {(dt.now() - start).total_seconds()}s", + sender=self, color="warning" + ) + ) # NOTE: unlike specviz which determines the closest point in x per-layer, # this determines the closest point in x/y per-layer in pixel-space @@ -145,8 +163,17 @@ def _cursor_fallback(): self.icon = closest_icon + if self.first: + start = dt.now() self.marks[viewer._reference_id].update_xy([closest_x], [closest_y]) # noqa self.marks[viewer._reference_id].visible = True + if self.first: + self.hub.broadcast( + SnackbarMessage( + f"marks update_xy took {(dt.now() - start).total_seconds()}s", + sender=self, color="warning" + ) + ) def _image_viewer_update(self, viewer, x, y): # Extract first dataset from visible layers and use this for coordinates - the choice @@ -239,7 +266,27 @@ def update_display(self, viewer, x, y): if not len(viewer.state.layers): return - if isinstance(viewer, (TimeScatterView, PhaseScatterView)): - self._lc_viewer_update(viewer, x, y) - elif isinstance(viewer, CubeView): - self._image_viewer_update(viewer, x, y) + if self.first: + self.hub.broadcast( + SnackbarMessage( + f"coords_info first update_display call", + sender=self, color="warning" + ) + ) + start = dt.now() + try: + if isinstance(viewer, (TimeScatterView, PhaseScatterView)): + self._lc_viewer_update(viewer, x, y) + elif isinstance(viewer, CubeView): + self._image_viewer_update(viewer, x, y) + except Exception as e: + self._viewer_mouse_clear_event(viewer) + if self.first: + end = dt.now() + self.hub.broadcast( + SnackbarMessage( + f"coords_info first update_display took {(end - start).total_seconds()}s", + sender=self, color="warning" + ) + ) + self.first = False \ No newline at end of file From 8e10ed5fff7080f1a9d018c625a39fb3c404742f Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Tue, 20 Aug 2024 17:10:25 -0400 Subject: [PATCH 3/7] force layers to have points_mode='markers' --- lcviz/viewers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lcviz/viewers.py b/lcviz/viewers.py index a2e7910..1d0e74d 100644 --- a/lcviz/viewers.py +++ b/lcviz/viewers.py @@ -149,6 +149,7 @@ def _apply_layer_defaults(self, layer_state): if getattr(layer_state.layer, 'meta', {}).get('Plugin', None) == 'Binning': # increased size of binned results, by default layer_state.size = 5 + layer_state.points_mode = 'markers' def set_plot_axes(self): # set which components should be plotted From de97406191215db9ea2d7f2b919c8029bb9b2477 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 21 Aug 2024 09:53:08 -0400 Subject: [PATCH 4/7] add snackbar message when point_mode is overridden --- lcviz/viewers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lcviz/viewers.py b/lcviz/viewers.py index 1d0e74d..761ac89 100644 --- a/lcviz/viewers.py +++ b/lcviz/viewers.py @@ -150,6 +150,8 @@ def _apply_layer_defaults(self, layer_state): # increased size of binned results, by default layer_state.size = 5 layer_state.points_mode = 'markers' + from jdaviz.core.events import SnackbarMessage + self.hub.broadcast(SnackbarMessage("Layer changed to markers mode", sender=self, color='warning')) def set_plot_axes(self): # set which components should be plotted From e637dd36d8ba5a30055c70b556baeece3483f4c7 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 30 Aug 2024 09:07:09 -0400 Subject: [PATCH 5/7] Revert "debugging snackbar messages for profiling" This reverts commit c94c5c6b86a5361972d303ef687b13a7561550c1. --- lcviz/plugins/coords_info/coords_info.py | 57 +++--------------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/lcviz/plugins/coords_info/coords_info.py b/lcviz/plugins/coords_info/coords_info.py index b0f28fe..33f3956 100644 --- a/lcviz/plugins/coords_info/coords_info.py +++ b/lcviz/plugins/coords_info/coords_info.py @@ -2,13 +2,11 @@ from glue.core.subset_group import GroupedSubset from jdaviz.configs.imviz.plugins.coords_info import CoordsInfo -from jdaviz.core.events import ViewerRenamedMessage, SnackbarMessage +from jdaviz.core.events import ViewerRenamedMessage from jdaviz.core.registries import tool_registry from lcviz.viewers import TimeScatterView, PhaseScatterView, CubeView -from datetime import datetime as dt - __all__ = ['CoordsInfo'] @@ -18,7 +16,6 @@ class CoordsInfo(CoordsInfo): _viewer_classes_with_marker = (TimeScatterView, PhaseScatterView) def __init__(self, *args, **kwargs): - self.first = True super().__init__(*args, **kwargs) # TODO: move to jdaviz if/once viewer renaming supported @@ -92,25 +89,10 @@ def _cursor_fallback(): if self.dataset.selected != 'auto' and self.dataset.selected != lyr.layer.label: continue - if self.first: - start = dt.now() scatter = lyr.scatter_mark lyr_x, lyr_y = scatter.x, scatter.y if not len(lyr_x): - self.hub.broadcast( - SnackbarMessage( - f"not len(lyr_x) for {lyr.layer.label}", - sender=self, color="warning" - ) - ) continue - if self.first: - self.hub.broadcast( - SnackbarMessage( - f"lyr.scatter_mark retrieveal {(dt.now() - start).total_seconds()}s", - sender=self, color="warning" - ) - ) # NOTE: unlike specviz which determines the closest point in x per-layer, # this determines the closest point in x/y per-layer in pixel-space @@ -163,17 +145,8 @@ def _cursor_fallback(): self.icon = closest_icon - if self.first: - start = dt.now() self.marks[viewer._reference_id].update_xy([closest_x], [closest_y]) # noqa self.marks[viewer._reference_id].visible = True - if self.first: - self.hub.broadcast( - SnackbarMessage( - f"marks update_xy took {(dt.now() - start).total_seconds()}s", - sender=self, color="warning" - ) - ) def _image_viewer_update(self, viewer, x, y): # Extract first dataset from visible layers and use this for coordinates - the choice @@ -266,27 +239,7 @@ def update_display(self, viewer, x, y): if not len(viewer.state.layers): return - if self.first: - self.hub.broadcast( - SnackbarMessage( - f"coords_info first update_display call", - sender=self, color="warning" - ) - ) - start = dt.now() - try: - if isinstance(viewer, (TimeScatterView, PhaseScatterView)): - self._lc_viewer_update(viewer, x, y) - elif isinstance(viewer, CubeView): - self._image_viewer_update(viewer, x, y) - except Exception as e: - self._viewer_mouse_clear_event(viewer) - if self.first: - end = dt.now() - self.hub.broadcast( - SnackbarMessage( - f"coords_info first update_display took {(end - start).total_seconds()}s", - sender=self, color="warning" - ) - ) - self.first = False \ No newline at end of file + if isinstance(viewer, (TimeScatterView, PhaseScatterView)): + self._lc_viewer_update(viewer, x, y) + elif isinstance(viewer, CubeView): + self._image_viewer_update(viewer, x, y) From fce66f317cf58aa6b666a368806742dc9980501e Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 30 Aug 2024 09:07:23 -0400 Subject: [PATCH 6/7] Revert "add snackbar message when point_mode is overridden" This reverts commit 3bc1ab95c4aacba2ea58c8fc63bc0acd7d484bb7. --- lcviz/viewers.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lcviz/viewers.py b/lcviz/viewers.py index 761ac89..1d0e74d 100644 --- a/lcviz/viewers.py +++ b/lcviz/viewers.py @@ -150,8 +150,6 @@ def _apply_layer_defaults(self, layer_state): # increased size of binned results, by default layer_state.size = 5 layer_state.points_mode = 'markers' - from jdaviz.core.events import SnackbarMessage - self.hub.broadcast(SnackbarMessage("Layer changed to markers mode", sender=self, color='warning')) def set_plot_axes(self): # set which components should be plotted From 6702dd7d35bbae85177ed048ac4422fe783f4b27 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 30 Aug 2024 09:11:38 -0400 Subject: [PATCH 7/7] changelog entry --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index d483681..3dfe732 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,8 @@ * bumps lightkurve to 2.5.0 to include upstream bug fixes. [#132] +* Improve scatter viewer and mouseover performance. [#137] + 0.4.2 (07.23.2024) ------------------