Data.section(axes, stop=None, chunks=False, min_step=1, mode='dictionary')[source]

Returns a dictionary of sections of the Data object.

Specifically, returns a dictionary of Data objects which are the m-dimensional sections of this n-dimensional Data object, where m <= n. The dictionary keys are the indices of the sections in the original Data object. The m dimensions that are not sliced are marked with None as a placeholder making it possible to reconstruct the original data object. The corresponding values are the resulting sections of type Data.

axes: (sequence of) int

This is should be one or more integers of the m indices of the m axes that define the sections of the Data object. If axes is None (the default) or an empty sequence then all axes are selected.

Note that the axes specified by the axes parameter are the one which are to be kept whole. All other axes are sectioned.

stop: int, optional

Deprecated at version 3.14.0.

Stop after this number of sections and return. If stop is None all sections are taken.

chunks: bool, optional

Deprecated at version 3.14.0. Consider using cf.Data.rechunk instead.

If True return sections that are of the maximum possible size that will fit in one chunk of memory instead of sectioning into slices of size 1 along the dimensions that are being sectioned.

min_step: int, optional

The minimum step size when making chunks. By default this is 1. Can be set higher to avoid size 1 dimensions, which are problematic for linear regridding.


The dictionary of m dimensional sections of the Data object.


>>> d = cf.Data(np.arange(120).reshape(2, 6, 10))
>>> d
<CF Data(2, 6, 10): [[[0, ..., 119]]]>
>>> d.section([1, 2])
{(0, None, None): <CF Data(1, 6, 10): [[[0, ..., 59]]]>,
 (1, None, None): <CF Data(1, 6, 10): [[[60, ..., 119]]]>}
>>> d.section([0, 1], min_step=2)
{(None, None, 0): <CF Data(2, 6, 2): [[[0, ..., 111]]]>,
 (None, None, 2): <CF Data(2, 6, 2): [[[2, ..., 113]]]>,
 (None, None, 4): <CF Data(2, 6, 2): [[[4, ..., 115]]]>,
 (None, None, 6): <CF Data(2, 6, 2): [[[6, ..., 117]]]>,
 (None, None, 8): <CF Data(2, 6, 2): [[[8, ..., 119]]]>}