From 3f80eb5426a12d25fa892707679ad7c72016c636 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 9 Sep 2024 10:19:46 -0400 Subject: [PATCH] per-config display of unit selections (#3166) * per-config display of unit selections and customizable downstream --- .../unit_conversion/unit_conversion.py | 53 ++++++++++++---- .../unit_conversion/unit_conversion.vue | 63 ++++++++++++------- 2 files changed, 80 insertions(+), 36 deletions(-) diff --git a/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py b/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py index 27d2de23ae..e5212dcaa7 100644 --- a/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py +++ b/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py @@ -56,17 +56,25 @@ class UnitConversion(PluginTemplateMixin): """ template_file = __file__, "unit_conversion.vue" + has_spectral = Bool(False).tag(sync=True) spectral_unit_items = List().tag(sync=True) spectral_unit_selected = Unicode().tag(sync=True) + has_flux = Bool(False).tag(sync=True) flux_unit_items = List().tag(sync=True) flux_unit_selected = Unicode().tag(sync=True) - sb_unit_selected = Unicode().tag(sync=True) - + has_angle = Bool(False).tag(sync=True) angle_unit_items = List().tag(sync=True) angle_unit_selected = Unicode().tag(sync=True) + has_sb = Bool(False).tag(sync=True) + sb_unit_selected = Unicode().tag(sync=True) + + has_time = Bool(False).tag(sync=True) + time_unit_items = List().tag(sync=True) + time_unit_selected = Unicode().tag(sync=True) + spectral_y_type_items = List().tag(sync=True) spectral_y_type_selected = Unicode().tag(sync=True) @@ -97,30 +105,51 @@ def __init__(self, *args, **kwargs): self.session.hub.subscribe(self, AddDataToViewerMessage, handler=self._find_and_convert_contour_units) + self.has_spectral = self.config in ('specviz', 'cubeviz', 'specviz2d', 'mosviz') self.spectral_unit = UnitSelectPluginComponent(self, items='spectral_unit_items', selected='spectral_unit_selected') - self.spectral_y_type = SelectPluginComponent(self, - items='spectral_y_type_items', - selected='spectral_y_type_selected', - manual_options=['Surface Brightness', 'Flux']) - + self.has_flux = self.config in ('specviz', 'cubeviz', 'specviz2d', 'mosviz') self.flux_unit = UnitSelectPluginComponent(self, items='flux_unit_items', selected='flux_unit_selected') + self.has_angle = self.config in ('cubeviz', 'specviz', 'mosviz') self.angle_unit = UnitSelectPluginComponent(self, items='angle_unit_items', selected='angle_unit_selected') + self.has_sb = self.has_angle or self.config in ('imviz',) + # NOTE: always read_only, exposed through sb_unit property + + self.has_time = False + self.time_unit = UnitSelectPluginComponent(self, + items='time_unit_items', + selected='time_unit_selected') + + self.spectral_y_type = SelectPluginComponent(self, + items='spectral_y_type_items', + selected='spectral_y_type_selected', + manual_options=['Surface Brightness', 'Flux']) + @property def user_api(self): - if self.app.config == 'cubeviz': - expose = ('spectral_unit', 'spectral_y_type', 'flux_unit', 'angle_unit', 'sb_unit') - else: - expose = ('spectral_unit', 'flux_unit', 'angle_unit') - return PluginUserApi(self, expose=expose) + expose = [] + readonly = [] + if self.has_spectral: + expose += ['spectral_unit'] + if self.has_flux: + expose += ['flux_unit'] + if self.has_angle: + expose += ['angle_unit'] + if self.has_sb: + readonly = ['sb_unit'] + if self.has_time: + expose += ['time_unit'] + if self.config == 'cubeviz': + expose += ['spectral_y_type'] + return PluginUserApi(self, expose=expose, readonly=readonly) @property def sb_unit(self): diff --git a/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue b/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue index 1f8a26d8d7..e04b2b74e3 100644 --- a/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue +++ b/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue @@ -9,7 +9,7 @@ :popout_button="popout_button" :scroll_to.sync="scroll_to"> - + - + + + + + - - + + - + - - - +
+ + + - - - + + + - - PIXAR_SR FITS header keyword not found when parsing spectral cube. - Flux/Surface Brightness will use default PIXAR_SR value of 1. - + + PIXAR_SR FITS header keyword not found when parsing spectral cube. + Flux/Surface Brightness will use default PIXAR_SR value of 1. + +