hyperspy._signals.complex_signal module

class hyperspy._signals.complex_signal.ComplexSignal(*args, **kwargs)

Bases: hyperspy._signals.complex_signal.ComplexSignal_mixin, hyperspy.signal.BaseSignal

angle(deg=False)

Return the angle (also known as phase or argument). If the data is real, the angle is 0 for positive values and 2\pi for negative values.

Parameters

deg (bool, optional) – Return angle in degrees if True, radians if False (default).

Returns

angle – The counterclockwise angle from the positive real axis on the complex plane, with dtype as numpy.float64.

Return type

HyperSpy signal

class hyperspy._signals.complex_signal.ComplexSignal_mixin(*args, **kwargs)

Bases: object

BaseSignal subclass for complex data.

property amplitude

Get/set the amplitude of the data. Returns an appropriate HyperSpy signal.

angle(angle, deg=False)

Return the angle (also known as phase or argument). If the data is real, the angle is 0 for positive values and 2\pi for negative values.

Parameters

deg (bool, optional) – Return angle in degrees if True, radians if False (default).

Returns

angle – The counterclockwise angle from the positive real axis on the complex plane, with dtype as numpy.float64.

Return type

HyperSpy signal

change_dtype(dtype)

Change the data type.

Parameters

dtype (str or dtype) – Typecode or data-type to which the array is cast. For complex signals only other complex dtypes are allowed. If real valued properties are required use real, imag, amplitude and phase instead.

property imag

Get/set imaginary part of the data. Returns an appropriate HyperSpy signal.

property phase

Get/set the phase of the data. Returns an appropriate HyperSpy signal.

plot(power_spectrum=False, navigator='auto', axes_manager=None, representation='cartesian', norm='auto', fft_shift=False, same_axes=True, **kwargs)

Plot the signal at the current coordinates.

For multidimensional datasets an optional figure, the “navigator”, with a cursor to navigate that data is raised. In any case it is possible to navigate the data using the sliders. Currently only signals with signal_dimension equal to 0, 1 and 2 can be plotted.

Parameters
  • navigator ({"auto", None, "slider", "spectrum", Signal}) – If “auto”, if navigation_dimension > 0, a navigator is provided to explore the data. If navigation_dimension is 1 and the signal is an image the navigator is a spectrum obtained by integrating over the signal axes (the image). If navigation_dimension is 1 and the signal is a spectrum the navigator is an image obtained by stacking horizontally all the spectra in the dataset. If navigation_dimension is > 1, the navigator is an image obtained by integrating the data over the signal axes. Additionaly, if navigation_dimension > 2 a window with one slider per axis is raised to navigate the data. For example, if the dataset consists of 3 navigation axes X, Y, Z and one signal axis, E, the default navigator will be an image obtained by integrating the data over E at the current Z index and a window with sliders for the X, Y and Z axes will be raised. Notice that changing the Z-axis index changes the navigator in this case. If “slider” and the navigation dimension > 0 a window with one slider per axis is raised to navigate the data. If “spectrum” and navigation_dimension > 0 the navigator is always a spectrum obtained by integrating the data over all other axes. If None, no navigator will be provided. Alternatively a Signal instance can be provided. The signal dimension must be 1 (for a spectrum navigator) or 2 (for a image navigator) and navigation_shape must be 0 (for a static navigator) or navigation_shape + signal_shape must be equal to the navigator_shape of the current object (for a dynamic navigator). If the signal dtype is RGB or RGBA this parameters has no effect and is always “slider”.

  • axes_manager ({None, axes_manager}) – If None axes_manager is used.

  • plot_markers (bool, default True) – Plot markers added using s.add_marker(marker, permanent=True). Note, a large number of markers might lead to very slow plotting.

  • norm ({‘auto’, ‘linear’, ‘log’, mpl Normalize instance or subclass},) – default is ‘auto’. Plot the intensity scale on a linear or logarithmic scale. If ‘auto’, plot the intensity on a linear scale except when power_spectrum is True, which can be used only for compatible signal. For Signal2D, a matplotlib Normalize subclass or instance can be provided.

  • power_spectrum (bool, default is False.) – If True, plot the power spectrum instead of the actual signal, if False, plot the real and imaginary parts of the complex signal.

  • representation ({'cartesian' or 'polar'}) – Determines if the real and imaginary part of the complex data is plotted (‘cartesian’, default), or if the amplitude and phase should be used (‘polar’).

  • same_axes (bool, default True) – If True (default) plot the real and imaginary parts (or amplitude and phase) in the same figure if the signal is one-dimensional.

  • fft_shift (bool, default False) – If True, shift the zero-frequency component. See numpy.fft.fftshift for more details.

  • optional (**kwargs,) – Only for 2D signals: additional key word arguments for matplotlib.pyplot.imshow.

property real

Get/set the real part of the data. Returns an appropriate HyperSpy signal.

unwrapped_phase(wrap_around=False, seed=None, show_progressbar=None, parallel=None)

Return the unwrapped phase as an appropriate HyperSpy signal.

Parameters
  • wrap_around (bool or sequence of bool, optional) – When an element of the sequence is True, the unwrapping process will regard the edges along the corresponding axis of the image to be connected and use this connectivity to guide the phase unwrapping process. If only a single boolean is given, it will apply to all axes. Wrap around is not supported for 1D arrays.

  • seed (int, optional) – Unwrapping 2D or 3D images uses random initialization. This sets the seed of the PRNG to achieve deterministic behavior.

  • show_progressbar (None or bool) – If True, display a progress bar. If None the default from the preferences settings is used.

  • parallel (None or bool) – If True, perform computation in parallel using multiple cores. If None the default from the preferences settings is used.

Returns

phase_image – Unwrapped phase.

Return type

BaseSignal subclass

Notes

Uses the unwrap_phase() function from skimage. The algorithm is based on Miguel Arevallilo Herraez, David R. Burton, Michael J. Lalor, and Munther A. Gdeisat, “Fast two-dimensional phase-unwrapping algorithm based on sorting by reliability following a noncontinuous path”, Journal Applied Optics, Vol. 41, No. 35, pp. 7437, 2002

class hyperspy._signals.complex_signal.LazyComplexSignal(*args, **kwargs)

Bases: hyperspy._signals.complex_signal.ComplexSignal, hyperspy._signals.lazy.LazySignal

angle(deg=False)

Return the angle (also known as phase or argument). If the data is real, the angle is 0 for positive values and 2\pi for negative values.

Parameters

deg (bool, optional) – Return angle in degrees if True, radians if False (default).

Returns

angle – The counterclockwise angle from the positive real axis on the complex plane, with dtype as numpy.float64.

Return type

HyperSpy signal

hyperspy._signals.complex_signal.format_title(thing)