From 4e328c4e80e43d8bdce535552c1b7cd980502673 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 19 Apr 2024 09:34:11 -0400 Subject: [PATCH] consolidate cubeviz/imviz logic --- jdaviz/configs/cubeviz/helper.py | 5 ----- jdaviz/configs/cubeviz/plugins/viewers.py | 1 - jdaviz/configs/imviz/helper.py | 6 +++++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/jdaviz/configs/cubeviz/helper.py b/jdaviz/configs/cubeviz/helper.py index d0f5f2c89e..1b6df6f293 100644 --- a/jdaviz/configs/cubeviz/helper.py +++ b/jdaviz/configs/cubeviz/helper.py @@ -2,7 +2,6 @@ from astropy.io import fits from astropy.io import registry as io_registry from astropy.utils.decorators import deprecated -from glue.core import BaseData from specutils import Spectrum1D from specutils.io.registers import _astropy_has_priorities @@ -181,10 +180,6 @@ def get_aperture_photometry_results(self): return self.plugins['Aperture Photometry']._obj.export_table() -def layer_is_cube_image_data(layer): - return isinstance(layer, BaseData) and layer.ndim in (2, 3) - - # TODO: We can remove this when specutils supports it, i.e., # https://github.com/astropy/specutils/issues/592 and # https://github.com/astropy/specutils/pull/1009 diff --git a/jdaviz/configs/cubeviz/plugins/viewers.py b/jdaviz/configs/cubeviz/plugins/viewers.py index 8db4bf72b3..8d1316af80 100644 --- a/jdaviz/configs/cubeviz/plugins/viewers.py +++ b/jdaviz/configs/cubeviz/plugins/viewers.py @@ -9,7 +9,6 @@ from jdaviz.core.registries import viewer_registry from jdaviz.core.marks import SliceIndicatorMarks, ShadowSpatialSpectral -from jdaviz.configs.cubeviz.helper import layer_is_cube_image_data from jdaviz.configs.default.plugins.viewers import JdavizViewerMixin from jdaviz.configs.specviz.plugins.viewers import SpecvizProfileView from jdaviz.core.events import AddDataMessage, RemoveDataMessage, GlobalDisplayUnitChanged diff --git a/jdaviz/configs/imviz/helper.py b/jdaviz/configs/imviz/helper.py index 11e04c6161..f2d5310a6e 100644 --- a/jdaviz/configs/imviz/helper.py +++ b/jdaviz/configs/imviz/helper.py @@ -398,8 +398,12 @@ def layer_is_2d(layer): return isinstance(layer, BaseData) and layer.ndim == 2 +def layer_is_2d_or_3d(layer): + return isinstance(layer, BaseData) and layer.ndim in (2, 3) + + def layer_is_image_data(layer): - return layer_is_2d(layer) and not layer.meta.get(_wcs_only_label, False) + return layer_is_2d_or_3d(layer) and not layer.meta.get(_wcs_only_label, False) def layer_is_wcs_only(layer):