From 5b9aa5940b22ad7614d20d4d389728fd08b59cf8 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 11 Mar 2024 12:26:22 -0400 Subject: [PATCH] update location of phase-indicator on change to ephemeris --- lcviz/plugins/time_selector/time_selector.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lcviz/plugins/time_selector/time_selector.py b/lcviz/plugins/time_selector/time_selector.py index 9620e361..da1f40d8 100644 --- a/lcviz/plugins/time_selector/time_selector.py +++ b/lcviz/plugins/time_selector/time_selector.py @@ -1,6 +1,7 @@ from jdaviz.configs.cubeviz.plugins import Slice from jdaviz.core.registries import tray_registry +from lcviz.events import EphemerisChangedMessage from lcviz.viewers import CubeView, PhaseScatterView __all__ = ['TimeSelector'] @@ -42,6 +43,9 @@ def __init__(self, *args, **kwargs): self.value_unit = 'd' self.allow_disable_snapping = True + self.session.hub.subscribe(self, EphemerisChangedMessage, + handler=self._on_ephemeris_changed) + @property def slice_axis(self): # global display unit "axis" corresponding to the slice axis @@ -68,3 +72,11 @@ def _on_select_slice_message(self, msg): self.value = self.value + (new_phase - prev_phase) * viewer.ephemeris.get('period', 1.0) else: super()._on_select_slice_message(msg) + + def _on_ephemeris_changed(self, msg): + for viewer in self.slice_indicator_viewers: + if not isinstance(viewer, PhaseScatterView): + continue + if viewer._ephemeris_component != msg.ephemeris_label: + continue + viewer._set_slice_indicator_value(self.value)