Image widget for Jupyter Lab/notebook

Getting started

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:

>>> image.load_fits('https://zenodo.org/record/3356833/files/kelt-16-b-S001-R001-C084-r.fit.bz2?download=1')

The image widget can also load a Numpy array via load_array. It also understands astropy NDData objects; load them via load_data.

API

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.

Example Notebooks