BaseCartesianData

class glue.core.data.BaseCartesianData[source]

Bases: glue.core.data.BaseData

Base class for any glue data object which indicates which methods should be provided at a minimum.

The underlying data can be any kind of data (structured or unstructured) but it needs to expose an interface that looks like a regular n-dimensional cartesian dataset. This means exposing e.g. shape and ndim, and means that get_data can expect ndarray slices. Non-regular datasets should therefore have the concept of ‘virtual’ pixel coordinates and should typically match the highest resolution a user might want to access the data at.

Attributes Summary

ndim

The number of dimensions of the data, as an integer.

shape

The n-dimensional shape of the dataset, as a tuple.

size

The size of the data (the product of the shape dimensions), as an integer.

Methods Summary

compute_fixed_resolution_buffer(self, bounds)

Get a fixed-resolution buffer.

compute_histogram(self, cids[, weights, …])

Compute an n-dimensional histogram with regularly spaced bins.

compute_statistic(self, statistic, cid[, …])

Compute a statistic for the data.

get_data(self, cid[, view])

Get the data values for a given component

get_mask(self, subset_state[, view])

Get a boolean mask for a given subset state.

Attributes Documentation

ndim[source]

The number of dimensions of the data, as an integer.

shape[source]

The n-dimensional shape of the dataset, as a tuple.

size[source]

The size of the data (the product of the shape dimensions), as an integer.

Methods Documentation

compute_fixed_resolution_buffer(self, bounds, target_data=None, target_cid=None, subset_state=None, broadcast=True)[source]

Get a fixed-resolution buffer.

Parameters
boundslist

The list of bounds for the fixed resolution buffer. This list should have as many items as there are dimensions in target_data. Each item should either be a scalar value, or a tuple of (min, max, nsteps).

target_data~glue.core.Data, optional

The data in whose frame of reference the bounds are defined. Defaults to data.

target_cid~glue.core.component_id.ComponentID, optional

If specified, gives the component ID giving the component to use for the data values. Alternatively, use subset_state to get a subset mask.

subset_state~glue.core.subset.SubsetState, optional

If specified, gives the subset state for which to compute a mask. Alternatively, use target_cid if you want to get data values.

broadcastbool, optional

If True, then if a dimension in target_data for which bounds is not a scalar does not affect any of the dimensions in data, then the final array will be effectively broadcast along this dimension, otherwise an error will be raised.

abstract compute_histogram(self, cids, weights=None, range=None, bins=None, log=None, subset_state=None)[source]

Compute an n-dimensional histogram with regularly spaced bins.

Parameters
cidslist of str or ComponentID

Component IDs to compute the histogram over

weightsstr or ComponentID

Component IDs to use for the histogram weights

rangelist of tuple

The (min, max) of the histogram range

binslist of int

The number of bins

loglist of bool

Whether to compute the histogram in log space

subset_stateSubsetState, optional

If specified, the histogram will only take into account values in the subset state.

abstract compute_statistic(self, statistic, cid, subset_state=None, axis=None, finite=True, positive=False, percentile=None, view=None, random_subset=None)[source]

Compute a statistic for the data.

Parameters
statistic{‘minimum’, ‘maximum’, ‘mean’, ‘median’, ‘sum’, ‘percentile’}

The statistic to compute

cidComponentID or str

The component ID to compute the statistic on - if given as a string this will be assumed to be for the component belonging to the dataset (not external links).

subset_stateSubsetState

If specified, the statistic will only include the values that are in the subset specified by this subset state.

axisNone or int or tuple of int

If specified, the axis/axes to compute the statistic over.

finitebool, optional

Whether to include only finite values in the statistic. This should be True to ignore NaN/Inf values

positivebool, optional

Whether to include only (strictly) positive values in the statistic. This is used for example when computing statistics of data shown in log space.

percentilefloat, optional

If statistic is 'percentile', the percentile argument should be given and specify the percentile to calculate in the range [0:100]

random_subsetint, optional

If specified, this should be an integer giving the number of values to use for the statistic. This can only be used if axis is None

get_data(self, cid, view=None)[source]

Get the data values for a given component

Parameters
cidComponentID

The component ID to get the data for

view

The ‘view’ on the data - anything that is considered a valid Numpy slice/index.

abstract get_mask(self, subset_state, view=None)[source]

Get a boolean mask for a given subset state.

Parameters
subset_stateSubsetState

The subset state to use to compute the mask

view

The ‘view’ on the mask - anything that is considered a valid Numpy slice/index.