diff --git a/CHANGES.rst b/CHANGES.rst index 8ecc95cec6..4fceafe4cc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -34,6 +34,9 @@ Mosviz Specviz ^^^^^^^ +- Line List Spectral Range filter displays only lines with an observed + wavelength within the range of the spectrum viewer [#1327] + API Changes ----------- diff --git a/jdaviz/components/tooltip.vue b/jdaviz/components/tooltip.vue index 2579040a88..0dbbd57238 100644 --- a/jdaviz/components/tooltip.vue +++ b/jdaviz/components/tooltip.vue @@ -66,6 +66,8 @@ const tooltips = { 'plugin-line-lists-line-identify-chip-inactive': 'No line currently highlighted. Use selection tool in spectrum viewer to identify a line.', 'plugin-line-lists-line-visible': 'Toggle showing the line in the spectrum viewer', 'plugin-line-lists-line-identify': 'Highlight this line in the spectrum viewer for easy identification', + 'plugin-line-lists-color-picker': 'Change the color of this list', + 'plugin-line-lists-spectral-range': 'Toggle filter to only lines observable within the range of the Spectrum Viewer', 'plugin-line-analysis-sync-identify': 'Lock/unlock selection with identified line', 'plugin-line-analysis-assign': 'Assign the centroid wavelength and update the redshift', 'plugin-moment-save-fits': 'Save moment map as FITS file', diff --git a/jdaviz/components/tray_plugin.vue b/jdaviz/components/tray_plugin.vue index 1026bd91db..73d38b5afa 100644 --- a/jdaviz/components/tray_plugin.vue +++ b/jdaviz/components/tray_plugin.vue @@ -35,6 +35,13 @@ module.exports = { padding-left: 0px !important; } + .row-no-vertical-padding-margin { + padding-top: 0px !important; + padding-bottom: 0px !important; + margin-bottom: 0px !important; + margin-top: 0px !important; + } + .row-no-outside-padding .col:last-of-type { padding-right: 0px !important; } diff --git a/jdaviz/configs/default/plugins/line_lists/line_lists.py b/jdaviz/configs/default/plugins/line_lists/line_lists.py index 4e6bfb0c80..d4c3df4139 100644 --- a/jdaviz/configs/default/plugins/line_lists/line_lists.py +++ b/jdaviz/configs/default/plugins/line_lists/line_lists.py @@ -54,9 +54,13 @@ class LineListTool(PluginTemplateMixin): custom_unit = Unicode().tag(sync=True) lines_filter = Any().tag(sync=True) # string or None + filter_range = Bool(False).tag(sync=True) + spectrum_viewer_min = Float(0.01).tag(sync=True) + spectrum_viewer_max = Float(0.01).tag(sync=True) identify_label = Unicode().tag(sync=True) identify_line_icon = Unicode(read_icon(os.path.join(ICON_DIR, 'line_select.svg'), 'svg+xml')).tag(sync=True) # noqa + filter_range_icon = Unicode(read_icon(os.path.join(ICON_DIR, 'spectral_range.svg'), 'svg+xml')).tag(sync=True) # noqa def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -103,7 +107,10 @@ def __init__(self, *args, **kwargs): handler=self._process_identify_change) # if set to auto (default), update the slider range when zooming on the spectrum viewer - self._viewer.scales['x'].observe(self._auto_slider_range, names=['min', 'max']) + self._viewer.state.add_callback("x_min", + lambda x_min: self._on_spectrum_viewer_limits_changed()) + self._viewer.state.add_callback("x_max", + lambda x_max: self._on_spectrum_viewer_limits_changed()) def _on_viewer_data_changed(self, msg=None): """ @@ -155,7 +162,7 @@ def _on_viewer_data_changed(self, msg=None): self.rs_redshift = (viewer_data.redshift.value if hasattr(viewer_data.redshift, 'value') else viewer_data.redshift) - self._auto_slider_range() # will also trigger _auto_slider_step + self._on_spectrum_viewer_limits_changed() # will also trigger _auto_slider_step # set the choices (and default) for the units for new custom lines self.custom_unit_choices = create_spectral_equivalencies_list(viewer_data) @@ -367,12 +374,23 @@ def vue_slider_reset(self, event): # updating during slide, so update them now self.vue_unpause_tables() + def _on_spectrum_viewer_limits_changed(self, event=None): + sv = self.app.get_viewer('spectrum-viewer') + self.spectrum_viewer_min = sv.state.x_min + self.spectrum_viewer_max = sv.state.x_max + + # Also update the slider range + self._auto_slider_range() + def _auto_slider_range(self, event=None): + """ + Automatically adjusts the Redshift slider range to the values of the + spectrum_viewer_min and spectrum_viewer_max traitlets + """ if not self.rs_slider_range_auto: return # if set to auto, default the range based on the limits of the spectrum plot - sv = self.app.get_viewer('spectrum-viewer') - x_min, x_max = sv.state.x_min, sv.state.x_max + x_min, x_max = self.spectrum_viewer_min, self.spectrum_viewer_max x_mid = abs(x_max + x_min) / 2. # we'll *estimate* the redshift range to shift the range of the viewer # (for a line with a rest wavelength in the center of the viewer), @@ -393,7 +411,7 @@ def _auto_slider_range(self, event=None): @observe('rs_slider_range_auto') def _on_rs_slider_range_auto_updated(self, event): if event['new']: - self._auto_slider_range() + self._on_spectrum_viewer_limits_changed() @observe('rs_slider_half_range') def _auto_slider_step(self, event=None): @@ -740,7 +758,8 @@ def vue_set_color(self, data): color = data['color'] if "listname" in data: listname = data["listname"] - lc = self.list_contents[listname] + # force a copy so that the change is picked up by traitlets + lc = self.list_contents[listname].copy() lc["color"] = color for line in lc["lines"]: @@ -752,6 +771,8 @@ def vue_set_color(self, data): if name_rest in self.line_mark_dict: self.line_mark_dict[name_rest].colors = [color] + self.list_contents = {**self.list_contents, listname: lc} + elif "linename" in data: pass diff --git a/jdaviz/configs/default/plugins/line_lists/line_lists.vue b/jdaviz/configs/default/plugins/line_lists/line_lists.vue index 52d0eead8d..276e0176e0 100644 --- a/jdaviz/configs/default/plugins/line_lists/line_lists.vue +++ b/jdaviz/configs/default/plugins/line_lists/line_lists.vue @@ -113,36 +113,42 @@ - - + + mdi-close-circle - - - {{ item }} - + + + + +
+ +
+
+
+
+ +
{{ item }}
+ +
- - - - -
@@ -185,89 +191,114 @@
- - - - Erase All + + + + + + mdi-eye + Plot All + - - - Plot All + + + + mdi-eye-off + Erase All + + + + + + + -
- - - - {{line.show ? "mdi-eye" : "mdi-eye-off"}} - - - - - - - - - {{line.linename}} - - - - - rest +
+ + + + + {{line.linename}} + + + + + + + + + - + + + + {{line.show ? "mdi-eye" : "mdi-eye-off"}} + + + + + + + + Rest - - {{ line.unit.replace("Angstrom", "Å") }} - - - - - obs - - + + Observed - - {{ line.unit.replace("Angstrom", "Å") }} -
@@ -280,18 +311,34 @@ - Erase All + + mdi-eye + Plot All + - Plot All + + mdi-eye-off + Erase All + @@ -303,12 +350,23 @@ @@ -343,4 +404,10 @@ .v-slider { margin: 0px !important; } + + .linelist-color-menu { + font-size: 16px; + padding-left: 16px; + border: 2px solid rgba(0,0,0,0.54); + } diff --git a/jdaviz/data/icons/spectral_range.svg b/jdaviz/data/icons/spectral_range.svg new file mode 100644 index 0000000000..f79791af1a --- /dev/null +++ b/jdaviz/data/icons/spectral_range.svg @@ -0,0 +1 @@ + \ No newline at end of file