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
andndim
, 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
The coordinates object for the data.
The number of dimensions of the data, as an integer.
The n-dimensional shape of the dataset, as a tuple.
The size of the data (the product of the shape dimensions), as an integer.
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
- 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_data
Data
, optional The data in whose frame of reference the bounds are defined. Defaults to
data
.- target_cid
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
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 whichbounds
is not a scalar does not affect any of the dimensions indata
, 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)[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_state
SubsetState
, optional If specified, the histogram will only take into account values in the subset state.
- cidslist of str or
- 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
- cid
ComponentID
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_state
SubsetState
, 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'
, thepercentile
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
- cid
ComponentID
The component ID to get the data for.
- viewslice
The ‘view’ on the data - anything that is considered a valid Numpy slice/index.
- cid
- abstract get_mask(subset_state, view=None)[source]¶
Get a boolean mask for a given subset state.
- Parameters
- subset_state
SubsetState
The subset state to use to compute the mask
- viewslice
The ‘view’ on the mask - anything that is considered a valid Numpy slice/index.
- subset_state