ImageWidget¶
- class astrowidgets.ImageWidget(**kwargs: Any)[source]¶
Bases:
VBox
Image widget for Jupyter notebook using Ginga viewer.
- Parameters:
- loggerobj or
None
Ginga logger. For example:
from ginga.misc.log import get_logger logger = get_logger('my_viewer', log_stderr=False, log_file='ginga.log', level=40)
- image_width, image_heightint
Dimension of Jupyter notebook’s image widget.
- use_opencvbool
Let Ginga use
opencv
to speed up image transformation; e.g., rotation and mosaic. If this is enabled and you do not haveopencv
, you will get a warning.- pixel_coords_offsetint, optional
An offset, typically either 0 or 1, to add/subtract to all pixel values when going to/from the displayed image. In almost all situations the default value, ``0``, is the correct value to use.
- loggerobj or
Public constructor
Attributes Summary
List all available options for image auto-cut.
Settable.
Settable.
List of colormap names.
Show or hide cursor information (X, Y, WCS).
Current image cut levels.
Logger for this widget.
Marker to use.
An offset, typically either 0 or 1, to add/subtract to all pixel values when going to/from the displayed image.
Settable.
The image stretching algorithm in use.
List all available options for image stretching.
Zoom level:
Methods Summary
add_markers
(table[, x_colname, y_colname, ...])Creates markers in the image at given points.
center_on
(point)Centers the view on a particular point.
get_markers
([x_colname, y_colname, ...])Return the locations of existing markers.
load_array
(arr)Load a 2D array into the viewer.
load_fits
(fitsorfn[, numhdu, memmap])Load a FITS file into the viewer.
load_nddata
(nddata)Load an
NDData
object into the viewer.offset_by
(dx, dy)Move the center to a point that is given offset away from the current center.
offset_to
(dx, dy[, skycoord_offset])Deprecated since version 0.3.
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.
start_marking
([marker_name, marker])Start marking, with option to name this set of markers or to specify the marker style.
stop_marking
([clear_markers])Stop marking mode, with option to clear markers, if desired.
zoom
(val)Zoom in or out by the given factor.
Attributes Documentation
- autocut_options¶
List all available options for image auto-cut.
- click_center¶
Settable. If True, middle-clicking can be used to center. If False, that interaction is disabled.
In the future this might go from True/False to being a selectable button. But not for the first round.
- click_drag¶
Settable. If True, the “click-and-drag” mode is an available interaction for panning. If False, it is not.
Note that this should be automatically made
False
when selection mode is activated.
- colormap_options¶
List of colormap names.
- cursor¶
Show or hide cursor information (X, Y, WCS). Acceptable values are ‘top’, ‘bottom’, or
None
.
- 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
.
- image_height¶
- image_width¶
- is_marking¶
True
if in marking mode,False
otherwise. Marking mode means a mouse click adds a new marker. This does not affectadd_markers()
.
- logger¶
Logger for this widget.
- marker¶
Marker to use.
Marker can be set as follows:
{'type': 'circle', 'color': 'cyan', 'radius': 20} {'type': 'cross', 'color': 'green', 'radius': 20} {'type': 'plus', 'color': 'red', 'radius': 20}
- pixel_offset¶
An offset, typically either 0 or 1, to add/subtract to all pixel values when going to/from the displayed image. In almost all situations the default value, ``0``, is the correct value to use.
This value cannot be modified after initialization.
- scroll_pan¶
Settable. If True, scrolling moves around in the image. If False, scrolling (up/down) zooms the image in and out.
- stretch¶
The image stretching algorithm in use.
- stretch_options¶
List all available options for image stretching.
- 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.
Methods Documentation
- add_markers(table, x_colname='x', y_colname='y', skycoord_colname='coord', use_skycoord=False, marker_name=None)[source]¶
Creates markers in the image at given points.
- Parameters:
- table
Table
Table containing marker locations.
- x_colname, y_colnamestr
Column names for X and Y. Coordinates can be 0- or 1-indexed, as given by
self.pixel_offset
.- 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
- center_on(point)[source]¶
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.
- pointtuple or
- get_markers(x_colname='x', y_colname='y', skycoord_colname='coord', marker_name=None)[source]¶
Return the locations of existing markers.
- Parameters:
- x_colname, y_colnamestr
Column names for X and Y data coordinates. Coordinates returned are 0- or 1-indexed, depending on
self.pixel_offset
.- skycoord_colnamestr
Column name for
SkyCoord
, which contains sky coordinates associated with the active image. This is ignored if image has no WCS.
- Returns:
- markers_table
Table
orNone
Table of markers, if any, or
None
.
- markers_table
- load_array(arr)[source]¶
Load a 2D array into the viewer.
Note
Use
load_nddata()
for WCS support.- Parameters:
- arrarray-like
2D array.
- load_fits(fitsorfn, numhdu=None, memmap=None)[source]¶
Load a FITS file into the viewer.
- Parameters:
- fitsorfnstr or HDU
Either a file name or an HDU (not an HDUList). If file name is given, WCS in primary header is automatically inherited. If a single HDU is given, WCS must be in the HDU header.
- numhduint or
None
Extension number of the desired HDU. If
None
, it is determined automatically.- memmapbool or
None
Memory mapping. If
None
, it is determined automatically.
- load_nddata(nddata)[source]¶
Load an
NDData
object into the viewer.- Parameters:
- nddata
NDData
NDData
with image data and WCS.
- nddata
- 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
- offset_to(dx, dy, skycoord_offset=False)[source]¶
Deprecated since version 0.3: The offset_to function is deprecated and may be removed in a future version. Use offset_by instead.
Move the center to a point that is given offset away from the current center.
Note
This is deprecated. Use
offset_by()
.- Parameters:
- dx, dyfloat
Offset value. Unit is assumed based on
skycoord_offset
.- skycoord_offsetbool
If
True
, offset must be given in degrees. Otherwise, they are in pixel values.
- remove_markers(marker_name=None)[source]¶
Remove some but not all of the markers by name used when adding the markers
- Parameters:
- marker_namestr, optional
Name used when the markers were added.
- set_colormap(cmap)[source]¶
Set colormap to the given colormap name.
- Parameters:
- cmapstr
Colormap name. Possible values can be obtained from
colormap_options()
.
- start_marking(marker_name=None, marker=None)[source]¶
Start marking, with option to name this set of markers or to specify the marker style.
- stop_marking(clear_markers=False)[source]¶
Stop marking mode, with option to clear markers, if desired.
- Parameters:
- clear_markersbool, optional
If
clear_markers
isFalse
, existing markers are retained untilreset_markers()
is called. Otherwise, they are erased.
- zoom(val)[source]¶
Zoom in or out by the given factor.
- Parameters:
- valint
The zoom level to zoom the image. See
zoom_level
.