Subset#

class glue.core.subset.Subset(data, **kwargs)[source]#

Bases: object

Base class to handle subsets of data.

These objects both describe subsets of a dataset, and relay any state changes to the hub that their parent data are assigned to.

This base class only directly implements the logic that relays state changes back to the hub. Subclasses implement the actual description and manipulation of data subsets

Parameters:
dataData

The dataset that this subset describes

Create a new subset object.

Note: the preferred way for creating subsets is via new_subset_group(). Manually-instantiated subsets will probably not be represented properly by the UI

Attributes Summary

attributes

Returns a tuple of the ComponentIDs that this subset depends upon.

components

coordinate_components

derived_components

hub

label

Convenience access to subset's label.

main_components

ndim

pixel_component_ids

primary_components

shape

size

style

subset_state

uuid

visible_components

world_component_ids

Methods Summary

broadcast(attribute)

Explicitly broadcast a SubsetUpdateMessage to the hub.

component_ids()

delete()

Broadcast a SubsetDeleteMessage to the hub, and stop broadcasting.

do_broadcast(value)

Set whether state changes to the subset are relayed to a hub.

paste(other_subset)

Paste subset state from other_subset onto self.

read_mask(file_name)

register()

Register a subset to its data, and start broadcasting state changes

state_as_mask()

Convert the current SubsetState to a MaskSubsetState.

to_index_list()

Convert the current subset to a list of indices.

to_mask([view])

Convert the current subset to a mask.

write_mask(file_name[, format])

Write a subset mask out to file

Attributes Documentation

attributes[source]#

Returns a tuple of the ComponentIDs that this subset depends upon.

components[source]#
coordinate_components[source]#
derived_components[source]#
hub[source]#
label[source]#

Convenience access to subset’s label.

main_components[source]#
ndim[source]#
pixel_component_ids[source]#
primary_components[source]#
shape[source]#
size[source]#
style[source]#
subset_state[source]#
uuid[source]#
visible_components[source]#
world_component_ids[source]#

Methods Documentation

broadcast(attribute)[source]#

Explicitly broadcast a SubsetUpdateMessage to the hub.

Parameters:
attributestr

The name of the attribute (if any) that should be broadcast as updated.

component_ids()[source]#
delete()[source]#

Broadcast a SubsetDeleteMessage to the hub, and stop broadcasting.

Also removes subset reference from parent data’s subsets list.

do_broadcast(value)[source]#

Set whether state changes to the subset are relayed to a hub.

It can be useful to turn off broadcasting, when modifying the subset in ways that don’t impact any of the clients.

Attributes:
valuebool

Whether the subset should broadcast state changes (True/False)

paste(other_subset)[source]#

Paste subset state from other_subset onto self.

read_mask(file_name)[source]#
register()[source]#

Register a subset to its data, and start broadcasting state changes

state_as_mask()[source]#

Convert the current SubsetState to a MaskSubsetState.

to_index_list()[source]#

Convert the current subset to a list of indices. These index the elements in the (flattened) data object that belong to the subset.

If x is the numpy array corresponding to some component.data, the two following statements are equivalent:

x.flat[subset.to_index_list()]
x[subset.to_mask()]
Returns:
ndarray

A numpy array, giving the indices of elements in the data that belong to this subset.

Raises:
IncompatibleDataException

If an index list cannot be created for the requested data set.

to_mask(view=None)[source]#

Convert the current subset to a mask.

Parameters:
viewobject

An optional view into the dataset (e.g. a slice) If present, the mask will pertain to the view and not the entire dataset.

Returns:
ndarray

A boolean numpy array, the same shape as the data, that defines whether each element belongs to the subset.

write_mask(file_name, format='fits')[source]#

Write a subset mask out to file

Parameters:
file_namestr

Name of file to write to

formatstr, optional

Name of format to write to. Currently, only “fits” is supported.