ImageConfigHelper#

class jdaviz.core.helpers.ImageConfigHelper(*args, **kwargs)[source]#

Bases: ConfigHelper

ConfigHelper that uses an image viewer as its primary viewer. For example, Imviz and Cubeviz.

Attributes Summary

default_viewer

Default viewer instance.

Methods Summary

get_interactive_regions()

Return spatial regions that can be interacted with in the viewer.

load_regions(regions[, max_num_regions, ...])

Load given region(s) into the viewer.

load_regions_from_file(region_file[, ...])

Load regions defined in the given file.

Attributes Documentation

default_viewer#

Default viewer instance. This is typically the first viewer (e.g., “imviz-0” or “cubeviz-0”).

Methods Documentation

get_interactive_regions()[source]#

Return spatial regions that can be interacted with in the viewer. This does not return masked regions added via load_regions().

Unsupported region shapes will be skipped. When that happens, a yellow snackbar message will appear on display.

Returns:
regionsdict

Dictionary mapping interactive region names to respective Astropy regions objects.

load_regions(regions, max_num_regions=None, refdata_label=None, return_bad_regions=False, **kwargs)[source]#

Load given region(s) into the viewer. WCS-to-pixel translation and mask creation, if needed, is relative to the image defined by refdata_label. Meanwhile, the rest of the Subset operations are based on reference image as defined by Glue.

Note

Loading too many regions will affect performance.

A valid region can be loaded into one of the following categories:

  • An interactive Subset, as if it was drawn by hand. This is always done for supported shapes. Its label will be 'Subset N', where N is an integer.

  • A masked Subset that will display on the image but cannot be modified once loaded. This is done if the shape cannot be made interactive. Its label will be 'MaskedSubset N', where N is an integer.

Parameters:
regionslist of obj

A list of region objects. A region object can be one of the following:

  • Astropy regions object

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

max_num_regionsint or None

Maximum number of regions to load, starting from top of the list. Default is to load everything.

refdata_labelstr or None

Label of data to use for sky-to-pixel conversion for a region, or mask creation. Data must already be loaded into Jdaviz. If None, defaults to the reference data in the default viewer. Choice of this data is particularly important when sky region is involved.

return_bad_regionsbool

If True, return the regions that failed to load (see bad_regions); This is useful for debugging. If False, do not return anything (None).

kwargsdict

Extra keywords to be passed into the region’s to_mask method. This is ignored if the region can be made interactive.

Returns:
bad_regionslist of (obj, str) or None

If requested (see return_bad_regions option), return a list of (region, reason) tuples for region objects that failed to load. If all the regions loaded successfully, this list will be empty. If not requested, return None.

load_regions_from_file(region_file, region_format='ds9', max_num_regions=20, **kwargs)[source]#

Load regions defined in the given file. See Reading/Writing Region Files for supported file formats. See load_regions() for how regions are loaded.

Parameters:
region_filestr

Path to region file.

region_format{‘crtf’, ‘ds9’, ‘fits’}

See regions.Regions.get_formats().

max_num_regionsint or None

Maximum number of regions to read from the file, starting from top of the file. Default is first 20 regions that can be successfully loaded. If None, it will load everything.

kwargsdict

See load_regions().

Returns:
bad_regionslist of (obj, str) or None

See load_regions().