Image widget for Jupyter Lab/notebook¶
Make a viewer¶
The snippet below is all you need to make an image widget. The widget is part of the ipywidgets framework so that it can be easily integrated with other controls:
>>> from astrowidgets import ImageWidget >>> image = ImageWidget() >>> display(image)
Loading an image¶
An empty viewer is not very useful, though, so load some data from a FITS file. The FITS file at the link below is an image of the field of the exoplanet Kelt-16, and also contains part of the Veil Nebula:
One important design goal is to make all functionality available by a compact, clear API. The target API still needs a few features (e.g., blink), but much of it is already implemented.
The API-first approach means that manipulating the view programmatically is straightforward. For example, centering on the position of the object, Kelt-16, and zooming in to 8x the natural pixel scale is straightforward:
>>> from astropy.coordinates import SkyCoord >>> image.center_on(SkyCoord.from_name('kelt-16')) >>> image.zoom_level = 8
A more detailed description of the interface and the API Reference are available.