ShowComplex2D#
- class quantem.widget.ShowComplex2D(**kwargs: Any)[source]#
Bases:
AnyWidgetInteractive viewer for complex-valued 2D data.
Display complex images from ptychography, holography, or exit wave reconstruction with five visualization modes: amplitude, phase, HSV (hue=phase, brightness=amplitude), real part, and imaginary part.
- Parameters:
data (array_like (complex) or tuple of (real, imag)) – Complex 2D array of shape (height, width) with dtype complex64 or complex128. Also accepts a tuple
(real, imag)of two real arrays.display_mode (str, default "amplitude") – Initial display mode:
"amplitude","phase","hsv","real", or"imag".title (str, optional) – Title displayed in the widget header.
cmap (str, default "inferno") – Colormap for amplitude/real/imag modes. Phase and HSV modes use a fixed cyclic colormap.
pixel_size (float, default 0.0) – Pixel size in angstroms for scale bar display.
log_scale (bool, default False) – Apply log(1+x) to amplitude before display.
auto_contrast (bool, default False) – Use percentile-based contrast.
show_fft (bool, default False) – Show FFT panel.
show_stats (bool, default True) – Show statistics bar.
show_controls (bool, default True) – Show control panel.
Examples
>>> import numpy as np >>> from quantem.widget import ShowComplex2D >>> >>> # Complex exit wave >>> data = np.exp(1j * phase) * amplitude >>> ShowComplex2D(data, title="Exit Wave", display_mode="hsv") >>> >>> # From real and imaginary parts >>> ShowComplex2D((real_part, imag_part), display_mode="phase")
Key Methods
- ShowComplex2D.save_image(path: str | Path, *, display_mode: str | None = None, format: str | None = None, dpi: int = 150) Path[source]#
Save current view as PNG, PDF, or TIFF.
- Parameters:
path (str or pathlib.Path) – Output file path.
display_mode (str, optional) – Override display mode. One of ‘amplitude’, ‘phase’, ‘hsv’, ‘real’, ‘imag’. Defaults to current display_mode.
format (str, optional) – ‘png’, ‘pdf’, or ‘tiff’. If omitted, inferred from file extension.
dpi (int, default 150) – Output DPI metadata.
- Returns:
The written file path.
- Return type:
- ShowComplex2D.roi_circle(row=None, col=None, radius=None) ShowComplex2D[source]#
- ShowComplex2D.roi_square(row=None, col=None, radius=None) ShowComplex2D[source]#
- ShowComplex2D.roi_rect(row=None, col=None, width=None, height=None) ShowComplex2D[source]#