Imviz

class jdaviz.configs.imviz.Imviz(*args, **kwargs)[source] [edit on github]

Bases: jdaviz.core.helpers.ConfigHelper

Imviz Helper class.

Attributes Summary

default_viewer

Default viewer instance.

Methods Summary

get_interactive_regions()

Return regions interactively drawn in the viewer.

link_data([link_type, wcs_fallback_scheme, ...])

(Re)link loaded data with the desired link type.

load_data(data[, parser_reference])

Load data into Imviz.

load_static_regions(regions, **kwargs)

Load given region(s) into the viewer.

Attributes Documentation

default_viewer

Default viewer instance. This is typically the first viewer (“imviz-0”).

Methods Documentation

get_interactive_regions()[source] [edit on github]

Return regions interactively drawn in the viewer. This does not return regions added via load_static_regions().

Returns
regionsdict

Dictionary mapping interactive region names to respective Astropy regions objects.

(Re)link loaded data with the desired link type. All existing links will be replaced.

Warning

Any markers added in Imviz would be removed automatically. You can add back the markers using add_markers() for the relevant viewer(s). During the markers removal, pan/zoom will also reset.

Parameters
link_type{‘pixels’, ‘wcs’}

Choose to link by pixels or WCS.

wcs_fallback_scheme{None, ‘pixels’}

If WCS linking failed, choose to fall back to linking by pixels or not at all. This is only used when link_type='wcs'. Choosing None may result in some Imviz functionality not working properly.

wcs_use_affinebool

Use an affine transform to represent the offset between images if possible (requires that the approximation is accurate to within 1 pixel with the full WCS transformations). If approximation fails, it will automatically fall back to full WCS transformation. This is only used when link_type='wcs'. Affine approximation is much more performant at the cost of accuracy.

error_on_failbool

If True, any failure in linking will raise an exception. If False, warnings will be emitted as snackbar messages. When only warnings are emitted and no links are assigned, some Imviz functionality may not work properly.

Raises
ValueError

Invalid inputs or reference data.

load_data(data, parser_reference=None, **kwargs)[source] [edit on github]

Load data into Imviz.

Parameters
dataobj or str

File name or object to be loaded. Supported formats include:

  • 'filename.fits' (or any extension that astropy.io.fits supports; first image extension found is loaded unless ext keyword is also given)

  • 'filename.fits[SCI]' (loads only first SCI extension)

  • 'filename.fits[SCI,2]' (loads the second SCI extension)

  • 'filename.jpg' (requires scikit-image; grayscale only)

  • 'filename.png' (requires scikit-image; grayscale only)

  • JWST ASDF-in-FITS file (requires asdf and gwcs; data or given ext + GWCS)

  • HDUList object (first image extension found is loaded unless ext keyword is also given)

  • ImageHDU object

  • NDData object (2D only but may have unit, mask, or uncertainty attached)

  • Numpy array (2D only)

parser_reference

This is used internally by the app.

kwargsdict

Extra keywords to be passed into app-level parser. The only one you might call directly here is ext (any FITS extension format supported by astropy.io.fits) and show_in_viewer (bool).

Notes

When loading image formats that support RGB color like JPG or PNG, the files are converted to greyscale. This is done following the algorithm of skimage.color.rgb2grey(), which involves weighting the channels as 0.2125 R + 0.7154 G + 0.0721 B. If you prefer a different weighting, you can use skimage.io.imread() to produce your own greyscale image as Numpy array and load the latter instead.

load_static_regions(regions, **kwargs)[source] [edit on github]

Load given region(s) into the viewer. Region(s) is relative to the reference image. Once loaded, the region(s) cannot be modified.

Parameters
regionsdict

Dictionary mapping desired region name to one of the following:

  • Astropy regions object

  • photutils apertures (limited support until photutils fully supports regions)

  • Numpy boolean array (shape must match data)

Region name that starts with “Subset” is forbidden and reserved for internal use only.

kwargsdict

Extra keywords to be passed into the region’s to_mask method. This is ignored if Numpy array is given.