astrowidgets icon indicating copy to clipboard operation
astrowidgets copied to clipboard

Feature Request: Use astropy.visualization

Open pllim opened this issue 6 years ago • 3 comments

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

pllim avatar Feb 20 '19 23:02 pllim

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

kakirastern avatar Mar 13 '19 00:03 kakirastern

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.

pllim avatar Mar 13 '19 00:03 pllim

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

kakirastern avatar Mar 13 '19 00:03 kakirastern