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

Improve live-collapsed spectrum contrast in cubeviz #2387

Merged
merged 5 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Mosviz
Specviz
^^^^^^^

- Improve visibility of live-collapsed spectra from spatial regions in Cubeviz [#2387]

Specviz2d
^^^^^^^^^

Expand Down
16 changes: 16 additions & 0 deletions jdaviz/configs/cubeviz/plugins/viewers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from glue.core import BaseData

from glue.core.subset_group import GroupedSubset
from bqplot import Lines
from glue_jupyter.bqplot.image import BqplotImageView

from jdaviz.core.registries import viewer_registry
Expand Down Expand Up @@ -229,6 +230,21 @@ def _is_unique(m):
if _is_unique(new_shadow):
new_marks.append(new_shadow)

# change opacity for live-collapsed spectra from spatial subsets in Cubeviz:
spatial_layers = [sub_layer for sub_layer in
self._get_spatial_subset_layers(layer_state.layer.data.label)]
spatial_marks = self._get_marks_for_layers(spatial_layers)
for layer, mark in zip(spatial_layers, spatial_marks):
# update profile opacities for spatial subset:
if isinstance(mark, Lines):
mark.set_trait(
'opacities',
# set the alpha for the spectrum in the profile viewer
# to be 50% more opaque than the alpha for the spatial subset
# in the flux-viewer
[min(1.5 * layer.alpha, 1)]
)

elif subset_type == 'spectral':
# need to add marks for every intersection between THIS spectral subset and ALL spatial
# subset marks corresponding to this data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from astropy.visualization import PercentileInterval
from traitlets import Any, Dict, Float, Bool, Int, List, Unicode, observe

from glue.core.subset_group import GroupedSubset
from glue.viewers.scatter.state import ScatterViewerState
from glue.viewers.profile.state import ProfileViewerState, ProfileLayerState
from glue.viewers.image.state import ImageSubsetLayerState
Expand Down Expand Up @@ -535,7 +536,7 @@ def _update_stretch_histogram(self, msg={}):
# no (image) viewer with stretch function options
return

if (not self.viewer.selected or not self.layer.selected): # pragma: no cover
if not self.viewer.selected or not self.layer.selected: # pragma: no cover
# nothing to plot
self.stretch_histogram.clear_all_marks()
return
Expand Down Expand Up @@ -579,6 +580,10 @@ def _update_stretch_histogram(self, msg={}):
# skip further updates if no data are available:
return

if isinstance(data, GroupedSubset):
# don't update histogram for subsets:
return

comp = data.get_component(data.main_components[0])

# TODO: further optimization could be done by caching sub_data
Expand Down