Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion jdaviz/core/loaders/importers/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def assign_component_type(self, comp_id, comp, units, physical_type):
def add_to_data_collection(self, data, data_label=None, data_hash=None,
parent=None,
viewer_select=None,
cls=None):
cls=None,
data_type=None):
"""
Add data to the data collection (and optionally to viewers).

Expand Down Expand Up @@ -386,6 +387,8 @@ def add_to_data_collection(self, data, data_label=None, data_hash=None,
data.meta['_importer'] = self.__class__.__name__
# Create a hashed representation of the data if not already present
data.meta['_data_hash'] = data_hash if data_hash is not None else create_data_hash(data)
if data_type is not None:
data.meta['_data_type'] = data_type

# Add the data to data collection.
self._app.add_data(data, data_label=data_label)
Expand Down
3 changes: 2 additions & 1 deletion jdaviz/core/loaders/importers/spectrum2d/spectrum2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,5 @@ def __call__(self):
self._app.hub.broadcast(msg)

if ext is not None:
self.add_to_data_collection(ext, ext_data_label, viewer_select=self.ext_viewer)
self.add_to_data_collection(ext, ext_data_label, viewer_select=self.ext_viewer,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the data_type info is only being added for the automatic extraction, does this also need to be added in the spectral extraction plugin (or will the importer type there uphold the logic?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugin goes through add_results_from_plugin, which passes through the format and thus goes through the 1D loader.

data_type='1D Spectrum')
3 changes: 2 additions & 1 deletion jdaviz/core/loaders/importers/spectrum3d/spectrum3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ def __call__(self):
self._app.hub.broadcast(msg)

if ext is not None:
self.add_to_data_collection(ext, ext_data_label, viewer_select=self.ext_viewer)
self.add_to_data_collection(ext, ext_data_label, viewer_select=self.ext_viewer,
data_type='1D Spectrum')

if self.has_dq and not self.flux_only:
dq_hdu = self.dq_extension.selected_obj
Expand Down
10 changes: 4 additions & 6 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4869,14 +4869,12 @@ def is_image_or_flux_cube(data):
return (is_image(data) or is_flux_cube(data)) and not is_2d_spectrum_or_trace(data)

def is_spectrum(data):
return (len(data.shape) == 1
and data.coords is not None
and wcs_is_spectral(getattr(data, 'coords', None)))
return (data.meta.get('_importer') == 'SpectrumImporter' or
data.meta.get('_data_type') == '1D Spectrum')

def is_2d_spectrum_or_trace(data):
return (data.ndim == 2
and data.coords is not None
and wcs_is_spectral(getattr(data, 'coords', None))) or 'Trace' in data.meta
return (data.meta.get('_importer') in ('Spectrum2DImporter', 'TraceImporter') and
data.meta.get('_data_type') != '1D Spectrum')

def is_spectrum_or_flux_cube(data):
return is_spectrum(data) or is_flux_cube(data)
Expand Down
Loading