Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Linelist improvements #1327

Merged
merged 40 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f84e7a8
First pass: Copy logic from plot options collapsible color picker
duytnguyendtn May 11, 2022
bd23960
Add missing Bool Traitlet
duytnguyendtn May 11, 2022
cbaec7b
Remove unneeded template; call item directly
duytnguyendtn May 11, 2022
7f15aa5
Use item key to reference list_contents dict to retrieve color; force…
duytnguyendtn May 11, 2022
14fda86
Cleanup dict reset to trigger only one UI change
duytnguyendtn May 11, 2022
6f3f770
Only open active linelist color picker
duytnguyendtn May 11, 2022
e66b87b
Throttle Color Picker
duytnguyendtn May 11, 2022
04e71b5
Add colorpicker tooltip
duytnguyendtn May 11, 2022
ab19003
Move color picker to expansion header
duytnguyendtn May 12, 2022
2ae8ef1
Add tooltip to color picker
duytnguyendtn May 12, 2022
797e798
Add icons to plot/erase all btns; make btns solid
duytnguyendtn May 12, 2022
0182520
Add btn to filter spectral range
duytnguyendtn May 12, 2022
8496baf
Codestyle
duytnguyendtn May 12, 2022
b3b508d
Set spectral range icon to bell curve
duytnguyendtn May 12, 2022
ff07f0d
Add Lines separator
duytnguyendtn May 12, 2022
71ec967
Prevent Linelist header from overflowing; collapse name with ellipsis…
duytnguyendtn May 13, 2022
e40e642
Fit spectral range button on same line as line search
duytnguyendtn May 13, 2022
6a647c7
Update Plot/Erase All Button Styling
duytnguyendtn May 13, 2022
c6b33f0
Condense Rest/Obs Freq textfields
duytnguyendtn May 13, 2022
ee928cf
First pass: Filter on wavelength range
duytnguyendtn May 17, 2022
11c2332
Patch debugging change
duytnguyendtn May 17, 2022
2da06b2
Track spectrum viewer limits by traitlet
duytnguyendtn May 17, 2022
cf3d3f2
Spectral Range btn styling
duytnguyendtn May 17, 2022
4f736d4
Spectral range works independently of text filter
duytnguyendtn May 17, 2022
9121b08
Remove unneeded vue method
duytnguyendtn May 17, 2022
0f3e85d
Codestyle
duytnguyendtn May 17, 2022
8e6c1f6
Clarify Tooltip
duytnguyendtn May 17, 2022
24b9062
Add changelog entry
duytnguyendtn May 17, 2022
df0fe9c
Add new icon and adjust padding
duytnguyendtn May 18, 2022
4e95e9f
Change callback strategy to mitigate race condition
duytnguyendtn May 18, 2022
0de7c25
Codestyle
duytnguyendtn May 18, 2022
974ec84
Replace All Lists plot buttons with new style
duytnguyendtn May 18, 2022
ce21305
Remove number type from rest wavelength display to disable arrow incr…
duytnguyendtn May 18, 2022
f3790ee
Make wavelength fields dense
duytnguyendtn May 19, 2022
6805e41
Move list buttons to top, adjust ordering of line descriptors
duytnguyendtn May 19, 2022
7704546
Introduce manual label to allow bolding of wavelength labels
duytnguyendtn May 19, 2022
9eb4a4c
Add comment to indicate RS slider relying on traitlet value
duytnguyendtn May 19, 2022
b491038
Add missing height directive
duytnguyendtn May 20, 2022
86508d0
Increase padding between line elements
duytnguyendtn May 20, 2022
e5a741e
Fix vertical padding between Line Name and wavelength fields
duytnguyendtn May 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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
-----------

Expand Down
2 changes: 2 additions & 0 deletions jdaviz/components/tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 7 additions & 0 deletions jdaviz/components/tray_plugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
33 changes: 27 additions & 6 deletions jdaviz/configs/default/plugins/line_lists/line_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand All @@ -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):
Expand Down Expand Up @@ -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"]:
Expand All @@ -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

Expand Down
Loading