cf.SubsampledArray.subarrays¶
- SubsampledArray.subarrays(shapes=-1)[source]¶
Return descriptors for every subarray.
These descriptors are used during subarray decompression.
Added in version (cfdm): 1.10.0.0
- Parameters:
- chunks:
-1
or sequence, optional Define the subarray shapes.
Must be either
-1
, the default, meaning that all non-compressed dimensions in each subarray have the maximum possible size; or a sequence oftuple
. In the latter case chunks must be allowed as an input tosubarray_shapes
.A valid chunks specification may always be found by normalising an output of
subarray_shapes
withdask.array.core.normalize_chunks
as follows:chunks = dask.array.core.normalize_chunks(a.subarray_shapes(...), shape=a.shape, dtype=a.dtype)
.
- chunks:
- Returns:
- 6-
tuple
of iterators Each iterator iterates over a particular descriptor from each subarray.
The indices of the uncompressed array that correspond to each interpolation subarea.
Note
If a tie point is shared with a previous interpolation subarea, then that location is excluded from the index, thereby avoiding any overlaps between indices.
The shape of each uncompressed interpolation subarea, excluding the tie point locations defined in previous interpolation subareas.
The indices of the tie point array that correspond to each interpolation subarea. Each index for the tie point interpolated dimensions is expressed as a list of two integers, rather than a
slice
object, to facilitate retrieval of each tie point individually.The index of each interpolation subarea along the interpolation subarea dimensions.
Flags which state, for each interpolated dimension, whether each interpolation subarea is at the start of a continuous area.
The location of each subarray on the uncompressed dimensions. Note that if the tie points are bounds tie points then the uncompressed dimensions include the trailing bounds dimension.
- 6-
Examples
An original 3-d array with shape (20, 12, 15) has been compressed by subsampling with dimensions 0 and 2 being interpolated dimensions. Interpolated dimension 0 (size 20) has two equally-sized continuous areas, each with one interpolation subarea of size 10; and interpolated dimension 2 (size 15) has a single continuous area divided into has three interpolation subareas of sizes 5, 6, and 6.
>>> ( ... u_indices, ... u_shapes, ... c_indices, ... interpolation_subarea_indices, ... new_continuous_area, ... subarray_locations, ... ) = x.subarrays() >>> for i in u_indices: ... print(i) ... (slice(0, 10, None), slice(0, 12, None), slice(0, 5, None)) (slice(0, 10, None), slice(0, 12, None), slice(5, 10, None)) (slice(0, 10, None), slice(0, 12, None), slice(10, 15, None)) (slice(10, 20, None), slice(0, 12, None), slice(0, 5, None)) (slice(10, 20, None), slice(0, 12, None), slice(5, 10, None)) (slice(10, 20, None), slice(0, 12, None), slice(10, 15, None)) >>> for i in u_shapes: ... print(i) ... (10, 12, 5) (10, 12, 5) (10, 12, 5) (10, 12, 5) (10, 12, 5) (10, 12, 5) >>> for i in c_indices, ... print(i) ... (slice(0, 2, None), slice(0, 12, None), slice(0, 2, None)) (slice(0, 2, None), slice(0, 12, None), slice(1, 3, None)) (slice(0, 2, None), slice(0, 12, None), slice(2, 4, None)) (slice(2, 4, None), slice(0, 12, None), slice(0, 2, None)) (slice(2, 4, None), slice(0, 12, None), slice(1, 3, None)) (slice(2, 4, None), slice(0, 12, None), slice(2, 4, None)) >>> for i in interpolation_subarea_indices: ... print(i) ... (slice(0, 1, None), slice(0, 12, None), slice(0, 1, None) (slice(0, 1, None), slice(0, 12, None), slice(1, 2, None) (slice(0, 1, None), slice(0, 12, None), slice(2, 3, None) (slice(1, 2, None), slice(0, 12, None), slice(0, 1, None) (slice(1, 2, None), slice(0, 12, None), slice(1, 2, None) (slice(1, 2, None), slice(0, 12, None), slice(2, 3, None) >>> for i in new_continuous_area: ... print(i) ... (True, None, True) (True, None, False) (True, None, False) (True, None, True) (True, None, False) (True, None, False) >>> for i in subarray_locations: ... print(i) ... (0, 0, 0) (0, 0, 1) (0, 0, 2) (1, 0, 0) (1, 0, 1) (1, 0, 2)