diff --git a/lcviz/plugins/binning/binning.py b/lcviz/plugins/binning/binning.py index bc43edcc..84f141f6 100644 --- a/lcviz/plugins/binning/binning.py +++ b/lcviz/plugins/binning/binning.py @@ -1,5 +1,7 @@ +import numpy as np +from time import time from astropy.time import Time -from traitlets import Bool, observe +from traitlets import Bool, Float, observe from glue.config import data_translator from jdaviz.core.custom_traitlets import IntHandleEmpty @@ -46,6 +48,10 @@ class Binning(PluginTemplateMixin, DatasetSelectMixin, EphemerisSelectMixin, Add n_bins = IntHandleEmpty(100).tag(sync=True) bin_enabled = Bool(True).tag(sync=True) + last_live_time = Float(0).tag(sync=True) + previews_temp_disable = Bool(False).tag(sync=True) + spinner = Bool(False).tag(sync=True) + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -145,7 +151,7 @@ def _toggle_marks(self, event={}): self._live_update(event) @observe('dataset_selected', 'ephemeris_selected', - 'n_bins') + 'n_bins', 'previews_temp_disable') @skip_if_no_updates_since_last_active() def _live_update(self, event={}): if not self.show_live_preview or not self.is_active: @@ -153,6 +159,11 @@ def _live_update(self, event={}): self.bin_enabled = self.n_bins != '' and self.n_bins > 0 return + if self.previews_temp_disable: + return + + start = time() + if event.get('name', '') not in ('is_active', 'show_live_preview'): # mark visibility hasn't been handled yet self._toggle_marks() @@ -189,6 +200,10 @@ def _live_update(self, event={}): mark.times = [] mark.update_xy(times, lc.flux.value) + self.last_live_time = np.round(time() - start, 2) + if self.last_live_time > 0.3: + self.previews_temp_disable = True + def _on_ephemeris_update(self, msg): if not self.show_live_preview or not self.is_active: return @@ -199,7 +214,7 @@ def _on_ephemeris_update(self, msg): self._live_update() def bin(self, add_data=True): - + self.spinner = True if self.n_bins == '' or self.n_bins <= 0: raise ValueError("n_bins must be a positive integer") @@ -245,6 +260,7 @@ def bin(self, add_data=True): # by resetting x_att, the preview marks may have dissappeared self._live_update() + self.spinner = False return lc def vue_apply(self, event={}): diff --git a/lcviz/plugins/binning/binning.vue b/lcviz/plugins/binning/binning.vue index 5dbac90b..a3109573 100644 --- a/lcviz/plugins/binning/binning.vue +++ b/lcviz/plugins/binning/binning.vue @@ -57,6 +57,24 @@ + + Live-updating is temporarily disabled (last update took {{last_live_time}}s) + + + + disable previews + + + + + + + update preview + + + + +