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 thechunk_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 typedtype
.- 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 ifsignal
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 default30e6
, 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 ifsignal
is not.
- Returns:
chunks
Chunk tuple.