get_chunking#

kikuchipy.signals.util.get_chunking(signal: Optional[Union[EBSD, LazyEBSD]] = None, data_shape: Optional[tuple] = None, nav_dim: Optional[int] = None, sig_dim: Optional[int] = None, chunk_shape: Optional[int] = None, chunk_bytes: Optional[Union[int, float, str]] = 30000000.0, dtype: Optional[Union[str, dtype, type]] = 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 passed: 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 passed if signal is not given.

nav_dim

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

sig_dim

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

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 precedent over the signal data type if signal is given. Must be given if signal is not given.

Returns:
chunks

Chunk tuple.