From b7a60b154e8096930af64cff491d5973a9e3c7fd Mon Sep 17 00:00:00 2001 From: Gilbert Green Date: Tue, 16 Jan 2024 15:53:09 -0500 Subject: [PATCH] Revert "testing loop-less methodology to reduce O notation" This reverts commit 26ca5bfc7c37d7039bab1108b3f88d4fc06bdcc3. restoring main to be be up to date with upstream :wq --- jdaviz/configs/cubeviz/helper.py | 3 --- jdaviz/configs/cubeviz/plugins/parsers.py | 16 ---------------- .../spectral_extraction/spectral_extraction.py | 11 +++++++++-- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/jdaviz/configs/cubeviz/helper.py b/jdaviz/configs/cubeviz/helper.py index 2846cfe008..f1d8ac4d8f 100644 --- a/jdaviz/configs/cubeviz/helper.py +++ b/jdaviz/configs/cubeviz/helper.py @@ -22,9 +22,6 @@ class Cubeviz(ImageConfigHelper, LineListMixin): _default_flux_viewer_reference_name = "flux-viewer" _default_image_viewer_reference_name = "image-viewer" - _loaded_flux_cube = None - _loaded_uncert_cube = None - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.app.hub.subscribe(self, AddDataMessage, diff --git a/jdaviz/configs/cubeviz/plugins/parsers.py b/jdaviz/configs/cubeviz/plugins/parsers.py index 8d14a575ac..e552366dc3 100644 --- a/jdaviz/configs/cubeviz/plugins/parsers.py +++ b/jdaviz/configs/cubeviz/plugins/parsers.py @@ -258,14 +258,12 @@ def _parse_hdulist(app, hdulist, file_name=None, elif data_type == 'uncert': app.add_data_to_viewer(uncert_viewer_reference_name, data_label) - app._jdaviz_helper._loaded_uncert_cube = app.data_collection[data_label] else: # flux # Add flux to top left image viewer app.add_data_to_viewer(flux_viewer_reference_name, data_label) # Add flux to spectrum viewer app.add_data_to_viewer(spectrum_viewer_reference_name, data_label) - app._jdaviz_helper._loaded_flux_cube = app.data_collection[data_label] def _parse_jwst_s3d(app, hdulist, data_label, ext='SCI', @@ -315,11 +313,6 @@ def _parse_jwst_s3d(app, hdulist, data_label, ext='SCI', if viewer_name == flux_viewer_reference_name: app.add_data_to_viewer(spectrum_viewer_reference_name, data_label) - if data_type == 'flux': - 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] - def _parse_esa_s3d(app, hdulist, data_label, ext='DATA', flux_viewer_reference_name=None, spectrum_viewer_reference_name=None): @@ -366,11 +359,6 @@ def _parse_esa_s3d(app, hdulist, data_label, ext='DATA', flux_viewer_reference_n app.add_data_to_viewer(flux_viewer_reference_name, data_label) app.add_data_to_viewer(spectrum_viewer_reference_name, data_label) - if data_type == 'flux': - app._jdaviz_helper._loaded_flux_cube = app.data_collection[data_label] - if data_type == 'uncert': - app._jdaviz_helper._loaded_uncert_cube = app.data_collection[data_label] - def _parse_spectrum1d_3d(app, file_obj, data_label=None, flux_viewer_reference_name=None, spectrum_viewer_reference_name=None, @@ -418,10 +406,8 @@ def _parse_spectrum1d_3d(app, file_obj, data_label=None, if attr == 'flux': app.add_data_to_viewer(flux_viewer_reference_name, cur_data_label) app.add_data_to_viewer(spectrum_viewer_reference_name, cur_data_label) - app._jdaviz_helper._loaded_flux_cube = app.data_collection[cur_data_label] elif attr == 'uncertainty': app.add_data_to_viewer(uncert_viewer_reference_name, cur_data_label) - app._jdaviz_helper._loaded_uncert_cube = app.data_collection[cur_data_label] # We no longer auto-populate the mask cube into a viewer @@ -466,10 +452,8 @@ def _parse_ndarray(app, file_obj, data_label=None, data_type=None, if data_type == 'flux': app.add_data_to_viewer(flux_viewer_reference_name, data_label) app.add_data_to_viewer(spectrum_viewer_reference_name, data_label) - app._jdaviz_helper._loaded_flux_cube = app.data_collection[data_label] elif data_type == 'uncert': app.add_data_to_viewer(uncert_viewer_reference_name, data_label) - app._jdaviz_helper._loaded_uncert_cube = app.data_collection[data_label] def _parse_gif(app, file_obj, data_label=None, flux_viewer_reference_name=None, diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index acaee9a9ed..e95156ed47 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -114,8 +114,15 @@ def collapse_to_spectrum(self, add_data=True, **kwargs): Additional keyword arguments passed to the NDDataArray collapse operation. Examples include ``propagate_uncertainties`` and ``operation_ignores_mask``. """ - spectral_cube = self._app._jdaviz_helper._loaded_flux_cube - uncert_cube = self._app._jdaviz_helper._loaded_uncert_cube + # get glue Data objects for the spectral cube and uncertainties + flux_viewer = self._app.get_viewer( + self._app._jdaviz_helper._default_flux_viewer_reference_name + ) + uncert_viewer = self._app.get_viewer( + self._app._jdaviz_helper._default_uncert_viewer_reference_name + ) + [spectral_cube] = flux_viewer.data() + [uncert_cube] = uncert_viewer.data() # This plugin collapses over the *spatial axes* (optionally over a spatial subset, # defaults to ``No Subset``). Since the Cubeviz parser puts the fluxes