spacetelescope / jdaviz

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

JDAT-1399: Display Contour Levels in image viewer #530

Open pllim opened 3 years ago

pllim commented 3 years ago

Overlay contours on image in viewer. Use cases:

Workflow example: https://github.com/spacetelescope/jdaviz/issues/530#issuecomment-827773703

https://jira.stsci.edu/browse/JDAT-1399

astrofrog commented 3 years ago

In principle contours are already possible because they were implemented for cubeviz:

Screenshot_2021-04-27_14-54-21

I think this meets requirements 1, 2, and 4 in the list above. I'm not sure what 3 really means compared to say 2. Are there any standard formats for storing contours that we might want to support? Isn't 2 enough?

I think it would be nice to be able to customize the contours a bit to be able to turn the labels on/off and change the colors. I've opened an issue here: https://github.com/glue-viz/glue-jupyter/issues/219

pllim commented 3 years ago

Again, perhaps @PatrickOgle can advise.

PatrickOgle commented 3 years ago

The additional desired functionality is to save/load a file containing contour levels or export/load list of contour levels to/from a notebook like this:

1) Load and display image 1 2) Load and display image 2 3) Match WCS of image 2 to image 1 4) Plot contours on image 2 5) Manually adjust contour levels on image 2 6) Overplot contours from image 2 on image 1 (using existing mechanism) 7) Save contour levels as a list in a notebook (or to a CSV file): [1, 20, 40, 55, 100.] 8) Load contour levels back into viewer/layer as a list (or from a CSV file).

The point is that we don't want to type in potentially long lists of numbers in the custom contours tool. We also want to capture the list for use elsewhere and on other images.

astrofrog commented 3 years ago

That makes sense, thanks!

PatrickOgle commented 3 years ago

@astrofrog Is there a plan/way to export the contour levels to the notebook?

pllim commented 3 years ago

@PatrickOgle , from what I understood from what you said on 2021-05-25, you do not need to save or load contour from file. You only want to transfer contour in memory (in a given active session) from one image to another; this contour in memory will be lost when the session ends, is that correct?

pllim commented 3 years ago

Brute force obviously doesn't work... 😬

viewer.state.layers[0].contour_lim_helper = viewer.state.layers[1].contour_lim_helper
viewer.state.layers[0].contour_visible = True

Screenshot 2021-05-26 155429