cfdm.RaggedContiguousArray.subarrays

RaggedContiguousArray.subarrays(shapes=-1)[source]

Return descriptors for every subarray.

Theses descriptors are used during subarray decompression.

New 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 of tuple. In the latter case chunks must be allowed as an input to subarray_shapes.

A valid chunks specification may always be found by normalising an output of subarray_shapes with dask.array.core.normalize_chunks as follows: chunks = dask.array.core.normalize_chunks(a.subarray_shapes(...), shape=a.shape, dtype=a.dtype).

Returns
4-tuple of iterators

Each iterable iterates over a particular descriptor from each subarray.

  1. The indices of the uncompressed array that correspond to each subarray.

  2. The shape of each uncompressed subarray.

  3. The indices of the compressed array that correspond to each subarray.

  4. The location of each subarray on the uncompressed dimensions.

Examples

An original 2-d array with shape (3, 5) comprising 3 timeSeries features has been compressed as a contiguous ragged array. The features have counts of 2, 5, and 4 elements.

>>> u_indices, u_shapes, c_indices, locations = x.subarrays()
>>> for i in u_indices:
...    print(i)
...
(slice(0, 1, None), slice(0, 5, None))
(slice(1, 2, None), slice(0, 5, None))
(slice(2, 3, None), slice(0, 5, None))
>>> for i in u_shapes
...    print(i)
...
(1, 5)
(1, 5)
(1, 5)
>>> for i in c_indices:
...    print(i)
...
(slice(0, 2, None),)
(slice(2, 7, None),)
(slice(7, 11, None),)
>>> for i in locations:
...    print(i)
...
(0, 0)
(1, 0)
(2, 0)