get_chunking#

kikuchipy.signals.util.get_chunking(signal: EBSD | LazyEBSD | None = None, data_shape: tuple | None = None, nav_dim: int | None = None, sig_dim: int | None = None, chunk_shape: int | None = None, chunk_bytes: int | float | str | None = 30000000.0, dtype: str | dtype | type | None = None) tuple[source]#

Get a chunk tuple based on the shape of the signal data.

The signal dimensions will not be chunked, and the navigation dimensions will be chunked based on either chunk_shape, or be optimized based on the chunk_bytes.

This function is inspired by a similar function in pyxem.

Parameters:
signal

If not given, the following must be: data shape to be chunked, data_shape, the number of navigation dimensions, nav_dim, the number of signal dimensions, sig_dim, and the data array data type dtype.

data_shape

Data shape, must be given if signal is not.

nav_dim

Number of navigation dimensions, must be given if signal is not.

sig_dim

Number of signal dimensions, must be given if signal is not.

chunk_shape

Shape of navigation chunks. If not given, this size is set automatically based on chunk_bytes. This is a rectangle if signal has two navigation dimensions.

chunk_bytes

Number of bytes in each chunk. Default is 30e6, i.e. 30 MB. Only used if freedom is given to choose, i.e. if chunk_shape is not given. Various parameter types are allowed, e.g. 30000000, "30 MB", "30MiB", or the default 30e6, all resulting in approximately 30 MB chunks.

dtype

Data type of the array to chunk. Will take precedence over the signal data type if signal is given. Must be given if signal is not.

Returns:
chunks

Chunk tuple.