API

Core Data

glue.core.component Module

Classes

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

Classes

PixelComponentID(axis, label[, hidden, parent]) The ID of a component which is a pixel position in the data - this allows us to make assumptions in certain places.
ComponentID(label[, hidden, parent]) References a glue.core.component.Component object within a Data object.
PixelComponentID(axis, label[, hidden, 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)
ComponentIDList

glue.core.data Module

Classes

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

glue.core.data_collection Module

Classes

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

glue.core.hub Module

Classes

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

glue.core.subset Module

Functions

combine_multiple(subsets, operator)

Classes

Subset(data[, color, alpha, label]) Base class to handle subsets of data.
SubsetState()
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.

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

Classes

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

glue.core.roi Module

Classes

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) Base class for objects which use
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) Defines and displays polygonal ROIs on matplotlib plots
MplXRangeROI(axes)
param axes:A matplotlib Axes object to attach the graphical ROI to
MplYRangeROI(axes)
param axes:A matplotlib Axes object to attach the graphical ROI to
XRangeROI([min, max])
RangeROI(orientation[, min, max])
param orientation:
 ‘x’ or ‘y’. Sets which axis to range
YRangeROI([min, max])
VertexROIBase([vx, vy])
param vx:initial x vertices
CategoricalROI([categories]) A ROI abstraction to represent selections of categorical data.

glue.core.data_factories Package

Functions

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[, format, auto_merge]) 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,
is_fits(filename)
is_hdf5(filename)
is_npy(filename) The first bytes are: x93NUMPY
is_npz(filename) The first bytes are: x93NUMPY
latex_factory(file, **kwargs)
load_data(path[, factory]) Use a factory to load a file and assign a label.
npy_reader(filename[, format, auto_merge]) Read in a Numpy structured array saved to a .npy or .npz file.
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
sextractor_factory(file, **kwargs)
tabular_data(path, **kwargs)

Classes

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.

Classes

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.

User Interface

glue.core.application_base Module

Classes

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

glue.viewers.common.qt.data_viewer Module

Classes

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

glue.viewers.scatter.qt.viewer_widget Module

Classes

ScatterWidget(session[, parent]) An interactive scatter plot.

glue.viewers.image.qt.viewer_widget Module

Classes

ImageWidget(session[, parent]) A matplotlib-based image widget
StandaloneImageWidget([image, wcs, parent]) A simplified image viewer, without any brushing or linking, but with the ability to adjust contrast and resample.
ImageWidgetBase(session[, parent]) Widget for ImageClient

glue.viewers.histogram.qt.viewer_widget Module

Classes

HistogramWidget(session[, parent])

glue.app.qt.application Module

Classes

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

Functions

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

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()

Classes

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.
SettingsOracleInterface
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
FormDescriptor(name)
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 Package

Functions

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

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

Classes

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

Viewers

glue.viewers.common.viz_client Module

Classes

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

Classes

Tool([viewer]) The base class for all toolbar tools.
CheckableTool([viewer]) A tool that is checkable.

glue.viewers.common.qt.mouse_mode Module

MouseModes define various mouse gestures.

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

Classes

MouseMode(viewer[, press_callback, ...]) The base class for all MouseModes.
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
ClickRoiMode(viewer, **kwargs) Generate ROIs using clicks and click+drags.
RectangleMode(viewer, **kwargs) Defines a Rectangular ROI, accessible via the roi()
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

Classes

BasicToolbar(str, ...) Create a new toolbar object

glue.viewers.common.qt.mpl_toolbar Module

Classes

HomeTool(viewer[, toolbar])
SaveTool(viewer[, toolbar])
BackTool(viewer[, toolbar])
ForwardTool(viewer[, toolbar])
PanTool(viewer[, toolbar])
ZoomTool(viewer[, toolbar])
MatplotlibViewerToolbar(str, ...)

Utilities

glue.config Module

Classes

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
ViewerToolRegistry()
SingleSubsetLayerActionRegistry() Stores custom menu actions available when user selects a single
ProfileFitterRegistry()
DictRegistry() Base class for registries that are based on dictionaries instead of lists of objects.
PreferencePanesRegistry() Stores preference panes
DataExporterRegistry() Stores data exporters.

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.

Classes

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

glue.core.client Module

Classes

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

glue.core.message Module

Classes

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.

glue.core.util Module

Functions

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
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
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

Classes

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

glue.utils.array Module

Functions

unique(array) Return the unique elements of the array U, as well as
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
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.

glue.utils.geometry Module

Functions

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.

glue.utils.matplotlib Module

Functions

renderless_figure()
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
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.
color2rgb(color)
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.

glue.utils.misc Module

Functions

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
as_list(x)
file_format(filename)
defer(instance, method) Defer the calling of a method inside a context manager, and then call it 0 or 1 times afterwards.

Classes

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
PropertySetMixin An object that provides a set of properties that
Pointer(key)

glue.utils.qt Package

Functions

cmap2pixmap(cmap[, steps, size]) Convert a maplotlib colormap into a QPixmap
connect_color(client, prop, widget)
die_on_error(msg) Decorator that catches errors, displays a popup message, and quits
get_qapp([icon_path])
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) Decorator that catches exceptions and displays an error message
mpl_to_qt4_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.
qt4_to_mpl_color(qcolor) Convert a QColor object into a string that matplotlib understands
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

Classes

ColorProperty(att[, docstring])
CompletionTextEdit(...)
GlueItemWidget([parent]) A mixin for QtWidgets.QListWidget/GlueTreeWidget subclasses, that provides drag+drop funtionality.
GlueTabBar(parent: QWidget = None)
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: QWidget = None, ...)
QColormapCombo(parent: QWidget = None)
Worker(parent: QObject = None) 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

Classes

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()