cfdm.RaggedIndexedArray.subarrays

RaggedIndexedArray.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 an indexed ragged array. The features have counts of have counts of 2, 5, and 4 elements, at compressed locations (5, 8), (1, 3, 4, 7, 10), and (0, 2, 6, 9) respectively.

>>> 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, 12)
(1, 12)
(1, 12)
>>> for i in c_indices:
...    print(i)
...
(array([5, 8]),)
(array([1, 3, 4, 7, 10]),)
(array([0, 2, 6, 9]),)
>>> for i in locations:
...    print(i)
...
(0, 0)
(1, 0)
(2, 0)