Skip to content

Commit

Permalink
update spectral extraction plugin to listen to unit change messages
Browse files Browse the repository at this point in the history
  • Loading branch information
cshanahan1 committed Aug 15, 2024
1 parent bfca6aa commit d88a49b
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d88a49b

Please sign in to comment.