Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix parsing of MANGA cube #3115

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 15 additions & 5 deletions jdaviz/configs/cubeviz/plugins/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@

is_loaded = []
wcs_sci = None
bunit_sci = None

# TODO: This needs refactoring to be more robust.
# Current logic fails if there are multiple EXTVER.
Expand All @@ -250,18 +251,27 @@
else:
wcs = wcs_sci

if 'BUNIT' in hdu.header:
if data_type == 'mask': # DQ flags have no unit
flux_unit = u.dimensionless_unscaled
elif 'BUNIT' in hdu.header:
try:
flux_unit = u.Unit(hdu.header['BUNIT'])
except Exception:
logging.warning("Invalid BUNIT, using count as data unit")
if data_type == 'flux':
logging.warning("Invalid BUNIT, using count as data unit")

Check warning on line 261 in jdaviz/configs/cubeviz/plugins/parsers.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/parsers.py#L260-L261

Added lines #L260 - L261 were not covered by tests
flux_unit = u.count
elif data_type == 'mask': # DQ flags have no unit
flux_unit = u.dimensionless_unscaled
else:
logging.warning("Invalid BUNIT, using count as data unit")
if data_type == 'flux':
logging.warning("Invalid BUNIT, using count as data unit")

Check warning on line 265 in jdaviz/configs/cubeviz/plugins/parsers.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/parsers.py#L264-L265

Added lines #L264 - L265 were not covered by tests
flux_unit = u.count

# Force uncertainty unit to follow science extension when count detected.
if data_type == 'flux':
bunit_sci = flux_unit
# TODO: Is this assumption safe? There are many types of uncertainty.
elif (data_type == 'uncert') and bunit_sci and (flux_unit == u.count):
flux_unit = bunit_sci

Check warning on line 273 in jdaviz/configs/cubeviz/plugins/parsers.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/parsers.py#L273

Added line #L273 was not covered by tests

flux = hdu.data << flux_unit

metadata = standardize_metadata(hdu.header)
Expand Down
Loading