NDCollection¶
-
class
ndcube.NDCollection(key_data_pairs, aligned_axes=None, meta=None, **kwargs)[source] [edit on github]¶ Bases:
dictA class for holding and manipulating a collection of aligned NDCube or NDCubeSequences.
- Parameters
data (sequence of
tuple`s of (`str,NDCubeorNDCubeSequence)) – The names and data cubes/sequences to held in the collection.aligned_axes (
tupleofint,tupleoftuple`s of `int, ‘all’, or None, optional) – Axes of each cube/sequence that are aligned in numpy order. If elements are int, then the same axis numbers in all cubes/sequences are aligned. If elements are tuples of ints, then must be one tuple for every cube/sequence. Each element of each tuple gives the axes of each cube/sequence that are aligned. If ‘all’, all axes are aligned in natural order, i.e. the 0th axes of all cubes are aligned, as are the 1st, and so on. Default=Nonemeta (
dict, optional) – General metadata for the overall collection.
Example
Say the collection holds two NDCubes, each of 3 dimensions.
aligned_axes = (1, 2)means that axis 1 (0-based counting) of cube0 is aligned with axis 1 of cube1, and axis 2 of cube0 is aligned with axis 2 of cube1. However, ifaligned_axes = ((0, 1), (2, 1))then the first tuple corresponds to cube0 and the second with cube1. This is interpretted as axis 0 of cube0 is aligned with axis 2 of cube1 while axis 1 of cube0 is aligned with axis 1 of cube1.Attributes Summary
Returns the lengths of all aligned axes.
Returns the physical types of the aligned axes of an ND object in the collection.
Methods Summary
copy()pop(k[,d])If key is not found, default is returned if given, otherwise KeyError is raised
popitem()Remove and return a (key, value) pair as a 2-tuple.
Insert key with a value of default if key is not in the dictionary.
update(*args)Merges a new collection with current one replacing objects with common keys.
Attributes Documentation
-
aligned_dimensions¶ Returns the lengths of all aligned axes.
If there are no aligned axes, returns None.
-
aligned_world_axis_physical_types¶ Returns the physical types of the aligned axes of an ND object in the collection.
If there are no aligned axes, returns None.
Methods Documentation
-
copy() → a shallow copy of D[source] [edit on github]¶
-
pop(k[, d]) → v, remove specified key and return the corresponding value.[source] [edit on github]¶ If key is not found, default is returned if given, otherwise KeyError is raised
-
popitem()[source] [edit on github]¶ Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
-
setdefault()[source] [edit on github]¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
update(*args)[source] [edit on github]¶ Merges a new collection with current one replacing objects with common keys.
Takes either a single input (
NDCollection) or two inputs (sequence of key/value pair and aligned axes associated with each key/value pair.