astropy / astrowidgets

*PRE-ALPHA*/heavy dev. Jupyter widgets leveraging the Astropy ecosystem
https://astrowidgets.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
31 stars 14 forks source link

Feature Request: Use astropy.visualization #63

Open pllim opened 5 years ago

pllim commented 5 years ago

During a hack day project, in which @eteq and Matteo Correnti were a part of, I was given a non-interactive version of a photometry notebook. My task was to use astrowidgets to make some parts interactive. The non-interactive version leveraged astropy.visualization rather nicely. But I had a hard time trying to do exactly the same steps using astrowidgets with Ginga as a backend because ejeschke/ginga#560 is still unresolved. I have a feeling that other backends we would support in the future (e.g., bqplot or Aladdin Lite) might not use astropy.visualization as well. So, I guess that hook into astropy.visualization might have to happen here in the astrowidgets layer.

Relevant snippets:

import matplotlib.pyplot as plt
from astropy.visualization import (ZScaleInterval, SqrtStretch, ImageNormalize)
from astropy.visualization import simple_norm

norm = simple_norm(data, 'sqrt', percent=99.)

plt.figure(figsize=(14, 14))
plt.imshow(data, norm=norm, cmap='Greys')
norm = simple_norm(data, 'log', percent=99.)

plt.figure(figsize=(14, 14))
plt.imshow(data, norm=norm, origin='lower', cmap='viridis')
plt.colorbar()

xref spacetelescope/dat_pyinthesky#7

kakirastern commented 5 years ago

How about when Matplotlib is the backend, would that yield a solution to this request?

pllim commented 5 years ago

Just speaking for myself, I would like this to work in a backend agnostic way, but maybe that is not even possible. Definitely need more looking into. For instance, astropy.visualization.stretch does not rely on Matplotlib, but astropy.visualization.mpl_normalize does.

kakirastern commented 5 years ago

I see... No wonder why you have not mentioned that option in your original post.