From 097c18d33947a7cefd37e4fc3da590891128f0a6 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 23 Aug 2024 10:19:33 -0400 Subject: [PATCH 1/3] 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..fb4452329b 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. + +
From d93fec288a9e1c9edaf942f743c6515156f28c0a Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 6 Sep 2024 15:14:31 -0400 Subject: [PATCH 2/3] fix rebase conflict --- .../specviz/plugins/unit_conversion/unit_conversion.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue b/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue index fb4452329b..4ef4603706 100644 --- a/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue +++ b/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue @@ -82,9 +82,9 @@ Date: Fri, 6 Sep 2024 15:20:55 -0400 Subject: [PATCH 3/3] another rebase fix --- .../configs/specviz/plugins/unit_conversion/unit_conversion.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue b/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue index 4ef4603706..e04b2b74e3 100644 --- a/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue +++ b/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue @@ -84,7 +84,7 @@ attach :items="spectral_y_type_items.map(i => i.label)" v-model="spectral_y_type_selected" - :label="api_hints_enabled ? 'plg.spectral_y_type =' : 'Flux or Surface Brightness'" + :label="api_hints_enabled ? 'plg.spectral_y_type =' : 'Spectral y-axis Type'" :class="api_hints_enabled ? 'api-hint' : null" hint="Select the y-axis physical type for the spectrum-viewer." persistent-hint