cfdm.AggregatedArray.subarrays¶
- AggregatedArray.subarrays(subarray_shapes)[source]¶
Return descriptors for every subarray.
Added in version (cfdm): 1.12.0.0
See also
- Parameters:
- subarray_shapes:
tuple The subarray sizes along each dimension, as returned by a prior call to
subarray_shapes.
- subarray_shapes:
- Returns:
- 6-
tupleof iterators Each iterator iterates over a particular descriptor from each subarray.
The indices of the aggregated array that correspond to each subarray.
The shape of each subarray.
The indices of the fragment that corresponds to each subarray (some subarrays may be represented by a part of a fragment).
The location of each subarray.
The location on the fragment dimensions of the fragment that corresponds to each subarray.
The shape of each fragment that overlaps each chunk.
- 6-
Examples
An aggregated array with shape (12, 73, 144) has two fragments, both with with shape (6, 73, 144).
>>> a.shape (12, 73, 144) >>> a.get_fragment_array_shape() (2, 1, 1) >>> a.fragmented_dimensions() [0] >>> subarray_shapes = a.subarray_shapes({1: 40}) >>> print(subarray_shapes) ((6, 6), (40, 33), (144,)) >>> ( ... u_indices, ... u_shapes, ... f_indices, ... s_locations, ... f_locations, ... f_shapes, ... ) = a.subarrays(subarray_shapes) >>> for i in u_indices: ... print(i) ... (slice(0, 6, None), slice(0, 40, None), slice(0, 144, None)) (slice(0, 6, None), slice(40, 73, None), slice(0, 144, None)) (slice(6, 12, None), slice(0, 40, None), slice(0, 144, None)) (slice(6, 12, None), slice(40, 73, None), slice(0, 144, None))
>>> for i in u_shapes ... print(i) ... (6, 40, 144) (6, 33, 144) (6, 40, 144) (6, 33, 144) >>> for i in f_indices: ... print(i) ... (slice(None, None, None), slice(0, 40, None), slice(0, 144, None)) (slice(None, None, None), slice(40, 73, None), slice(0, 144, None)) (slice(None, None, None), slice(0, 40, None), slice(0, 144, None)) (slice(None, None, None), slice(40, 73, None), slice(0, 144, None)) >>> for i in s_locations: ... print(i) ... (0, 0, 0) (0, 1, 0) (1, 0, 0) (1, 1, 0) >>> for i in f_locations: ... print(i) ... (0, 0, 0) (0, 0, 0) (1, 0, 0) (1, 0, 0) >>> for i in f_shapes: ... print(i) ... (6, 73, 144) (6, 73, 144) (6, 73, 144) (6, 73, 144)