ComplexSignal2D#

class hyperspy.api.signals.ComplexSignal2D(*args, **kw)#

Bases: ComplexSignal, CommonSignal2D

Signal class for complex 2-dimensional data.

Create a signal instance.

Parameters:
datanumpy.ndarray

The signal data. It can be an array of any dimensions.

axes[dict/axes], optional

List of either dictionaries or axes objects to define the axes (see the documentation of the AxesManager class for more details).

attributesdict, optional

A dictionary whose items are stored as attributes.

metadatadict, optional

A dictionary containing a set of parameters that will to stores in the metadata attribute. Some parameters might be mandatory in some cases.

original_metadatadict, optional

A dictionary containing a set of parameters that will to stores in the original_metadata attribute. It typically contains all the parameters that has been imported from the original data file.

raggedbool or None, optional

Define whether the signal is ragged or not. Overwrite the ragged value in the attributes dictionary. If None, it does nothing. Default is None.

add_phase_ramp(ramp_x, ramp_y, offset=0)#

Add a linear phase ramp to the wave.

Parameters:
ramp_x: float

Slope of the ramp in x-direction.

ramp_y: float

Slope of the ramp in y-direction.

offset: float, optional

Offset of the ramp at the fulcrum.

Notes
—–
The fulcrum of the linear ramp is at the origin and the slopes are
given in units of the axis with the corresponding scale taken into
account. Both are available via the
:attr:`~hyperspy.api.signals.BaseSignal.axes_manager`.
plot(power_spectrum=False, fft_shift=False, navigator='auto', plot_markers=True, autoscale='v', norm='auto', vmin=None, vmax=None, gamma=1.0, linthresh=0.01, linscale=0.1, scalebar=True, scalebar_color='white', axes_ticks=None, axes_off=False, axes_manager=None, no_nans=False, colorbar=True, centre_colormap='auto', min_aspect=0.1, **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:
power_spectrumbool, default 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' | '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_axesbool, 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_shiftbool, default False

If True, shift the zero-frequency component. See numpy.fft.fftshift() for more details.

navigatorstr, None, or BaseSignal (or subclass).
Allowed string values are ``’auto’``, ``’slider’``, and ``’spectrum’``.
  • 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 sum 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 all the spectra in the dataset horizontally.

    • If navigation_dimension is > 1, the navigator is a sum image obtained by integrating the data over the signal axes.

    • Additionally, 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.

    • For lazy signals, the navigator will be calculated using the compute_navigator() method.

  • If 'slider':

    • If navigation dimension > 0 a window with one slider per axis is raised to navigate the data.

  • If 'spectrum':

    • If navigation_dimension > 0 the navigator is always a spectrum obtained by integrating the data over all other axes.

    • Not supported for lazy signals, the 'auto' option will be used instead.

  • If None, no navigator will be provided.

Alternatively a BaseSignal (or subclass) instance can be provided. The navigation or signal shape must match the navigation shape of the signal to plot or the 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 parameter has no effect and the value is always set to 'slider'.

axes_managerNone or AxesManager

If None, the signal’s axes_manager attribute is used.

plot_markersbool, default True

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

navigator_kwdsdict

Only for image navigator, additional keyword arguments for matplotlib.pyplot.imshow().

colorbarbool, optional

If true, a colorbar is plotted for non-RGB images.

autoscalestr, optional

The string must contain any combination of the 'x', 'y' and 'v' characters. If 'x' or 'y' are in the string, the corresponding axis limits are set to cover the full range of the data at a given position. If 'v' (for values) is in the string, the contrast of the image will be set automatically according to vmin` and ``vmax when the data or navigation indices change. Default is 'v'.

normstr {"auto"` | ``"linear" | "power" | "log" | "symlog"} or matplotlib.colors.Normalize

Set the norm of the image to display. If "auto", a linear scale is used except if when power_spectrum=True in case of complex data type. "symlog" can be used to display negative value on a negative scale - read matplotlib.colors.SymLogNorm and the linthresh and linscale parameter for more details.

vmin, vmax{scalar, str}, optional

vmin and vmax are used to normalise the displayed data. It can be a float or a string. If string, it should be formatted as 'xth', where 'x' must be an float in the [0, 100] range. 'x' is used to compute the x-th percentile of the data. See numpy.percentile() for more information.

gammafloat, optional

Parameter used in the power-law normalisation when the parameter norm="power". Read matplotlib.colors.PowerNorm for more details. Default value is 1.0.

linthreshfloat, optional

When used with norm="symlog", define the range within which the plot is linear (to avoid having the plot go to infinity around zero). Default value is 0.01.

linscalefloat, optional

This allows the linear range (-linthresh to linthresh) to be stretched relative to the logarithmic range. Its value is the number of powers of base to use for each half of the linear range. See matplotlib.colors.SymLogNorm for more details. Defaulf value is 0.1.

scalebarbool, optional

If True and the units and scale of the x and y axes are the same a scale bar is plotted.

scalebar_colorstr, optional

A valid MPL color string; will be used as the scalebar color.

axes_ticks{None, bool}, optional

If True, plot the axes ticks. If None axes_ticks are only plotted when the scale bar is not plotted. If False the axes ticks are never plotted.

axes_offbool, default False
no_nansbool, optional

If True, set nans to zero for plotting.

centre_colormapbool or "auto"

If True the centre of the color scheme is set to zero. This is specially useful when using diverging color schemes. If “auto” (default), diverging color schemes are automatically centred.

min_aspectfloat, optional

Set the minimum aspect ratio of the image and the figure. To keep the image in the aspect limit the pixels are made rectangular.

**kwargsdict

Only when plotting an image: additional (optional) keyword arguments for matplotlib.pyplot.imshow().