BaseCartesianData#

class glue.core.data.BaseCartesianData(coords=None)[source]#

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

coords

The coordinates object for the data.

ndim

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

pixel_aligned_data

Information about other datasets in the same data collection that have matching or a subset of pixel component IDs.

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.

world_component_ids

A list of ComponentID giving all world coordinate component IDs in the data.

Methods Summary

compute_fixed_resolution_buffer(bounds[, ...])

Get a fixed-resolution buffer.

compute_histogram(cids[, weights, range, ...])

Compute an n-dimensional histogram with regularly spaced bins.

compute_statistic(statistic, cid[, ...])

Compute a statistic for the data.

get_data(cid[, view])

Get the data values for a given component

get_mask(subset_state[, view])

Get a boolean mask for a given subset state.

Attributes Documentation

coords[source]#

The coordinates object for the data.

ndim[source]#

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

pixel_aligned_data[source]#

Information about other datasets in the same data collection that have matching or a subset of pixel component IDs.

This is returned as a dictionary where each key is a dataset with matching pixel component IDs, and the value is the order in which the pixel component IDs of the other dataset can be found in the current one.

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.

world_component_ids[source]#

A list of ComponentID giving all world coordinate component IDs in the data.

Methods Documentation

compute_fixed_resolution_buffer(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_dataData, optional

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

target_cidComponentID, 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_stateSubsetState, 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(cids, weights=None, range=None, bins=None, log=None, subset_state=None, random_subset=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.

random_subsetint, optional

If specified, this should be an integer giving the number of values to use for the statistic.

abstract compute_statistic(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, optional

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

axisint or tuple of int, optional

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(cid, view=None)[source]#

Get the data values for a given component

Parameters:
cidComponentID

The component ID to get the data for.

viewslice

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

abstract get_mask(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

viewslice

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