Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Prevent composite array calls on subsets #2854

Merged
merged 1 commit into from
May 7, 2024
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
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ Bug Fixes
Cubeviz
^^^^^^^

- Fix Data Quality plugin bug that attempted to apply array compositing logic to
spatial subsets. [#2854]

Imviz
^^^^^

Expand Down
6 changes: 4 additions & 2 deletions jdaviz/configs/default/plugins/data_quality/data_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ def init_decoding(self, event={}, viewers=None):
self.app._jdaviz_helper._default_uncert_viewer_reference_name
)
for layer in uncert_viewer.layers:
layer.composite._allow_bad_alpha = True
layer.force_update()
# allow bad alpha for image layers, not subsets:
if not hasattr(layer, 'subset_array'):
layer.composite._allow_bad_alpha = True
layer.force_update()

flag_bits = np.array([flag['flag'] for flag in self.decoded_flags])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
from astroquery.mast import Observations
from stdatamodels.jwst.datamodels.dqflags import pixel as pixel_jwst
from glue.core.subset import RectangularROI

from jdaviz.configs.imviz.plugins.parsers import HAS_ROMAN_DATAMODELS
from jdaviz.configs.default.plugins.data_quality.dq_utils import (
Expand Down Expand Up @@ -212,3 +213,35 @@ def test_data_quality_plugin_hst_acs(imviz_helper, tmp_path):
flag_map_selected[0]['description'] ==
'Reed-Solomon decoding error; e.g. data lost during compression.'
)


@pytest.mark.remote_data
def test_cubeviz_layer_visibility_bug(cubeviz_helper, tmp_path):
# regression test for bug:
uri = "mast:JWST/product/jw02732-o004_t004_miri_ch1-shortmediumlong_s3d.fits"
download_path = str(tmp_path / Path(uri).name)
Observations.download_file(uri, local_path=download_path)

with warnings.catch_warnings():
warnings.simplefilter("ignore")
cubeviz_helper.load_data(download_path)

# create a moment map:
mm = cubeviz_helper.plugins['Moment Maps']
mm.n_moment = 1
mm.reference_wavelength = 6
mm._obj.add_to_viewer_selected = 'uncert-viewer'
mm.calculate_moment()

# add the moment map to the flux viewer
dc = cubeviz_helper.app.data_collection
viewer = cubeviz_helper.app.get_viewer('flux-viewer')
viewer.add_data(dc[-1])

# create a spatial subset in the flux-viewer
roi = RectangularROI(22, 27, 22, 30)
viewer.apply_roi(roi)

# toggle layer visibility, this used to trigger an AttributeError:
cubeviz_helper.app.set_data_visibility('flux-viewer', dc[-1].label)
cubeviz_helper.app.set_data_visibility('flux-viewer', dc[0].label)