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 Cubeviz parsing DN and DN/s #3298

Merged
merged 1 commit into from
Nov 15, 2024
Merged
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
8 changes: 5 additions & 3 deletions jdaviz/configs/cubeviz/plugins/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from glue_astronomy.translators.spectrum1d import PaddedSpectrumWCS
from numpy.testing import assert_allclose, assert_array_equal

from jdaviz.core.custom_units import PIX2
from jdaviz.utils import PRIHDR_KEY


Expand Down Expand Up @@ -147,8 +148,9 @@ def test_spectrum3d_parse(image_cube_hdu_obj, cubeviz_helper):
assert label_mouseover.as_text() == ('', '', '')


def test_spectrum3d_no_wcs_parse(cubeviz_helper):
sc = Spectrum1D(flux=np.ones(24).reshape((2, 3, 4)) * u.nJy) # x, y, z
@pytest.mark.parametrize("flux_unit", [u.nJy, u.DN, u.DN / u.s])
def test_spectrum3d_no_wcs_parse(cubeviz_helper, flux_unit):
sc = Spectrum1D(flux=np.ones(24).reshape((2, 3, 4)) * flux_unit) # x, y, z
cubeviz_helper.load_data(sc)
assert sc.spectral_axis.unit == u.pix

Expand All @@ -158,7 +160,7 @@ def test_spectrum3d_no_wcs_parse(cubeviz_helper):
assert data.shape == (2, 3, 4) # x, y, z
assert isinstance(data.coords, PaddedSpectrumWCS)
assert_array_equal(flux.data, 1)
assert flux.units == 'nJy / pix2'
assert flux.units == f'{flux_unit / PIX2}'


def test_spectrum1d_parse(spectrum1d, cubeviz_helper):
Expand Down
4 changes: 3 additions & 1 deletion jdaviz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ def _eqv_flux_to_sb_pixel():
u.erg / (u.s * u.cm**2 * u.Angstrom),
u.ph / (u.Angstrom * u.s * u.cm**2),
u.ph / (u.Hz * u.s * u.cm**2),
u.ct]
u.ct,
u.DN,
u.DN / u.s]
return [(flux_unit, flux_unit / PIX2, lambda x: x, lambda x: x)
for flux_unit in flux_units]

Expand Down