Imviz
- class jdaviz.configs.imviz.Imviz(*args, **kwargs)[source] [edit on github]
Bases:
jdaviz.core.helpers.ConfigHelperImviz Helper class.
Attributes Summary
Default viewer instance.
Methods Summary
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
regionsobjects.
- link_data(link_type='pixels', wcs_fallback_scheme='pixels', wcs_use_affine=True, error_on_fail=False)[source] [edit on github]
(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'. ChoosingNonemay 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. IfFalse, 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 thatastropy.io.fitssupports; first image extension found is loaded unlessextkeyword 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
asdfandgwcs;dataor givenext+ GWCS)HDUListobject (first image extension found is loaded unlessextkeyword is also given)ImageHDUobjectNDDataobject (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.rgb2grey(), 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
regionsobjectphotutilsapertures (limited support untilphotutilsfully 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_maskmethod. This is ignored if Numpy array is given.