spacetelescope / cubeviz

Data analysis package for cubes. https://cubeviz.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
15 stars 25 forks source link

Moment calculations need unit propagation #500

Closed brechmos-stsci closed 5 years ago

brechmos-stsci commented 5 years ago

The moment maps calculations do not have units. It seems the underlying spectral-cube moment map calculation has units so it might be something in the code here-in. So, need to see why moment maps calculated in cubeviz are unit-less.

brechmos-stsci commented 5 years ago

I looked at it this afternoon. It is not an issue with spectral-cube. Spectral-cube returns data with units. The problem is that in the code after the moment call we are using data.value and so stripping the units (https://github.com/spacetelescope/cubeviz/blob/master/cubeviz/tools/moment_maps.py#L102). The data.value variable is then passed into another method as component_data and then added to the 2D container (around line https://github.com/spacetelescope/cubeviz/blob/master/cubeviz/tools/common.py#L27). So, I'll have to see about units for the container_2d and/or talk with @astrofrog to see if this is an easy fix.

astrofrog commented 5 years ago

I think the key is that here:

https://github.com/spacetelescope/cubeviz/blob/master/cubeviz/tools/common.py#L27

you should initialize a Component class manually and you can set units on it, then pass that to add_component. The Component initialized takes units:

https://github.com/glue-viz/glue/blob/master/glue/core/component.py#L31

brechmos-stsci commented 5 years ago

One note on this, the cube collapse is affected by this too. So we'll have to make sure any change fixes it as well.

brechmos-stsci commented 5 years ago

Closed by #525