Imviz
- class jdaviz.configs.imviz.helper.Imviz(*args, **kwargs)[source] [edit on github]
Bases:
jdaviz.core.helpers.ConfigHelper
Imviz Helper class.
Attributes Summary
Default viewer instance.
Methods Summary
create_image_viewer
([viewer_name])Create a new image viewer.
destroy_viewer
(viewer_id)Destroy a viewer associated with the given ID.
Return aperture photometry results, if any.
Return regions interactively drawn in the viewer.
link_data
(**kwargs)(Re)link loaded data in Imviz 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
- 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()
fromimviz.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
- Returns
- viewer
ImvizImageView
Image viewer instance.
- viewer
- 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.
- get_interactive_regions()[source] [edit on github]
Return regions interactively drawn in the viewer. This does not return regions added via
load_static_regions()
.Unsupported region shapes will be skipped. When that happens, a red snackbar message will appear on display.
- Returns
- regionsdict
Dictionary mapping interactive region names to respective Astropy
regions
objects.
- link_data(**kwargs)[source] [edit on github]
(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, 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 thatastropy.io.fits
supports; first image extension found is loaded unlessext
keyword is also given)'filename.fits[SCI]'
(loads only first SCI extension)'filename.fits[SCI,2]'
(loads the second SCI extension)'filename.jpg'
(requiresscikit-image
; grayscale only)'filename.png'
(requiresscikit-image
; grayscale only)JWST ASDF-in-FITS file (requires
asdf
andgwcs
;data
or givenext
+ GWCS)HDUList
object (first image extension found is loaded unlessext
keyword is also given)ImageHDU
objectNDData
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 byastropy.io.fits
) andshow_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.rgb2gray()
, which involves weighting the channels as0.2125 R + 0.7154 G + 0.0721 B
. If you prefer a different weighting, you can useskimage.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
objectphotutils
apertures (limited support untilphotutils
fully supportsregions
)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.