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[, hidden]) References a glue.core.component.Component object within a Data object.
ComponentIDDict(data, **kwargs)

glue.core.data Module


Data([label]) 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])
CompositeSubsetState(state1[, state2])
OrState(state1[, state2])
AndState(state1[, state2])
XorState(state1[, state2])
InvertState(state1[, state2])
RangeSubsetState(lo, hi[, att])

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
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) 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
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’. 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


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


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.

User Interface

glue.core.application_base Module


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

glue.viewers.common.qt.data_viewer Module


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

glue.viewers.scatter.qt.viewer_widget Module


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

glue.viewers.image.qt.viewer_widget Module


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


HistogramWidget(session[, parent])

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


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

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

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


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

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


VisualAttributes([parent, washout, color]) 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
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.

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.

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

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
defer(*args, **kwds) Defer the calling of a method inside a context manager, and then call it 0 or 1 times afterwards.


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

glue.utils.qt Package


cmap2pixmap(cmap[, steps, size]) Convert a maplotlib colormap into a QPixmap
connect_color(client, prop, widget)
get_text([title]) 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(*args, **kwds) 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
tint_pixmap(bm, color) Re-color a monochrome pixmap object using color
update_combobox(combo, labeldata) Redefine the items in a QComboBox


GlueItemWidget([parent]) A mixin for QtGui.QListWidget/GlueTreeWidget subclasses, that provides drag+drop funtionality.
GlueTabBar(*args, **kwargs)
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(*args, **kwargs)
QColormapCombo(*args, **kwargs)
QMessageBoxPatched(*args, **kwargs)
Worker(func, *args, **kwargs) Execute a function call on a different QThread