Glue
  • Installing Glue
    • Recommended: Anaconda Python Distribution
    • Enthought Canopy
    • Standalone Application
    • Building from Source (For the Brave)
    • Running Glue
    • Known issues
  • Getting started
    • Opening Data
    • Plotting Data
    • Defining Subsets
    • Refining Subsets and Linked Views
    • Linking Data
    • Saving your work
  • User Interface Guide
    • How Data Linking Works
    • Merging Datasets
    • Defining New Components
    • Spectrum Analysis
    • Slice Extraction
    • Visualizing Astronomical Dendrograms
  • Using the IPython terminal in Glue
  • Working with Data objects
    • Data classes
    • Using Data and DataCollection
    • Adding new attributes to datasets
    • Using lazy attributes
    • Defining new subsets
    • Accessing subset data
    • Creating a data object
  • Starting Glue from Python
    • Quickly send data to Glue with qglue
    • Manual data construction
    • Starting Glue from a script
  • Configuring Glue via a startup file
    • Example Usage: Custom Link Functions
  • Customizing your Glue environment
    • Registries
    • Custom Link Functions
    • Custom Data Loaders
    • Custom importers
    • Custom menubar tools
    • Custom Colormaps
    • Custom Subset Actions
    • Complete list of registries
    • Deferring loading of plug-in functionality (advanced)
  • Programmatically configuring plots
    • Plot Options
    • Customizing Plots with Matplotlib
  • Building Custom Data Viewers
    • The Goal: Basketball Shot Charts
    • Shot Chart Version 1: Heatmap and plot
    • Shot Chart Version 2: Court markings
    • Shot Chart Version 3: Widgets
    • Shot Chart Version 4: Selection
    • Viewer Subclasses
    • Valid Function Arguments
    • UI Elements
    • Other Guidelines
  • Watching data for changes
  • Writing a fully customized Qt viewer (advanced)
    • Motivation
    • Displaying the widget in glue
    • Passing data to the widget
    • Adding side panels
    • Setting up a client
    • Using layers
  • Demo Videos
    • Quick Introduction to Glue (1 minute)
    • 2013 SciPy Conference Talk (20 minutes)
    • The Perseus Shell (2 Minutes)
    • Glue, data cleaning, and civic hacking (5 minutes)
    • Glue, FBI Crime Data, and Plotly (5 minutes)
    • Extracting slices from cubes
  • Frequently Asked Questions
    • Why is Glue crashing on startup?
    • What data formats does Glue understand?
    • How do I overplot catalogs on images in Glue?
    • How do I use Glue with the IPython notebook?
    • Does Glue Understand CASA Cubes?
    • Something is broken, or confusing. What should I do?
    • How do I make a scatterplot of columns from two different catalogs?
    • How do I make a scatterplot between two images?
    • I have some other question...?
  • Getting Help with Glue
  • The selection/subset framework
    • Regions of interest
    • Subset states
    • Subsets
  • The communication framework
    • Publish/Subscribe model
    • Typical workflow
  • The linking framework
    • Creating component links programmatically
    • Built-in link functions
  • Developer Guide
    • Code organization
    • Qt development in Glue
    • Coding guidelines
    • Testing framework
    • How the MacOS X app is built
  • API
    • Core Data
    • User Interface
    • Viewers
    • Utilities
 
Glue
  • Docs »
  • API »
  • ComponentLink
  • Edit on GitHub

ComponentLink¶

class glue.core.component_link.ComponentLink(comp_from, comp_to, using=None, inverse=None)[source]¶

Bases: object

ComponentLinks represent transformation logic between ComponentIDs

ComponentLinks are be used to derive one ComponentID from another:

Example:

def hours_to_minutes(hours):
    return hours * 60

d = Data(hour=[1, 2, 3])
hour = d.id['hour']
minute = ComponentID('minute')
link = ComponentLink( [hour], minute, using=hours_to_minutes)

link.compute(d)  # array([ 60, 120, 180])
d.add_component_link(link)
d['minute'] # array([ 60, 120, 180])
Parameters:
  • comp_from (ComponentID) – The input ComponentIDs
  • comp_to – The target component ID
Pram using:

The translation function which maps data from comp_from to comp_to (optional)

The using function should satisfy:

using(data[comp_from[0]],...,data[comp_from[-1]]) = desired data
Parameters:inverse – The inverse translation function, if exists (optional)
Raises:TypeError if input is invalid

Note

Both inverse and using should accept and return numpy arrays

Methods Summary

compute(data[, view]) For a given data set, compute the component comp_to given
get_from_ids() The list of input ComponentIDs
get_inverse() The inverse transformation, or None
get_to_id() The target ComponentID
get_using() The transformation function
replace_ids(old, new) Replace all references to an old ComponentID with references
set_from_ids(_from)
set_to_id(to)

Methods Documentation

compute(data, view=None)[source]¶

For a given data set, compute the component comp_to given the data associated with each comp_from and the using function

Parameters:
  • data – The data set to use
  • view – Optional view (e.g. slice) through the data to use

Returns:

The data associated with comp_to component

Raises:

InvalidAttribute, if the data set doesn’t have all the ComponentIDs needed for the transformation
get_from_ids()[source]¶

The list of input ComponentIDs

get_inverse()[source]¶

The inverse transformation, or None

get_to_id()[source]¶

The target ComponentID

get_using()[source]¶

The transformation function

replace_ids(old, new)[source]¶

Replace all references to an old ComponentID with references to new

Parma old:ComponentID to replace
Parameters:new – ComponentID to replace with
set_from_ids(_from)[source]¶
set_to_id(to)[source]¶
Next Previous

© Copyright 2012-2016, Chris Beaumont, Thomas Robitaille, Michelle Borkin.

Built with Sphinx using a theme provided by Read the Docs.