change_dtype#
- EBSD.change_dtype(*args, **kwargs) None[source]#
Change the data type of a Signal.
This docstring was copied from HyperSpy’s Signal2D.change_dtype. Some inconsistencies with the kikuchipy version may exist.
- Parameters:
- dtype
strornumpy.dtype Typecode string or data-type to which the Signal’s data array is cast. In addition to all the standard numpy Data type objects (dtype), HyperSpy supports four extra dtypes for RGB images:
'rgb8','rgba8','rgb16', and'rgba16'. Changing from and to anyrgb(a)dtype is more constrained than most other dtype conversions. To change to anrgb(a)dtype, the signal_dimension must be 1, and its size should be 3 (forrgb) or 4 (forrgba) dtypes. The original dtype should beuint8oruint16if converting torgb(a)8orrgb(a))16, and the navigation_dimension should be at least 2. After conversion, the signal_dimension becomes 2. The dtype of images with original dtypergb(a)8orrgb(a)16can only be changed touint8oruint16, and the signal_dimension becomes 1.- rechunkbool,
strortuple Only for lazy signal, default is
False. IfFalse, the chunking structure will be retained. IfTrue(use"dask_auto"), the data may be automatically rechunked before performing this operation, when the chunking changes.Chunking options:
"auto": chunking doesn’t split the signal dimension,"dask_auto": uses dask’s automatic chunking,tuple: defines the chunking.
- dtype
Examples
>>> s = hs.signals.Signal1D([1, 2, 3, 4, 5]) >>> s.data array([1, 2, 3, 4, 5]) >>> s.change_dtype('float') >>> s.data array([1., 2., 3., 4., 5.])