diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index e2270518cd..62b9d6c93c 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -109,6 +109,8 @@ class SpectralExtraction(PluginTemplateMixin, ApertureSubsetSelectMixin, results_units = Unicode().tag(sync=True) spectrum_y_units = Unicode().tag(sync=True) + flux_unit = Unicode().tag(sync=True) + sb_unit = Unicode().tag(sync=True) aperture_method_items = List().tag(sync=True) aperture_method_selected = Unicode('Center').tag(sync=True) @@ -178,7 +180,7 @@ def __init__(self, *args, **kwargs): self.session.hub.subscribe(self, SliceValueUpdatedMessage, handler=self._on_slice_changed) self.hub.subscribe(self, GlobalDisplayUnitChanged, - handler=self._update_results_units) + handler=self._on_gloabl_display_unit_changed) self._update_disabled_msg() @@ -313,13 +315,25 @@ def _update_mark_scale(self, *args): else: self.background.scale_factor = self.slice_spectral_value/self.reference_spectral_value + def _on_gloabl_display_unit_changed(self, msg={}): + + + if msg.axis == 'spectral_y': + self.spectrum_y_units = str(msg.unit) + + if msg.axis == 'flux': + self.flux_unit = str(msg.unit) + if msg.axis == 'sb': + self.sb_unit = str(msg.unit) + @observe('function_selected') - def _update_results_units(self, msg={}): - self.spectrum_y_units = str(self.app._get_display_unit('spectral_y')) + def _update_units_on_function_selection(self): + if self.function_selected.lower() == 'sum': - self.results_units = str(self.app._get_display_unit('flux')) + self.results_units = self.flux_unit else: - self.results_units = str(self.app._get_display_unit('sb')) + self.results_units = self.sb_unit + @observe('function_selected', 'aperture_method_selected') def _update_aperture_method_on_function_change(self, *args):