Skip to content

Commit

Permalink
Move addition of ext keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
javerbukh committed Sep 23, 2022
1 parent 1d6e5f4 commit 6a11934
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion jdaviz/configs/cubeviz/plugins/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/cubeviz/plugins/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 8 additions & 6 deletions jdaviz/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

Expand Down

0 comments on commit 6a11934

Please sign in to comment.