From 446fa4f9343109c5d14b430a90637411c9a700d8 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen <39831871+rosteen@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:53:03 -0400 Subject: [PATCH] Better menu selection labels for spectral lines in line analysis plugin (#2816) * Better menu selection labels for spectral lines in line analysis * Add changelog * Properly display a different text than the value returned * Codestyle * Remove debugging print Co-authored-by: Kyle Conroy * Update jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py Co-authored-by: Kyle Conroy * Address review comments Clarify comment --------- Co-authored-by: Kyle Conroy --- CHANGES.rst | 4 +++- .../plugins/line_analysis/line_analysis.py | 13 +++++++--- .../plugins/line_analysis/line_analysis.vue | 24 ++++++++++--------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index d63945f496..9ffa710598 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -62,6 +62,8 @@ Specviz2d Other Changes and Additions --------------------------- +- Line menu in Redshift from Centroid section of Line Analysis now shows values in current units. [#2816] + 3.9.1 (unreleased) ================== @@ -81,7 +83,7 @@ Cubeviz Imviz ^^^^^ -- Fix bugs where API created footprints did not overlay and only last +- Fix bugs where API created footprints did not overlay and only last footprint displayed if added before linking. [#2790, #2797] - Improved behavior when orientations are created or selected without having data loaded in the viewer. [#2789] diff --git a/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py b/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py index aa1dd144be..6e7b1f841b 100644 --- a/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py +++ b/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py @@ -102,7 +102,7 @@ class LineAnalysis(PluginTemplateMixin, DatasetSelectMixin, SpectralSubsetSelect results_computing = Bool(False).tag(sync=True) results = List().tag(sync=True) results_centroid = Float().tag(sync=True) # stored in AA units - line_items = List([]).tag(sync=True) + line_menu_items = List([{}]).tag(sync=True) sync_identify = Bool(True).tag(sync=True) sync_identify_icon_enabled = Unicode(read_icon(os.path.join(ICON_DIR, 'line_select.svg'), 'svg+xml')).tag(sync=True) # noqa sync_identify_icon_disabled = Unicode(read_icon(os.path.join(ICON_DIR, 'line_select_disabled.svg'), 'svg+xml')).tag(sync=True) # noqa @@ -173,6 +173,11 @@ def user_api(self): return PluginUserApi(self, expose=('dataset', 'spatial_subset', 'spectral_subset', 'continuum', 'width', 'continuum_width', 'get_results')) + @property + def line_items(self): + # Return list of only the table indices ("name_rest" in line table) from line_menu_items + return [item["value"] for item in self.line_menu_items] + def _on_viewer_data_changed(self, msg): viewer_id = self.app._viewer_item_by_reference( self._default_spectrum_viewer_reference_name @@ -242,14 +247,16 @@ def get_results(self): if not self.spectral_subset_valid: valid, spec_range, subset_range = self._check_dataset_spectral_subset_valid(return_ranges=True) # noqa - raise ValueError(f"spectral subset '{self.spectral_subset.selected}' {subset_range} is outside data range of '{self.dataset.selected}' {spec_range}") # noqa + raise ValueError(f"spectral subset '{self.spectral_subset.selected}' {subset_range}" + f" is outside data range of '{self.dataset.selected}' {spec_range}") self._calculate_statistics() return self.results def _on_plotted_lines_changed(self, msg): self.line_marks = msg.marks - self.line_items = msg.names_rest + self.line_menu_items = [{"title": f"{mark.name} {mark.rest_value} {mark.xunit}", "value": name_rest} # noqa + for mark, name_rest in zip(msg.marks, msg.names_rest)] if self.selected_line not in self.line_items: # default to identified line if available self.selected_line = self.identified_line diff --git a/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.vue b/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.vue index 38b89a0161..83e0d2495d 100644 --- a/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.vue +++ b/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.vue @@ -33,7 +33,7 @@ hint="Select which region's collapsed spectrum to analyze." /> - Continuum - {{continuum_subset_selected=='Surrounding' && spectral_subset_selected=='Entire Spectrum' ? "Since using the entire spectrum, the end points will be used to fit a linear continuum." : "Choose a region to fit a linear line as the underlying continuum."}} + {{continuum_subset_selected=='Surrounding' && spectral_subset_selected=='Entire Spectrum' ? "Since using the entire spectrum, the end points will be used to fit a linear continuum." : "Choose a region to fit a linear line as the underlying continuum."}} {{continuum_subset_selected=='Surrounding' && spectral_subset_selected!='Entire Spectrum' ? "Choose a width in number of data points to consider on each side of the line region defined above." : null}} When this plugin is opened, a visual indicator will show on the spectrum plot showing the continuum fitted as a thick line, and interpolated into the line region as a thin line. - Function Result - {{ item.function }} - mdi-open-in-new - + @@ -123,7 +123,7 @@
-
- +