Core Data

glue.core.component Module


Component(data[, units]) Stores the actual, numerical information for a particular quantity
DerivedComponent(data, link[, units]) A component which derives its data from a function
CategoricalComponent(categorical_data[, …]) Container for categorical data.
CoordinateComponent(data, axis[, world]) Components associated with pixel or world coordinates

glue.core.component_id Module


ComponentID(label[, parent]) References a glue.core.component.Component object within a Data object.
PixelComponentID(axis, label[, parent]) The ID of a component which is a pixel position in the data - this allows us to make assumptions in certain places.
ComponentIDDict(data, **kwargs)

glue.core.coordinates Module


coordinates_from_header(header) Convert a FITS header into a glue Coordinates object.
coordinates_from_wcs(wcs) Convert an Astropy WCS object into a glue Coordinates object.


Coordinates() Base class for coordinate transformation
WCSCoordinates([header, wcs]) Class for coordinate transformation based on the WCS FITS standard.

glue.core.data Module


Data([label, coords]) The basic data container in Glue.

glue.core.data_collection Module


DataCollection([data]) The top-level object for interacting with datasets in Glue.

glue.core.hub Module


Hub(*args) The hub manages communication between subscribers.
HubListener The base class for any object that subscribes to hub messages.

glue.core.subset Module


combine_multiple(subsets, operator)


Subset(data[, color, alpha, label]) Base class to handle subsets of data.
RoiSubsetState([xatt, yatt, roi])
CategoricalROISubsetState([att, roi])
RangeSubsetState(lo, hi[, att])
MultiRangeSubsetState(pairs[, att]) A subset state defined by multiple discontinuous ranges
CompositeSubsetState(state1[, state2])
OrState(state1[, state2])
AndState(state1[, state2])
XorState(state1[, state2])
InvertState(state1[, state2])
MaskSubsetState(mask, cids) A subset defined by boolean pixel mask
CategorySubsetState(attribute, values)
ElementSubsetState([indices, data])
InequalitySubsetState(left, right, op)
CategoricalMultiRangeSubsetState(ranges, …) A 2D subset state where one attribute is categorical and the other is numerical, and where for each category, there are multiple possible subset ranges.
CategoricalROISubsetState2D(categories, …) A 2D subset state where both attributes are categorical.
SliceSubsetState(reference_data, slices) A subset defined by a slice in an array

glue.core.subset_group Module

A SubsetGroup unites a group of Subset instances together with a consistent state, label, and style.

While subsets are internally associated with particular datasets, it’s confusing for the user to juggle multiple similar or identical subsets, applied to different datasets. Because of this, the GUI manages SubsetGroups, and presents each group to the user as a single entity. The individual subsets are held in-sync by the SubsetGroup.

Client code should only create Subset Groups via DataCollection.new_subset_group. It should not call Data.add_subset or Data.new_subset directly


GroupedSubset(data, group) A member of a SubsetGroup, whose internal representation is shared with other group members
SubsetGroup([color, alpha, label, subset_state]) Create a new empty SubsetGroup

glue.core.roi Module


Roi A geometrical 2D region of interest.
RectangularROI([xmin, xmax, ymin, ymax]) A 2D rectangular region of interest.
CircularROI([xc, yc, radius]) A 2D circular region of interest.
PolygonalROI([vx, vy]) A class to define 2D polygonal regions-of-interest
AbstractMplRoi(axes[, roi]) Base class for objects which use Matplotlib user events to edit/display ROIs
MplRectangularROI(axes) A subclass of RectangularROI that also renders the ROI to a plot
MplCircularROI(axes) Class to display / edit circular ROIs using matplotlib
MplPolygonalROI(axes[, roi]) Defines and displays polygonal ROIs on matplotlib plots
param axes:A matplotlib Axes object to attach the graphical ROI to
param axes:A matplotlib Axes object to attach the graphical ROI to
XRangeROI([min, max])
RangeROI(orientation[, min, max])
param orientation:
 ’x’ or ‘y’.
YRangeROI([min, max])
VertexROIBase([vx, vy])
param vx:initial x vertices :type vx: list :param vy: initial y vertices :type vy: list
CategoricalROI([categories]) A ROI abstraction to represent selections of categorical data.

glue.core.data_factories Package


aastex_factory(file, **kwargs)
astropy_tabular_data(*args, **kwargs) Build a data set from a table.
auto_data(filename, *args, **kwargs) Attempt to automatically construct a data object
casalike_cube(filename, **kwargs) This provides special support for 4D CASA FITS - like cubes, which have 2 spatial axes, a spectral axis, and a stokes axis in that order.
cds_factory(file, **kwargs)
daophot_factory(file, **kwargs)
data_label(path) Convert a file path into a data label, by stripping out slashes, file extensions, etc.
find_factory(filename, **kwargs)
fits_reader(source[, auto_merge, …]) Read in all extensions from a FITS file.
has_extension(exts) A simple default filetype identifier function
hdf5_reader(filename[, auto_merge, memmap]) Read in all datasets from an HDF5 file
img_data(file_name) Load common image files into a Glue data object
ipac_factory(file, **kwargs)
is_casalike(filename, **kwargs) Check if a FITS file is a CASA like cube, with (P, P, V, Stokes) layout
is_npy_npz(filename) The first bytes are x93NUMPY (for npy) or PKx03x04 (for npz)
latex_factory(file, **kwargs)
load_data(path[, factory]) Use a factory to load a file and assign a label.
npy_npz_reader(filename[, format, auto_merge]) Read in a Numpy structured array saved to a .npy or .npz file.
pandas_read_table(path, **kwargs) A factory for reading tabular data using pandas :param path: path/to/file :param kwargs: All kwargs are passed to pandas.read_csv :returns: glue.core.data.Data object
sextractor_factory(file, **kwargs)
tabular_data(path, **kwargs)


FileWatcher(path, callback[, poll_interval]) Watch a path for modifications, and perform an action on change
LoadLog(path, factory, kwargs) This class attaches some metadata to data created from load_data, so that the data can be re-constructed when loading saved state.

glue.core.fitters Module

Glue’s fitting classes are designed to be easily subclassed for performing custom model fitting in Glue.

See the guide on writing custom fit plugins for help with using custom fitting utilities in Glue.


BaseFitter1D(**params) Base class for 1D fitters.
PolynomialFitter(**params) A polynomial model.
AstropyFitter1D(**params) A base class for wrapping astropy.modeling.
SimpleAstropyGaussianFitter(**params) Guassian fitter using astropy.modeling.
BasicGaussianFitter(**params) Fallback Gaussian fitter, for astropy < 0.3.

glue.core.state_objects Module


State(**kwargs) A class to represent the state of a UI element.
StateAttributeCacheHelper(state, attribute) Generic class to help with caching values on a per-attribute basis
StateAttributeLimitsHelper(state, attribute) This class is a helper for attribute-dependent min/max level values.
StateAttributeSingleValueHelper(state, …)

User Interface

glue.viewers.common.qt.data_viewer Module


DataViewer(session[, parent]) Base class for all Qt DataViewer widgets.

glue.viewers.matplotlib.state Module


DeferredDrawSelectionCallbackProperty([…]) A callback property where drawing is deferred until after notify has called all callback functions.
DeferredDrawCallbackProperty([default, …]) A callback property where drawing is deferred until after notify has called all callback functions.
MatplotlibDataViewerState(*args, **kwargs) A base class that includes common attributes for viewers based on Matplotlib.
MatplotlibLayerState([viewer_state]) A base class that includes common attributes for all layers in viewers based on Matplotlib.

glue.viewers.matplotlib.qt.data_viewer Module


MatplotlibDataViewer(session[, parent, wcs, …])

glue.core.layer_artist Module

LayerArtist classes handle the visualization of an individual subset or dataset.

Visualization clients in Glue typically combose visualizations by stacking visualizations of several datasets and subsets on top of each other. They do this by creating and managing a collection of LayerArtists, one for each Data or Subset to view.

LayerArtists contain the bulk of the logic for actually rendering things


LayerArtistBase(layer) Create a new LayerArtist
MatplotlibLayerArtist(layer, axes) MPL-specific layer artist base class, that uses an Axes object
LayerArtistContainer() A collection of LayerArtists

glue.viewers.common.viz_client Module


VizClient(data[, options]) The VizClient class provides an interface (and minimal implementation) for a generic client that creates visualizations.
GenericMplClient([data, figure, axes, …]) This client base class handles the logic of adding, removing, and updating layers.

glue.viewers.common.qt.tool Module


Tool([viewer]) The base class for all toolbar tools.
CheckableTool([viewer]) A tool that is checkable.
DropdownTool(*args, **kwargs) A base class for all tools that show a drop-down menu.
SimpleToolMenu(*args, **kwargs) A base class for tools that have no action it themselves but show a dropdown of other tools.

glue.viewers.common.qt.mouse_mode Module

MouseModes define various mouse gestures.

MouseModes are generally activated and deactivated by toolbar buttons, although not necessarily so. The toolbar maintains a list of MouseModes from the visualization it is assigned to, and sees to it that only one MouseMode is active at a time.

Each MouseMode appears as an Icon in the toolbar. Classes can assign methods to the press_callback, move_callback, and release_callback methods of each Mouse Mode, to implement custom functionality

The basic usage pattern is thus:
  • visualization object instantiates the MouseModes it wants
  • each of these is passed to the add_tool method of the toolbar
  • visualization object optionally attaches methods to the 3 _callback methods in a MouseMode, for additional behavior


MouseMode(viewer[, press_callback, …]) The base class for all MouseModes.

glue.viewers.common.qt.toolbar_mode Module

ToolbarModes are CheckableTools that enable various MouseModes.

The toolbar maintains a list of MouseModes from the visualization it is assigned to, and sees to it that only one MouseMode is active at a time.

Each ToolbarMode appears as an Icon in the toolbar. Classes can assign methods to the press_callback, move_callback, and release_callback methods of each Mouse Mode, to implement custom functionality

The basic usage pattern is thus:
  • visualization object instantiates the MouseModes it wants
  • each of these is passed to the add_tool method of the toolbar
  • visualization object optionally attaches methods to the 3 _callback methods in a MouseMode, for additional behavior


ToolbarModeBase(viewer, **kwargs) All ToolbarModes are both MouseModes and CheckableTools
RoiModeBase(viewer, **kwargs) Base class for defining ROIs.
RoiMode(viewer, **kwargs) Define Roi Modes via click+drag events.
PersistentRoiMode(viewer, **kwargs) Same functionality as RoiMode, but the Roi is never finalized, and remains rendered after mouse gestures
ClickRoiMode(viewer, **kwargs) Generate ROIs using clicks and click+drags.
RectangleMode(viewer, **kwargs) Defines a Rectangular ROI, accessible via the roi() method
PathMode(viewer, **kwargs)
CircleMode(viewer, **kwargs) Defines a Circular ROI, accessible via the roi() method
PolyMode(viewer, **kwargs) Defines a Polygonal ROI, accessible via the roi() method
LassoMode(viewer, **kwargs) Defines a Polygonal ROI, accessible via the roi() method
HRangeMode(viewer, **kwargs) Defines a Range ROI, accessible via the roi() method.
VRangeMode(viewer, **kwargs) Defines a Range ROI, accessible via the roi() method.
PickMode(viewer, **kwargs) Defines a PointROI.
ContrastMode(viewer, **kwargs) Uses right mouse button drags to set bias and contrast, DS9-style.
ColormapMode([viewer]) A tool to change the colormap used in a viewer.

glue.viewers.common.qt.toolbar Module


BasicToolbar(str, parent) Create a new toolbar object

glue.viewers.matplotlib.qt.toolbar Module



glue.viewers.scatter.state Module


ScatterViewerState(**kwargs) A state class that includes all the attributes for a scatter viewer.
ScatterLayerState([viewer_state, layer]) A state class that includes all the attributes for layers in a scatter plot.

glue.viewers.scatter.qt Package


ScatterViewer(session[, parent, state])

glue.viewers.image.state Module


ImageViewerState(**kwargs) A state class that includes all the attributes for an image viewer.
ImageLayerState([layer, viewer_state]) A state class that includes all the attributes for data layers in an image plot.
ImageSubsetLayerState([viewer_state]) A state class that includes all the attributes for subset layers in an image plot.
AggregateSlice([slice, center, function])

glue.viewers.image.qt Package


ImageViewer(session[, parent, state])
StandaloneImageViewer([image, wcs, parent]) A simplified image viewer, without any brushing or linking, but with the ability to adjust contrast and resample.

glue.viewers.histogram.state Module


HistogramViewerState(**kwargs) A state class that includes all the attributes for a histogram viewer.
HistogramLayerState([viewer_state]) A state class that includes all the attributes for layers in a histogram plot.

glue.viewers.histogram.qt Package


HistogramViewer(session[, parent, state])

glue.viewers.table.qt Package


TableLayerArtist(layer, table_viewer)
TableViewer(session[, parent, widget])

glue.viewers.custom.qt.custom_viewer Module

This module provides utilities for creating custom data viewers. The goal of this module is to make it easy for users to make new data viewers by focusing on matplotlib visualization logic, and not UI or event processing logic.

The end user typically interacts with this code via glue.custom_viewer()


AttributeInfo An array subclass wrapping a Component of a dataset
ViewerState Empty object for users to store data inside
UserDefinedFunction(name) Descriptor to specify a UserDefinedFunction.
CustomViewer(widget_instance) Base class for custom data viewers.
SettingsOracle(settings, **override)
CustomViewerMeta Metaclass to construct CustomViewer and subclasses
CustomSubsetState(viewer_cls, roi, settings) A SubsetState subclass that uses a CustomViewer’s “select” function
FrozenSettings(**kwargs) Encapsulates the current settings of a CustomViewer
CustomViewer(widget_instance) Base class for custom data viewers.
CustomArtist(layer, axes, coordinator) LayerArtist for custom viewers
CustomClient(*args, **kwargs)
CustomWidgetBase(session[, parent]) Base Qt widget class for custom viewers
FormElement(params) Base class for user-defined settings in a custom widget.
NumberElement(params) A form element representing a number
LabeledSlider(min, max[, default, parent]) A labeled slider widget, that handles floats and integers
BoolElement(params) A checkbox representing a boolean setting
FixedComponent(params) An element for a Data Component.
ComponenentElement(params) A dropdown selector to choose a component
ChoiceElement(params) A dropdown selector to choose between a set of items

glue.core.application_base Module


Application([data_collection, session])
ViewerBase(session) Base class for data viewers in an application

glue.app.qt.application Module


GlueApplication([data_collection, session]) The main GUI application for the Qt frontend

glue.qglue Module

Utility function to load a variety of python objects into glue


qglue(**kwargs) Quickly send python variables to Glue for visualization.

glue Package


custom_viewer(name, **kwargs) Create a custom interactive data viewer.
qglue(**kwargs) Quickly send python variables to Glue for visualization.


glue.config Module


Registry() Container to hold groups of objects or settings.
SettingRegistry() Stores key/value settings that code can use to customize Glue
ExporterRegistry() Stores functions which can export an applocation to an output file
ColormapRegistry() Stores colormaps for the Image Viewer.
DataFactoryRegistry() Stores data factories.
QtClientRegistry() Stores QT widgets to visualize data.
LinkFunctionRegistry() Stores functions to convert between quantities
LinkHelperRegistry() Stores helper objects that compute many ComponentLinks at once
LayerActionRegistry() Stores custom menu actions available when the user select one or more datasets, subset group, or subset in the data collection view.
DictRegistry() Base class for registries that are based on dictionaries instead of lists of objects.
PreferencePanesRegistry() Stores preference panes
DataExporterRegistry() Stores data exporters.
SubsetMaskExporterRegistry() Stores mask exporters.
SubsetMaskImporterRegistry() Stores mask importers.
QtFixedLayoutTabRegistry() Stores Qt pre-defined tabs (non-MDI)
KeyboardShortcut() Stores keyboard shortcuts.

glue.core.simpleforms Module

The descriptors in this module are meant to be added to classes, to specify simple user-settable forms. These classes are used to automatically construct GUIs, without having to write GUI code in the form class itself.

Option objects are defined at the class-level. To instances of these classes, an Option behaves like a normal instance attribute.

See Custom fitting plugins for example usage.


BoolOption([label, default]) A boolean-valued option.
FloatOption([min, max, default, label]) A floating-point option.
IntOption([min, max, default, label]) An integer-valued option.
Option(default, label) Base class for other options.

glue.core.client Module


Client(data) Base class for interaction / visualization modules
BasicClient(data) Create a new client object.

glue.core.message Module


Message(sender[, tag]) Base class for messages that the hub handles.
ErrorMessage(sender[, tag]) Used to send general purpose error messages
SubsetMessage(sender[, tag]) A general message issued by a subset.
SubsetCreateMessage(sender[, tag]) A message that a subset issues when its state changes
SubsetUpdateMessage(sender[, attribute, tag]) A message that a subset issues when its state changes.
SubsetDeleteMessage(sender[, tag]) A message that a subset issues when it is deleted
DataMessage(sender[, tag]) The base class for messages that data objects issue
DataAddComponentMessage(sender, component_id)
DataUpdateMessage(sender, attribute[, tag])
DataCollectionMessage(sender[, tag])
DataCollectionActiveChange(sender[, tag])
DataCollectionActiveDataChange(sender[, tag])
DataCollectionAddMessage(sender, data[, tag])
DataCollectionDeleteMessage(sender, data[, tag])
ApplicationClosedMessage(sender[, tag]) A general message issued when Glue application is closed.
DataRemoveComponentMessage(sender, component_id)
LayerArtistEnabledMessage(sender[, tag])
LayerArtistDisabledMessage(sender[, tag])
DataRenameComponentMessage(sender, component_id)
DataReorderComponentMessage(sender, …[, tag])

glue.core.util Module


relim(lo, hi[, log])
split_component_view(arg) Split the input to data or subset.__getitem__ into its pieces.
join_component_view(component, view) Pack a ComponentID and optional view into single tuple.
facet_subsets(data_collection, cid[, lo, …]) Create a series of subsets that partition the values of a particular attribute into several bins
colorize_subsets(subsets, cmap[, lo, hi]) Re-color a list of subsets according to a colormap.
disambiguate(label, taken) If necessary, add a suffix to label to avoid name conflicts
row_lookup(data, categories) Lookup which row in categories each data item is equal to
small_view(data, attribute) Extract a downsampled view from a dataset, for quick statistical summaries
small_view_array(data) Same as small_view, except using a numpy array as input
visible_limits(artists, axis) Determines the data limits for the data in a set of artists.
tick_linker(all_categories, pos, *args)
update_ticks(axes, coord, components, is_log) Changes the axes to have the proper tick formatting based on the type of component.

glue.core.visual Module


VisualAttributes([parent, washout, color, alpha]) This class is used to define visual attributes for any kind of objects

glue.utils.array Module


unique(array) Return the unique elements of the array U, as well as the index array I such that U[I] == array
shape_to_string(shape) On Windows, shape tuples use long ints which results in formatted shapes such as (2L, 3L).
view_shape(shape, view) Return the shape of a view of an array.
stack_view(shape, *views)
coerce_numeric(arr) Coerce an array into a numeric array, replacing non-numeric elements with nans.
check_sorted(array) Return True if the array is sorted, False otherwise.
broadcast_to(array, shape) Compatibility function - can be removed once we support only Numpy 1.10 and above
unbroadcast(array) Given an array, return a new array that is the smallest subset of the original array that can be re-broadcasted back to the original array.
iterate_chunks(shape[, chunk_shape, n_max]) Given a data shape and a chunk shape (or maximum chunk size), iteratively return slice objects that can be used to slice the array.
combine_slices(slice1, slice2, length) Given two slices that can be applied to a 1D array and the length of that array, this returns a new slice which is the one that should be applied to the array instead of slice2 if slice1 has already been applied.
nanmean(array[, axis])
nanmedian(array[, axis])
nansum(array[, axis])
nanmin(array[, axis])
nanmax(array[, axis])
format_minimal(values) Find the shortest format that can be used to represent all values in an array such that all the string representations are different.

glue.utils.geometry Module


points_inside_poly(x, y, vx, vy)
polygon_line_intersections(px, py[, xval, yval]) Find all the segments of intersection between a polygon and an infinite horizontal/vertical line.
floodfill(data, start_coords, threshold)

glue.utils.matplotlib Module


all_artists(fig) Build a set of all Matplotlib artists in a Figure
new_artists(fig, old_artists) Find the newly-added artists in a figure
remove_artists(artists) Remove a collection of matplotlib artists from a scene
get_extent(view[, transpose])
view_cascade(data, view) Return a set of views progressively zoomed out of input at roughly constant pixel count
fast_limits(data, plo, phi) Quickly estimate percentiles in an array, using a downsampled version
defer_draw(func) Decorator that globally defers all Agg canvas draws until function exit.
point_contour(x, y, data) Calculate the contour that passes through (x,y) in data
cache_axes(axes, toolbar) Set up caching for an axes object.
datetime64_to_mpl(d) Convert numpy.datetime64 or an ndarray of those types to Gregorian date as UTC float.


DeferDrawMeta Metaclass that decorates all methods on a class with @defer_draw

glue.utils.misc Module


nonpartial(func, *args, **kwargs) Like functools.partial, this returns a function which, when called, calls func(*args, **kwargs).
lookup_class(ref) Look up an object via its module string (e.g., ‘glue.core.Data’)
as_variable_name(x) Convert a string to a legal python variable name


DeferredMethod(method) This class stubs out a method, and provides a callable interface that logs its calls.
CallbackMixin() A mixin that provides a utility for attaching callback functions to methods
PropertySetMixin An object that provides a set of properties that are meant to encapsulate state information

glue.utils.qt Package


cmap2pixmap(cmap[, steps, size]) Convert a maplotlib colormap into a QPixmap
combo_as_string(combo) Return the text labels of a combo box as a string to make it easier to check the content of a combo box in tests.
connect_color(client, prop, widget)
die_on_error(msg) Decorator that catches errors, displays a popup message, and quits
fix_tab_widget_fontsize(tab_widget) Because of a bug in Qt, tab titles on MacOS X don’t have the right font size
get_text([title, default]) Prompt the user to enter text using Qt
load_ui(path[, parent, directory]) Load a .ui file
messagebox_on_error(msg[, sep]) Decorator that catches exceptions and displays an error message
mpl_to_qt_color(color[, alpha]) Convert a matplotlib color stirng into a Qt QColor object
pick_class(classes[, sort]) Prompt the user to pick from a list of classes using Qt
pick_item(items, labels[, title, label, default]) Prompt the user to choose an item
process_dialog([delay, accept, reject, function]) Context manager to automatically capture the active dialog and carry out certain actions.
qt_to_mpl_color(qcolor) Convert a QColor object into a string that matplotlib understands
qurl_to_path(url) Convert a local QUrl to a normal path
set_cursor(shape) Set the Qt cursor for the duration of a function call, and unset
set_cursor_cm(shape) Context manager equivalent for set_cursor().
tint_pixmap(bm, color) Re-color a monochrome pixmap object using color
update_combobox(combo, labeldata[, …]) Redefine the items in a QComboBox


CenteredDialog A dialog that is centered on the screen.
ColorProperty(att[, docstring])
CompletionTextEdit(parent, parent)
GlueItemWidget([parent]) A mixin for QtWidgets.QListWidget/GlueTreeWidget subclasses, that provides drag+drop funtionality.
HtmlItemDelegate An item delegate that can be used for e.g.
PyMimeData([instance]) A custom MimeData object that stores live python objects
PythonListModel(items[, parent]) A Qt Model that wraps a python list, and exposes a list-like interface
QColorBox(parent, flags, …)
Worker(parent) Execute a function call on a different QThread

glue.utils.qt.widget_properties Module

The classes in this module provide a property-like interface to widget instance variables in a class. These properties translate essential pieces of widget state into more convenient python objects (for example, the check state of a button to a bool).

Example Use:

class Foo(object):
    bar = ButtonProperty('_button')

    def __init__(self):
        self._button = QtWidgets.QCheckBox()

f = Foo()
f.bar = True  # equivalent to f._button.setChecked(True)
assert f.bar == True


WidgetProperty(att[, docstring]) Base class for widget properties
CurrentComboDataProperty(att[, docstring]) Wrapper around the data in QComboBox.
CurrentComboTextProperty(att[, docstring]) Wrapper around the text in QComboBox.
CurrentTabProperty(att[, docstring]) Wrapper around QTabWidget.
TextProperty(att[, docstring]) Wrapper around the text() and setText() methods for QLabel etc
ButtonProperty(att[, docstring]) Wrapper around the check state for QAbstractButton widgets
FloatLineProperty(att[, docstring]) Wrapper around the text state for QLineEdit widgets.
ValueProperty(att[, docstring, value_range, log]) Wrapper around widgets with value() and setValue()