From e2c6006dc00d9a0e256a208d3f580f008570ba06 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Mon, 25 Nov 2024 14:28:28 -0500 Subject: [PATCH 01/12] Track loaded mask cube in cubeviz --- jdaviz/configs/cubeviz/plugins/parsers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdaviz/configs/cubeviz/plugins/parsers.py b/jdaviz/configs/cubeviz/plugins/parsers.py index 715df19f4d..4c8bf995f9 100644 --- a/jdaviz/configs/cubeviz/plugins/parsers.py +++ b/jdaviz/configs/cubeviz/plugins/parsers.py @@ -385,6 +385,8 @@ def _parse_jwst_s3d(app, hdulist, data_label, ext='SCI', app._jdaviz_helper._loaded_flux_cube = app.data_collection[data_label] elif data_type == 'uncert': app._jdaviz_helper._loaded_uncert_cube = app.data_collection[data_label] + elif data_type == 'mask': + app._jdaviz_helper._loaded_mask_cube = app.data_collection[data_label] def _parse_esa_s3d(app, hdulist, data_label, ext='DATA', flux_viewer_reference_name=None): From 2bb381abe709f2a0b2a4cfe0625b2dda00839fea Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Thu, 5 Dec 2024 13:17:03 -0500 Subject: [PATCH 02/12] Don't save DQ array as loaded_mask for JWST --- jdaviz/configs/cubeviz/plugins/parsers.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/jdaviz/configs/cubeviz/plugins/parsers.py b/jdaviz/configs/cubeviz/plugins/parsers.py index 4c8bf995f9..715df19f4d 100644 --- a/jdaviz/configs/cubeviz/plugins/parsers.py +++ b/jdaviz/configs/cubeviz/plugins/parsers.py @@ -385,8 +385,6 @@ def _parse_jwst_s3d(app, hdulist, data_label, ext='SCI', app._jdaviz_helper._loaded_flux_cube = app.data_collection[data_label] elif data_type == 'uncert': app._jdaviz_helper._loaded_uncert_cube = app.data_collection[data_label] - elif data_type == 'mask': - app._jdaviz_helper._loaded_mask_cube = app.data_collection[data_label] def _parse_esa_s3d(app, hdulist, data_label, ext='DATA', flux_viewer_reference_name=None): From 942670bc258fc0bbe4f5613b5a2ae0468cd01ccc Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Mon, 9 Dec 2024 13:06:42 -0500 Subject: [PATCH 03/12] Add extraction test on file with mask --- .../cubeviz/plugins/tests/test_parsers.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index 8f0d2fc9d5..d0070b08ed 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -208,6 +208,24 @@ def test_numpy_cube(cubeviz_helper): assert isinstance(data.coords, PaddedSpectrumWCS) assert flux.units == 'ct / pix2' +@pytest.mark.remote_data +def test_manga_cube(cubeviz_helper): + # Remote data test of loading and extracting an up-to-date (as of 11/19/2024) MaNGA cube + # This also tests that spaxel is converted to pix**2 + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + cubeviz_helper.load_data("https://stsci.box.com/shared/static/gts87zqt5265msuwi4w5u003b6typ6h0.gz", cache=True) # noqa + + uc = cubeviz_helper.plugins['Unit Conversion'] + uc.spectral_y_type = "Surface Brightness" + + se = cubeviz_helper.plugins['Spectral Extraction'] + se.function = "Mean" + se.extract() + extracted_max = cubeviz_helper.get_data("Spectrum (mean)").max() + assert_allclose(extracted_max.value, 2.836957E-18) + assert extracted_max.unit == u.Unit("erg / Angstrom s cm**2 pix**2") + @pytest.mark.remote_data def test_manga_cube(cubeviz_helper): From cbe230d229a4599ca9bcfbe4e340efa30cdd4fee Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Mon, 9 Dec 2024 13:18:18 -0500 Subject: [PATCH 04/12] Codestyle --- jdaviz/configs/cubeviz/plugins/tests/test_parsers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index d0070b08ed..970215d485 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -208,6 +208,7 @@ def test_numpy_cube(cubeviz_helper): assert isinstance(data.coords, PaddedSpectrumWCS) assert flux.units == 'ct / pix2' + @pytest.mark.remote_data def test_manga_cube(cubeviz_helper): # Remote data test of loading and extracting an up-to-date (as of 11/19/2024) MaNGA cube From ce319a05417c7a128de4404cc33cb3450848f5b4 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Fri, 13 Dec 2024 16:49:02 -0500 Subject: [PATCH 05/12] Add consideration of loaded mask to aperture weight mask --- .../spectral_extraction.py | 14 +++++----- .../cubeviz/plugins/tests/test_parsers.py | 26 ++++++++++++++++--- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index da18a12e40..256c25a1fe 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -386,14 +386,14 @@ def slice_display_unit(self): return astropy.units.Unit(self.app._get_display_unit(self.slice_display_unit_name)) @property - def mask_non_science(self): + def inverted_mask_non_science(self): # Aperture masks begin by removing from consideration any pixel # set to NaN, which corresponds to a pixel on the "non-science" portions # of the detector. For JWST spectral cubes, these pixels are also marked in - # the DQ array with flag `513`. - return np.logical_not( - np.isnan(self.dataset.selected_obj.flux.value) - ).astype(float) + # the DQ array with flag `513`. Also respect the loaded mask, if it exists + nan_mask = np.isnan(self.dataset.selected_obj.flux.value) + return np.logical_not(np.logical_or(self.mask_cube.get_component('flux').data, + nan_mask)).astype(float) @property def aperture_weight_mask(self): @@ -402,10 +402,10 @@ def aperture_weight_mask(self): # wavelength, on the range [0, 1]. if self.aperture.selected == self.aperture.default_text: # Entire Cube - return self.mask_non_science + return self.inverted_mask_non_science return ( - self.mask_non_science * + self.inverted_mask_non_science * self.aperture.get_mask( self.dataset.selected_obj, self.aperture_method_selected, diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index 970215d485..19fe1e7b17 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -209,10 +209,30 @@ def test_numpy_cube(cubeviz_helper): assert flux.units == 'ct / pix2' +def test_loading_with_mask(cubeviz_helper): + # This also tests that spaxel is converted to pix**2 + custom_spec = Spectrum1D(flux=[[[20, 1],[9, 1]],[[3, 1],[6, 5]]] * u.Unit("erg / Angstrom s cm**2 spaxel"), # noqa + spectral_axis = [1, 2]*u.AA, + mask=[[[1, 0],[0, 0]],[[0, 0],[0, 0]]]) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + cubeviz_helper.load_data(custom_spec) + #cubeviz_helper.load_data("https://stsci.box.com/shared/static/gts87zqt5265msuwi4w5u003b6typ6h0.gz", cache=True) # noqa + + uc = cubeviz_helper.plugins['Unit Conversion'] + uc.spectral_y_type = "Surface Brightness" + + se = cubeviz_helper.plugins['Spectral Extraction'] + se.function = "Mean" + se.extract() + extracted = cubeviz_helper.get_data("Spectrum (mean)") + assert_allclose(extracted.flux.value, [6, 2]) + assert extracted.unit == u.Unit("erg / Angstrom s cm**2 pix**2") + + @pytest.mark.remote_data -def test_manga_cube(cubeviz_helper): +def test_manga_with_mask(cubeviz_helper): # Remote data test of loading and extracting an up-to-date (as of 11/19/2024) MaNGA cube - # This also tests that spaxel is converted to pix**2 with warnings.catch_warnings(): warnings.filterwarnings("ignore") cubeviz_helper.load_data("https://stsci.box.com/shared/static/gts87zqt5265msuwi4w5u003b6typ6h0.gz", cache=True) # noqa @@ -224,7 +244,7 @@ def test_manga_cube(cubeviz_helper): se.function = "Mean" se.extract() extracted_max = cubeviz_helper.get_data("Spectrum (mean)").max() - assert_allclose(extracted_max.value, 2.836957E-18) + assert_allclose(extracted_max.value, 5.566169e-18) assert extracted_max.unit == u.Unit("erg / Angstrom s cm**2 pix**2") From ac9d6080ba9578494f8bbb61ffcaa01212f3f377 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Fri, 13 Dec 2024 16:57:01 -0500 Subject: [PATCH 06/12] Remove duplicate test, codestyle --- .../spectral_extraction.py | 2 +- .../cubeviz/plugins/tests/test_parsers.py | 26 +++---------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index 256c25a1fe..f04bc7b620 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -391,7 +391,7 @@ def inverted_mask_non_science(self): # set to NaN, which corresponds to a pixel on the "non-science" portions # of the detector. For JWST spectral cubes, these pixels are also marked in # the DQ array with flag `513`. Also respect the loaded mask, if it exists - nan_mask = np.isnan(self.dataset.selected_obj.flux.value) + nan_mask = np.isnan(self.dataset.selected_obj.flux.value) return np.logical_not(np.logical_or(self.mask_cube.get_component('flux').data, nan_mask)).astype(float) diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index 19fe1e7b17..e3dc62c29f 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -211,9 +211,9 @@ def test_numpy_cube(cubeviz_helper): def test_loading_with_mask(cubeviz_helper): # This also tests that spaxel is converted to pix**2 - custom_spec = Spectrum1D(flux=[[[20, 1],[9, 1]],[[3, 1],[6, 5]]] * u.Unit("erg / Angstrom s cm**2 spaxel"), # noqa - spectral_axis = [1, 2]*u.AA, - mask=[[[1, 0],[0, 0]],[[0, 0],[0, 0]]]) + custom_spec = Spectrum1D(flux=[[[20, 1], [9, 1]], [[3, 1], [6, 5]]] * u.Unit("erg / Angstrom s cm**2 spaxel"), # noqa + spectral_axis=[1, 2]*u.AA, + mask=[[[1, 0], [0, 0]], [[0, 0], [0, 0]]]) with warnings.catch_warnings(): warnings.filterwarnings("ignore") cubeviz_helper.load_data(custom_spec) @@ -232,24 +232,6 @@ def test_loading_with_mask(cubeviz_helper): @pytest.mark.remote_data def test_manga_with_mask(cubeviz_helper): - # Remote data test of loading and extracting an up-to-date (as of 11/19/2024) MaNGA cube - with warnings.catch_warnings(): - warnings.filterwarnings("ignore") - cubeviz_helper.load_data("https://stsci.box.com/shared/static/gts87zqt5265msuwi4w5u003b6typ6h0.gz", cache=True) # noqa - - uc = cubeviz_helper.plugins['Unit Conversion'] - uc.spectral_y_type = "Surface Brightness" - - se = cubeviz_helper.plugins['Spectral Extraction'] - se.function = "Mean" - se.extract() - extracted_max = cubeviz_helper.get_data("Spectrum (mean)").max() - assert_allclose(extracted_max.value, 5.566169e-18) - assert extracted_max.unit == u.Unit("erg / Angstrom s cm**2 pix**2") - - -@pytest.mark.remote_data -def test_manga_cube(cubeviz_helper): # Remote data test of loading and extracting an up-to-date (as of 11/19/2024) MaNGA cube # This also tests that spaxel is converted to pix**2 with warnings.catch_warnings(): @@ -263,7 +245,7 @@ def test_manga_cube(cubeviz_helper): se.function = "Mean" se.extract() extracted_max = cubeviz_helper.get_data("Spectrum (mean)").max() - assert_allclose(extracted_max.value, 2.836957E-18) + assert_allclose(extracted_max.value, 5.566169e-18) assert extracted_max.unit == u.Unit("erg / Angstrom s cm**2 pix**2") From 7b8df51df2714dc0575bf48fa6383f6c3677ee82 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Fri, 13 Dec 2024 17:07:13 -0500 Subject: [PATCH 07/12] Changelog --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 01e6579375..4d193d7f5b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -114,7 +114,7 @@ Cubeviz - Fixed initializing a Gaussian1D model component when ``Cube Fit`` is toggled on. [#3295] -- Spectral extraction now correctly respects the loaded mask cube. [#3319] +- Spectral extraction now correctly respects the loaded mask cube. [#3319, #3358] Imviz ^^^^^ From 08691b6b91d36f753eac97f3356c130344a85dae Mon Sep 17 00:00:00 2001 From: Ricky O'Steen <39831871+rosteen@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:18:44 -0500 Subject: [PATCH 08/12] Update jdaviz/configs/cubeviz/plugins/tests/test_parsers.py Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> --- jdaviz/configs/cubeviz/plugins/tests/test_parsers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index e3dc62c29f..3c1363fd62 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -217,7 +217,6 @@ def test_loading_with_mask(cubeviz_helper): with warnings.catch_warnings(): warnings.filterwarnings("ignore") cubeviz_helper.load_data(custom_spec) - #cubeviz_helper.load_data("https://stsci.box.com/shared/static/gts87zqt5265msuwi4w5u003b6typ6h0.gz", cache=True) # noqa uc = cubeviz_helper.plugins['Unit Conversion'] uc.spectral_y_type = "Surface Brightness" From 13a0cc3e7c7e168e547e0e3d75ee3254cf37e35e Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Mon, 16 Dec 2024 09:42:45 -0500 Subject: [PATCH 09/12] Cast this as bool here --- .../cubeviz/plugins/spectral_extraction/spectral_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index f04bc7b620..adfde3eda3 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -392,7 +392,7 @@ def inverted_mask_non_science(self): # of the detector. For JWST spectral cubes, these pixels are also marked in # the DQ array with flag `513`. Also respect the loaded mask, if it exists nan_mask = np.isnan(self.dataset.selected_obj.flux.value) - return np.logical_not(np.logical_or(self.mask_cube.get_component('flux').data, + return np.logical_not(np.logical_or(self.mask_cube.get_component('flux').data.astype(bool), nan_mask)).astype(float) @property From 238d9999f6d38ee8ea78c545fb50ee799f5a3bd4 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Mon, 16 Dec 2024 10:49:09 -0500 Subject: [PATCH 10/12] Fix tests, address review comments --- .../plugins/spectral_extraction/spectral_extraction.py | 10 ++++++---- jdaviz/configs/cubeviz/plugins/tests/test_parsers.py | 8 +++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index adfde3eda3..07761e66e8 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -391,9 +391,11 @@ def inverted_mask_non_science(self): # set to NaN, which corresponds to a pixel on the "non-science" portions # of the detector. For JWST spectral cubes, these pixels are also marked in # the DQ array with flag `513`. Also respect the loaded mask, if it exists - nan_mask = np.isnan(self.dataset.selected_obj.flux.value) - return np.logical_not(np.logical_or(self.mask_cube.get_component('flux').data.astype(bool), - nan_mask)).astype(float) + mask_non_science = np.isnan(self.dataset.selected_obj.flux.value) + if self.mask_cube is not None: + mask_non_science = np.logical_or(self.mask_cube.get_component('flux').data, + mask_non_science) + return np.logical_not(mask_non_science).astype(float) @property def aperture_weight_mask(self): @@ -421,7 +423,7 @@ def bg_weight_mask(self): return np.zeros_like(self.dataset.selected_obj.flux.value) return ( - self.mask_non_science * + self.inverted_mask_non_science * self.background.get_mask( self.dataset.selected_obj, self.aperture_method_selected, diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index 3c1363fd62..380e3f9f10 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -211,12 +211,10 @@ def test_numpy_cube(cubeviz_helper): def test_loading_with_mask(cubeviz_helper): # This also tests that spaxel is converted to pix**2 - custom_spec = Spectrum1D(flux=[[[20, 1], [9, 1]], [[3, 1], [6, 5]]] * u.Unit("erg / Angstrom s cm**2 spaxel"), # noqa + custom_spec = Spectrum1D(flux=[[[20, 1], [9, 1]], [[3, 1], [6, np.nan]]] * u.Unit("erg / Angstrom s cm**2 spaxel"), # noqa spectral_axis=[1, 2]*u.AA, mask=[[[1, 0], [0, 0]], [[0, 0], [0, 0]]]) - with warnings.catch_warnings(): - warnings.filterwarnings("ignore") - cubeviz_helper.load_data(custom_spec) + cubeviz_helper.load_data(custom_spec) uc = cubeviz_helper.plugins['Unit Conversion'] uc.spectral_y_type = "Surface Brightness" @@ -225,7 +223,7 @@ def test_loading_with_mask(cubeviz_helper): se.function = "Mean" se.extract() extracted = cubeviz_helper.get_data("Spectrum (mean)") - assert_allclose(extracted.flux.value, [6, 2]) + assert_allclose(extracted.flux.value, [6, 1]) assert extracted.unit == u.Unit("erg / Angstrom s cm**2 pix**2") From 2cb3108fdedfe2afbf262b357c32bce5ec7879ed Mon Sep 17 00:00:00 2001 From: "Brett M. Morris" Date: Mon, 16 Dec 2024 13:17:17 -0500 Subject: [PATCH 11/12] adding regression tests to manga mask --- .../cubeviz/plugins/tests/test_parsers.py | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index 380e3f9f10..dd3e587628 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -228,7 +228,15 @@ def test_loading_with_mask(cubeviz_helper): @pytest.mark.remote_data -def test_manga_with_mask(cubeviz_helper): +@pytest.mark.parametrize( + 'function, expected_value,', + ( + ('Mean', 5.566169e-18), + ('Sum', 1.553518e-14), + ('Max', 1e20), + ) +) +def test_manga_with_mask(cubeviz_helper, function, expected_value): # Remote data test of loading and extracting an up-to-date (as of 11/19/2024) MaNGA cube # This also tests that spaxel is converted to pix**2 with warnings.catch_warnings(): @@ -239,11 +247,14 @@ def test_manga_with_mask(cubeviz_helper): uc.spectral_y_type = "Surface Brightness" se = cubeviz_helper.plugins['Spectral Extraction'] - se.function = "Mean" + se.function = function se.extract() - extracted_max = cubeviz_helper.get_data("Spectrum (mean)").max() - assert_allclose(extracted_max.value, 5.566169e-18) - assert extracted_max.unit == u.Unit("erg / Angstrom s cm**2 pix**2") + extracted_max = cubeviz_helper.get_data(f"Spectrum ({function.lower()})").max() + assert_allclose(extracted_max.value, expected_value, rtol=5e-7) + if function == "Sum": + assert extracted_max.unit == u.Unit("erg / Angstrom s cm**2") + else: + assert extracted_max.unit == u.Unit("erg / Angstrom s cm**2 pix**2") def test_invalid_data_types(cubeviz_helper): From e57ef8360cc92bb9b3a340fb6b40b68108d3210c Mon Sep 17 00:00:00 2001 From: Ricky O'Steen <39831871+rosteen@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:23:55 -0500 Subject: [PATCH 12/12] Update jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py Co-authored-by: Brett M. Morris --- .../cubeviz/plugins/spectral_extraction/spectral_extraction.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index 07761e66e8..c1f87223cc 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -390,7 +390,8 @@ def inverted_mask_non_science(self): # Aperture masks begin by removing from consideration any pixel # set to NaN, which corresponds to a pixel on the "non-science" portions # of the detector. For JWST spectral cubes, these pixels are also marked in - # the DQ array with flag `513`. Also respect the loaded mask, if it exists + # the DQ array with flag `513`. Also respect the loaded mask, if it exists. + # This "inverted mask" is `True` where the data are included, `False` where excluded. mask_non_science = np.isnan(self.dataset.selected_obj.flux.value) if self.mask_cube is not None: mask_non_science = np.logical_or(self.mask_cube.get_component('flux').data,