Skip to content

Commit

Permalink
Revert "testing loop-less methodology to reduce O notation"
Browse files Browse the repository at this point in the history
This reverts commit 26ca5bf.

restoring main to be be up to date with upstream
:wq
  • Loading branch information
Gilbert Green committed Jan 16, 2024
1 parent 8456914 commit b7a60b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
3 changes: 0 additions & 3 deletions jdaviz/configs/cubeviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 0 additions & 16 deletions jdaviz/configs/cubeviz/plugins/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7a60b1

Please sign in to comment.