spacetelescope / jdaviz

JWST astronomical data analysis tools in the Jupyter platform
https://jdaviz.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
139 stars 74 forks source link

Cubeviz doesn't load Flux units #1625

Open Jdaviz-Triage-Bot opened 2 years ago

Jdaviz-Triage-Bot commented 2 years ago

Reporter: Duy Nguyen

There are two scenarios I found where Cubeviz doesn't load the flux units of a Spectrum1D Cube:

import numpy as np
from astropy import units as u
from specutils import Spectrum1D

from jdaviz import Cubeviz

cubeviz = Cubeviz()

flux = np.arange(16).reshape((2,2,4)) * u.Jy
spec = [1,2,3,4] * u.m
cubeviz.load_data(Spectrum1D(flux=flux, spectral_axis=spec))

cubeviz.show()

🐱


DISCLAIMER: This issue was autocreated by the Jdaviz Issue Creation Bot on behalf of the reporter. If any information is incorrect, please contact Duy Nguyen

pllim commented 2 years ago

This might be an upstream bug. The collapse happens all the way in glue-core and that operation is generic and does not carry the unit through. Maybe @astrofrog can confirm.

https://github.com/glue-viz/glue/blob/f8c1e9646e7252aa13f5f58c4838cb9b670875d3/glue/utils/array.py#L431

kecnry commented 2 years ago

Right, glue does not currently track units (yet) especially during collapse. There is a separate ticket/issue somewhere for having the correct 1d spectrum units as the collapse function is changed (sum and median should result in different output units), but I think this issue is different. This seems to be that the cube object itself is losing/missing units (pre-collapse).