diff --git a/jdaviz/configs/cubeviz/plugins/parsers.py b/jdaviz/configs/cubeviz/plugins/parsers.py index 93cacf7df8..3eedd04b66 100644 --- a/jdaviz/configs/cubeviz/plugins/parsers.py +++ b/jdaviz/configs/cubeviz/plugins/parsers.py @@ -324,7 +324,7 @@ def _parse_spectrum1d_3d(app, file_obj, data_label=None): def _parse_spectrum1d(app, file_obj, data_label=None): if data_label is None: # data_label = "Unknown spectrum object" - data_label = return_data_label(app, file_obj, ext="1d") + data_label = return_data_label(app, file_obj) # TODO: glue-astronomy translators only look at the flux property of # specutils Spectrum1D objects. Fix to support uncertainties and masks. diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index b5bad49057..a517f838cf 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -158,7 +158,7 @@ def test_spectrum1d_parse(spectrum1d, cubeviz_helper): cubeviz_helper.load_data(spectrum1d) assert len(cubeviz_helper.app.data_collection) == 1 - assert cubeviz_helper.app.data_collection[0].label.endswith('[1d]') + assert cubeviz_helper.app.data_collection[0].label.endswith('Spectrum1D') assert cubeviz_helper.app.data_collection[0].meta['uncertainty_type'] == 'std' # Coordinate display is only for spatial image, which is missing here. diff --git a/jdaviz/core/helpers.py b/jdaviz/core/helpers.py index 66b98dee5d..5057ccb64e 100644 --- a/jdaviz/core/helpers.py +++ b/jdaviz/core/helpers.py @@ -676,8 +676,7 @@ def return_data_label(app, loaded_object, ext=None): from specutils import Spectrum1D data_label = "Unknown" - if ext is None: - pass + if loaded_object is None: pass elif isinstance(loaded_object, str): @@ -686,18 +685,21 @@ def return_data_label(app, loaded_object, ext=None): file_format = loaded_object.lower().split(".")[-1] data_label = f"{loaded_object}[{file_format}]" else: - data_label = f"{loaded_object}[{ext}]" + data_label = f"{loaded_object}" elif isinstance(loaded_object, fits.hdu.hdulist.HDUList): if hasattr(loaded_object, 'file_name'): data_label = f"{loaded_object.file_name}[HDU object]" else: data_label = "Unknown HDU object" elif isinstance(loaded_object, Spectrum1D): - data_label = f"Spectrum1D[{ext}]" + data_label = f"Spectrum1D" elif isinstance(loaded_object, NDData): - data_label = f"NDData[{ext}]" + data_label = f"NDData" elif isinstance(loaded_object, np.array): - data_label = f"Array[{ext}]" + data_label = f"Array" + + if ext is not None: + data_label = data_label + f"[{ext}]" data_label = return_unique_name(app, data_label)