cdiutils.interactive.ThreeDViewer#
- class cdiutils.interactive.ThreeDViewer(**kwargs)[source]#
Widget to display 3D objects from CDI optimisation using Plotly.
This class provides interactive 3D visualisation of volumetric data with controls for threshold, phase/amplitude display, and colormap selection.
- Interactive controls:
Threshold slider: controls the isosurface level
Phase/Amplitude toggle: switches between phase and amplitude display
Colormap dropdown: selects the colormap for the surface colour
Auto-scale checkbox: automatically scales the colorbar to data range
Symmetric checkbox: forces the colorbar to be symmetric around zero
Set limits checkbox: enables manual vmin/vmax input fields
Replace NaN with mean checkbox: replaces NaN values in the displayed quantity with the mean value to avoid weird colouring artefacts
- cmap_options = ('turbo', 'viridis', 'inferno', 'magma', 'plasma', 'cividis', 'RdBu', 'coolwarm', 'twilight', 'Blues', 'Greens', 'Greys', 'Purples', 'Oranges', 'Reds', 'cet_CET_D13', 'cet_CET_C9s_r', 'cet_CET_D1A', 'jch_const', 'jch_max')#
- __init__(input_file=None, html_width=None, voxel_size=(1, 1, 1), figsize=(9, 6))[source]#
Initialise the 3D viewer with Plotly backend.
- Parameters:
input_file (np.ndarray | None, optional) – 3D complex array to visualise. Defaults to None.
html_width (int | None, optional) – HTML width in %. If given, the width of the notebook will be changed to that value (e.g. full width with 100). Defaults to None.
voxel_size (tuple, optional) – voxel size (dx, dy, dz) for proper scaling. Defaults to (1, 1, 1).
figsize (tuple, optional) – figure size in inches (width, height). Defaults to (9, 6).
- Raises:
ImportError – if plotly or required packages are not installed.