diff --git a/jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py b/jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py index 7748a3511d..67fa4a7c39 100644 --- a/jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py +++ b/jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py @@ -102,6 +102,9 @@ def __init__(self, *args, **kwargs): 'continuum_dataset_selected', filters=['not_child_layer', 'layer_in_spectrum_viewer']) + # since the continuum is just an approximation preview, + # automatically convert the units instead of recomputing + self.continuum_auto_update_units = True # when plugin is initialized, there won't be a dataset selected, so # call the output unit 'Flux' for now (rather than surface brightness). diff --git a/jdaviz/core/marks.py b/jdaviz/core/marks.py index 4bcd52d2e4..d1d2c7d4ae 100644 --- a/jdaviz/core/marks.py +++ b/jdaviz/core/marks.py @@ -559,10 +559,10 @@ def __init__(self, viewer, x=[], y=[], **kwargs): class LineAnalysisContinuum(PluginLine): def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) # units do not need to be updated because the plugin itself reruns # the computation and automatically changes the arrays themselves - self.auto_update_units = False + self.auto_update_units = kwargs.pop('auto_update_units', False) + super().__init__(*args, **kwargs) class LineAnalysisContinuumCenter(LineAnalysisContinuum): diff --git a/jdaviz/core/template_mixin.py b/jdaviz/core/template_mixin.py index 0eb455691c..a3db290531 100644 --- a/jdaviz/core/template_mixin.py +++ b/jdaviz/core/template_mixin.py @@ -2895,6 +2895,9 @@ class SpectralContinuumMixin(VuetifyTemplate, HubListener): continuum_subset_selected = Unicode().tag(sync=True) continuum_width = FloatHandleEmpty(3).tag(sync=True) + # whether continuum marks should update on unit change or + # if the plugin will handle that logic + continuum_auto_update_units = Bool(False).tag(sync=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -2932,15 +2935,29 @@ def continuum_marks(self): return {} # then haven't been initialized yet, so initialize with empty # marks that will be populated once the first analysis is done. - marks = {'left': LineAnalysisContinuumLeft(viewer, visible=self.is_active), - 'center': LineAnalysisContinuumCenter(viewer, visible=self.is_active), - 'right': LineAnalysisContinuumRight(viewer, visible=self.is_active)} + marks = {'left': LineAnalysisContinuumLeft(viewer, + auto_update_units=self.continuum_auto_update_units, # noqa + visible=self.is_active), + 'center': LineAnalysisContinuumCenter(viewer, + auto_update_units=self.continuum_auto_update_units, # noqa + visible=self.is_active), + 'right': LineAnalysisContinuumRight(viewer, + auto_update_units=self.continuum_auto_update_units, # noqa + visible=self.is_active)} shadows = [ShadowLine(mark, shadow_width=2) for mark in marks.values()] # NOTE: += won't trigger the figure to notice new marks viewer.figure.marks = viewer.figure.marks + shadows + list(marks.values()) return marks + @observe('continuum_auto_update_units') + def _set_auto_update_units(self, event=None): + for mark in self.continuum_marks.values(): + # LineAnalysis recomputes the continuum on a change to units, + # but here since the continuum is just visual and an approximation, + # let's just convert units on the mark itself + mark.auto_update_units = self.continuum_auto_update_units + def _update_continuum_marks(self, mark_x={}, mark_y={}): for pos, mark in self.continuum_marks.items(): mark.update_xy(mark_x.get(pos, []), mark_y.get(pos, []))