Skip to content

Commit

Permalink
Merge pull request #2854 from bmorris3/cubeviz-dq-bugfix
Browse files Browse the repository at this point in the history
Prevent composite array calls on subsets
  • Loading branch information
bmorris3 authored May 7, 2024
2 parents d040c6c + bcea12f commit ded416e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,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)

0 comments on commit ded416e

Please sign in to comment.