spacetelescope / jdaviz

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

stop counts cube from entering translator #3136

Open gibsongreen opened 2 months ago

gibsongreen commented 2 months ago

Description

On app startup, when a cube with u.count units is loaded into Cubeviz, the flux_or_sb_selected is set to 'Flux'. This would then trigger _on_flux_unit_changed(), and enter the condition for translating. An additional condition has been added to ensure that flux_or_sb_selected can be set without entering the translator when the native units are in counts.

Change log entry

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 88.82%. Comparing base (f4a6889) to head (1aa60fa).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3136 +/- ## ======================================= Coverage 88.82% 88.82% ======================================= Files 112 112 Lines 17430 17430 ======================================= Hits 15482 15482 Misses 1948 1948 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

pllim commented 2 months ago

Thanks. Is there a way to test this in the CI, preferably without remote data?

kecnry commented 1 month ago

Eventually we want a cube in counts to be coerced into counts/pix**2 ("surface brightness" units) and for SB<>flux to still work to toggle between counts/pix**2 and counts. This is probably covered under @cshanahan1's current work, but its not clear to me how this PR fits into that (will it need to be reverted once coercing cubes from flux into SB is implemented?).

gibsongreen commented 1 month ago

Eventually we want a cube in counts to be coerced into counts/pix**2 ("surface brightness" units) and for SB<>flux to still work to toggle between counts/pix**2 and counts. This is probably covered under @cshanahan1's current work, but its not clear to me how this PR fits into that (will it need to be reverted once coercing cubes from flux into SB is implemented?).

With that being said, the problem should likely go away when generalizing the angle unit is implemented (and this translation becomes possible). I imagine this PR is probably not merging given when we expect the following PR to be implemented, but if the problem still arises then, we have some investigation to completed as to why. Although, I do think a test for counts cubes like what @pllim was suggesting is a great idea.

I'm not sure if this is semantics or if there is a scientific value, but, what would the angle_unit.selected be for a flux unit? Not that this is correct, right now I have a placeholder there that is 'pix' so the dropdown doesn't appear empty, and that there are angle_unit.choices.

kecnry commented 1 month ago

I'm not sure if this is semantics or if there is a scientific value, but, what would the angle_unit.selected be for a flux unit?

(Eventually) if a cube with units of counts is imported into cubeviz, the parser should coerce that into counts/pix**2, the flux dropdown would show counts (and probably not have any other choices), the solid angle dropdown pix**2 (and probably not any other choices unless there is some information on the size of the pixel on the sky), and surface-brightness would then be computed as counts/pix**2. The spectrum viewer, which defaults to function = 'sum' would then integrate over counts/pix**2 cube, to show a spectrum in "flux" units of counts, by default.