Imviz¶
- class jdaviz.configs.imviz.Imviz(*args, **kwargs)[source] [edit on github]¶
Bases:
jdaviz.core.helpers.ConfigHelperImviz Helper class
Attributes Summary
List of all available options for automatic image cut levels.
List of colormap names.
Current image cut levels.
Marker to use.
The image stretching algorithm in use.
List of all available options for image stretching.
Zoom level:
Methods Summary
add_markers(table[, x_colname, y_colname, …])Creates markers w.r.t.
center_on(point)Centers the view on a particular point.
Return regions interactively drawn in the viewer.
load_data(data[, parser_reference])Load data into Imviz.
load_static_regions(regions, **kwargs)Load given region(s) into the viewer.
offset_by(dx, dy)Move the center to a point that is given offset away from the current center.
remove_markers([marker_name])Remove some but not all of the markers by name used when adding the markers.
Delete all markers.
save(filename)Save out the current image view to given PNG filename.
set_colormap(cmap)Set colormap to the given colormap name.
zoom(val)Zoom in or out by the given factor.
Attributes Documentation
- autocut_options¶
List of all available options for automatic image cut levels.
- colormap_options¶
List of colormap names.
- cuts¶
Current image cut levels.
To set new cut levels, either provide a tuple of
(low, high)values or one of the options fromautocut_options.
- marker¶
Marker to use.
Marker can be set as follows; e.g.:
{'color': 'red', 'alpha': 1.0, 'markersize': 3} {'color': '#ff0000', 'alpha': 0.5, 'markersize': 10} {'color': (1, 0, 0)}
The valid properties for markers in imviz are listed at https://docs.glueviz.org/en/stable/api/glue.core.visual.VisualAttributes.html
- stretch¶
The image stretching algorithm in use.
- stretch_options¶
List of all available options for image stretching.
Their
astropy.visualizationcounterparts are also accepted, as follows:'arcsinh':astropy.visualization.AsinhStretch'linear':astropy.visualization.LinearStretch'log':astropy.visualization.LogStretch'sqrt':astropy.visualization.SqrtStretch
- zoom_level¶
Zoom level:
1 means real-pixel-size.
2 means zoomed in by a factor of 2.
0.5 means zoomed out by a factor of 2.
‘fit’ means zoomed to fit the whole image width into display.
Methods Documentation
- add_markers(table, x_colname='x', y_colname='y', skycoord_colname='coord', use_skycoord=False, marker_name=None)[source] [edit on github]¶
Creates markers w.r.t. the reference image at given points in the table.
Note
Use
markerto change marker appearance.- Parameters
- table
Table Table containing marker locations.
- x_colname, y_colnamestr
Column names for X and Y. Coordinates must be 0-indexed.
- skycoord_colnamestr
Column name with
SkyCoordobjects.- use_skycoordbool
If
True, useskycoord_colnameto mark. Otherwise, usex_colnameandy_colname.- marker_namestr, optional
Name to assign the markers in the table. Providing a name allows markers to be removed by name at a later time.
- table
- Raises
- AttributeError
Sky coordinates are given but reference image does not have a valid WCS.
- ValueError
Invalid marker name.
- center_on(point)[source] [edit on github]¶
Centers the view on a particular point.
- Parameters
- pointtuple or
SkyCoord If tuple of
(X, Y)is given, it is assumed to be in data coordinates and 0-indexed.
- pointtuple or
- Raises
- AttributeError
Sky coordinates are given but image does not have a valid WCS.
- 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.
- 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)astropy.io.fits.HDUListobject (first image extension found is loaded unlessextkeyword is also given)astropy.io.fits.ImageHDUobjectastropy.nddata.NDDataobject (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.imreadto 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.
- offset_by(dx, dy)[source] [edit on github]¶
Move the center to a point that is given offset away from the current center.
- Parameters
- dx, dyfloat or
Quantity Offset value. Without a unit, assumed to be pixel offsets. If a unit is attached, offset by pixel or sky is assumed from the unit.
- dx, dyfloat or
- Raises
- AttributeError
Sky offset is given but image does not have a valid WCS.
- ValueError
Offsets are of different types.
- astropy.units.core.UnitTypeError
Sky offset has invalid unit.
- remove_markers(marker_name=None)[source] [edit on github]¶
Remove some but not all of the markers by name used when adding the markers.
- Parameters
- marker_namestr
Name used when the markers were added. If not given, will delete markers added under default name.
- reset_markers()[source] [edit on github]¶
Delete all markers.
- save(filename)[source] [edit on github]¶
Save out the current image view to given PNG filename.
- set_colormap(cmap)[source] [edit on github]¶
Set colormap to the given colormap name.
- Parameters
- cmapstr
Colormap name. Possible values can be obtained from
colormap_options().
- Raises
- ValueError
Invalid colormap name.
- zoom(val)[source] [edit on github]¶
Zoom in or out by the given factor.
- Parameters
- valint or float
The zoom level to zoom the image. See
zoom_level.
- Raises
- ValueError
Invalid zoom factor.