Imviz

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

Bases: ImageConfigHelper

Imviz Helper class.

Methods Summary

create_image_viewer([viewer_name])

Create a new image viewer.

destroy_viewer(viewer_id)

Destroy a viewer associated with the given ID.

get_aperture_photometry_results()

Return aperture photometry results, if any.

get_catalog_source_results()

Return table of sources given by querying from a catalog, if any.

link_data(**kwargs)

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

load_data(data[, data_label, do_link, ...])

Load data into Imviz.

load_static_regions(regions, **kwargs)

Deprecated since version 2.9.

load_static_regions_from_file(region_file[, ...])

Deprecated since version 2.9.

Methods Documentation

create_image_viewer(viewer_name=None)[source] [edit on github]

Create a new image viewer.

To display data in this new viewer programmatically, first get the new viewer ID from the small tab on the top left of viewer display. Then, use add_data_to_viewer() from imviz.app by passing in the new viewer ID and the desired data label, once per dataset you wish to display.

Alternately, you can also display data interactively via the GUI.

Parameters
viewer_namestr or None

Viewer name/ID to use. If None, it is auto-generated.

Returns
viewerImvizImageView

Image viewer instance.

destroy_viewer(viewer_id)[source] [edit on github]

Destroy a viewer associated with the given ID.

Raises
ValueError

Default viewer cannot be destroyed.

get_aperture_photometry_results()[source] [edit on github]

Return aperture photometry results, if any. Results are calculated using Simple Aperture Photometry plugin.

Returns
resultsQTable or None

Photometry results if available or None otherwise.

get_catalog_source_results()[source] [edit on github]

Return table of sources given by querying from a catalog, if any. Results are calculated using Catalog Search plugin.

Returns
resultsQTable or None

Table of sources if available or None otherwise.

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

See link_image_data() for available keyword options and more details.

load_data(data, data_label=None, do_link=True, show_in_viewer=True, **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 or 3D); if 3D, it will treat each slice at axis=0 as a separate image (limit is 16 slices), however loading too many slices will cause performance issue, so consider using Cubeviz instead.

data_labelstr or None

Data label to go with the given data. If not given, this is automatically determined from filename or randomly generated. The final label shown in Imviz may have additional information appended for clarity.

do_linkbool

Link the data after parsing. Set this to False if you want to load multiple data back-to-back but you must remember to run link_data() manually at the end.

show_in_viewerstr or bool

If True, show the data in default viewer. If a string, show in that viewer.

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).

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.rgb2gray(), 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]

Deprecated since version 2.9: The load_static_regions function is deprecated and may be removed in a future version. Use load_regions instead.

Load given region(s) into the viewer.

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

Note

Loading too many regions will affect Imviz performance.

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.

Returns
bad_regionsdict

Dictionary mapping region names to the regions that failed to load. If all the regions loaded successfully, this will be empty.

load_static_regions_from_file(region_file, region_format='ds9', prefix='region', max_num_regions=20, **kwargs)[source] [edit on github]

Deprecated since version 2.9: The load_static_regions_from_file function is deprecated and may be removed in a future version. Use load_regions_from_file instead.

Load regions defined in the given file.

See Reading/Writing Region Files for supported file formats.

Parameters
region_filestr

Path to region file.

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

See regions.Regions.get_formats().

prefixstr

Prefix for the Subset names generated by loaded regions. Names will have the format of <prefix>_<i>, where i is the index in the load order.

max_num_regionsint

Maximum number of regions to read from the file, starting from top of the file, invalid regions included.

kwargsdict

See load_static_regions().

Returns
bad_regionsdict

See load_static_regions().