NDCubeSequence#
- class ndcube.NDCubeSequence(data_list, meta=None, common_axis=None, **kwargs)[source]#
Bases:
NDCubeSequenceBase
Class representing a sequence of
NDCube
-like objects.The cubes are assumed to have the same dimensionality and axis physical types.
- Parameters:
data_list (
list
) – List ofndcube.NDCube
-like objects.meta (
dict
or None) – Meta data relevant to the sequence as a whole.common_axis (
int
or None) – The array axis of the cubes along which the cubes are ordered. For example, if the cubes are sequenced in chronological order and time is the 1st axis of each Cube, then common_axis should be set to 0. This enables the “cube_like” methods to be used, e.g.ndcube.NDCubeSequence.index_as_cube
which slices the sequence as though it were a single cube concatenated along the common axis.
Attributes Summary
The physical types associated with each array axis, including the sequence axis.
The coordinate values at each location along the common axis across all cubes.
The physical types associated with each array axis, omitting the sequence axis.
The length of each array axis as if all cubes were concatenated along the common axis.
The length of each array axis as if all cubes were concatenated along the common axis.
The length of each axis including the sequence axis.
Slice the NDCubesequence instance as a single cube concatenated along the common axis.
Return the coordinate values along the sequence axis.
Methods Summary
crop
(*points[, wcses])Crop cubes in sequence to smallest pixel-space bounding box containing the input points.
crop_by_values
(*points[, units, wcses])Crop cubes in sequence to smallest pixel-space bounding box containing the input points.
explode_along_axis
(axis)Separates slices of N-D cubes along a given cube axis into (N-1)D cubes.
plot
([sequence_axis_coords, sequence_axis_unit])Visualize the
NDCubeSequence
.plot_as_cube
(*args, **kwargs)Attributes Documentation
- array_axis_physical_types#
The physical types associated with each array axis, including the sequence axis.
- common_axis_coords#
The coordinate values at each location along the common axis across all cubes.
Only coordinates associated with the common axis in all cubes in the sequence are returned. Coordinates from different cubes are concatenated along the common axis. They thus represent the coordinate values at each location as if all cubes in the sequence were concatenated along the common axis.
- cube_like_array_axis_physical_types#
The physical types associated with each array axis, omitting the sequence axis.
- cube_like_dimensions#
The length of each array axis as if all cubes were concatenated along the common axis.
- cube_like_shape#
The length of each array axis as if all cubes were concatenated along the common axis.
- dimensions#
The length of each axis including the sequence axis.
- index_as_cube#
Slice the NDCubesequence instance as a single cube concatenated along the common axis.
Example
>>> # Say we have three Cubes each cube has common_axis=0 is time and shape=(3,3,3) >>> data_list = [cubeA, cubeB, cubeC] >>> cs = NDCubeSequence(data_list, meta=None, common_axis=0) >>> # return zeroth time slice of cubeB in via normal NDCubeSequence indexing. >>> cs[1,:,0,:] >>> # Return same slice using this function >>> cs.index_as_cube[3:6, 0, :]
- plotter = None#
- sequence_axis_coords#
Return the coordinate values along the sequence axis.
These are compiled from the
GlobalCoords
objects attached to eachNDCube
where each cube represents a location along the sequence axis. Only coordinates that are common to all cubes are returned.
- shape#
Methods Documentation
- crop(*points, wcses=None)#
Crop cubes in sequence to smallest pixel-space bounding box containing the input points.
Each input point is given as a tuple of high-level world coordinate objects. This method does not crop the sequence axis. Instead input points are passed to the crop method of cubes in sequence. Note, therefore, that the input points do not include an entry for world coords only associated with the sequence axis. For a description of how the bounding box is defined, see the docstring of the
ndcube.NDCube.crop()
method. In cases where the cubes are not aligned, all cubes are cropped to the same region in pixel space. This region will be the smallest that encompasses the input points in all cubes while maintaining consistent array shape between the cubes.- Parameters:
points – Passed to
ndcube.NDCube.crop()
as the points arg without checking.wcses (iterable of WCS objects or
str
, optional) – The WCS objects to be used to crop the cubes. There must by one WCS per cube. Alternatively, can be a string giving the name of the cube wcs attribute to be used, namely, ‘wcs’, ‘combined_wcs’, or ‘extra_coords’. Default=None is equivalent to ‘wcs’.
- Returns:
NDCubeSequence
– The cropped sequence.
- crop_by_values(*points, units=None, wcses=None)#
Crop cubes in sequence to smallest pixel-space bounding box containing the input points.
Each input point is given as a tuple of low-level world coordinate objects. This method does not crop the sequence axis. Instead input points are passed to the
ndcube.NDCube.crop_by_values()
method of cubes in sequence. Note, therefore, that the input points do not include an entry for world coords only associated with the sequence axis. For a description of how the bounding box is defined, see the docstring of the NDCube.crop_by_values method. In cases where the cubes are not aligned, all cubes are cropped to the same region in pixel space. This region will be the smallest that encompasses the input points in all cubes while maintaining consistent array shape between the cubes.- Parameters:
points – Passed to
ndcube.NDCube.crop()
as the points arg without checking.units – Passed to
ndcube.NDCube.crop_by_values()
as theunits
kwarg.wcses (iterable of WCS objects or
str
, optional) – The WCS objects to be used to crop the cubes. There must by one WCS per cube. Alternatively, can be a string giving the name of the cube wcs attribute to be used, namely, ‘wcs’, ‘combined_wcs’, or ‘extra_coords’. Default=None is equivalent to ‘wcs’.
- Returns:
NDCubeSequence
– The cropped sequence.
- explode_along_axis(axis)#
Separates slices of N-D cubes along a given cube axis into (N-1)D cubes.
- Parameters:
axis (
int
) – The axis along which the data is to be changed.- Returns:
ndcube.NDCubeSequence
– New sequence of (N-1)D cubes broken up along given axis.
- plot(sequence_axis_coords=None, sequence_axis_unit=None, **kwargs)#
Visualize the
NDCubeSequence
.- Parameters:
sequence_axis_coords (
str
or array-like, optional) – The real world value of each step along the sequence axis. Ifstr
, the values are taken fromndcube.NDCubeSequence.sequence_axis_coords
.sequence_axis_unit (
str
orastropy.units.Unit
, optional) – The unit in which to display the sequence_axis_coords.