AstrowidgetsImageViewerMixin#
- class jdaviz.core.astrowidgets_api.AstrowidgetsImageViewerMixin[source]#
Bases:
object
This class implements
astrowidgets
API for Jdaviz image viewer. This does not provide a fully functional viewer, but rather should be used as mixin into an existing viewer subclass.A child class that uses this must run
init_astrowidgets_api()
within its__init__
.Note
Do not use this for spectral or cube viewers.
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.
The zoom level for an image viewer (not linked by WCS).
Methods Summary
add_markers
(table[, x_colname, y_colname, ...])Creates markers w.r.t.
center_on
(point)Centers the view on a particular point on the top visible layer.
This method must be called in child class
__init__
.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
- RESERVED_MARKER_SET_NAMES = ['all']#
- 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 Glue markers are listed at https://glue-core.readthedocs.io/en/latest/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.visualization
counterparts are also accepted, as follows:'arcsinh'
:astropy.visualization.AsinhStretch
'linear'
:astropy.visualization.LinearStretch
'log'
:astropy.visualization.LogStretch
'sqrt'
:astropy.visualization.SqrtStretch
- zoom_level#
The zoom level for an image viewer (not linked by WCS).
Warning
When a viewer is linked by WCS, the result corresponds to the
zoom_level
of the reference data.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]#
Creates markers w.r.t. the reference image at given points in the table.
Note
Use
marker
to change marker appearance.Note
Once markers are added, linking cannot be changed. To change linking options, remove and re-add the markers manually.
- 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
SkyCoord
objects.- use_skycoordbool
If
True
, useskycoord_colname
to mark. Otherwise, usex_colname
andy_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]#
Centers the view on a particular point on the top visible layer. The data label of the top visible layer can be queried using the viewer’s
top_visible_data_label
property.- 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.
- offset_by(dx, dy)[source]#
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]#
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.
- save(filename)[source]#
Save out the current image view to given PNG filename.
- Parameters:
- filenamestr
PNG filename. If the given file already exists, it will be silently overwritten.
- set_colormap(cmap)[source]#
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]#
Zoom in or out by the given factor.
Warning
When a viewer is linked by WCS, this method accidentally changes the center also; see the warning in
zoom_level
.- Parameters:
- valint or float
The zoom level to zoom the image. See
zoom_level
.
- Raises:
- ValueError
Invalid zoom factor.