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
str
ornumpy.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 beuint8
oruint16
if converting torgb(a)8
orrgb(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)8
orrgb(a)16
can only be changed touint8
oruint16
, and the signal_dimension becomes 1.- rechunkbool
Only has effect when operating on lazy signal. Default
False
, which means the chunking structure will be retained. IfTrue
, the data may be automatically rechunked before performing this operation.
- 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.])