Visualization
svetlanna.visualization.show_structure
Display setup structure in an IPython environment.
This helper renders only the hierarchy of elements (without parameter specs) and is useful for quick notebook previews.
Parameters:
-
*specsable(Specsable, default:()) –One or more
Specsableobjects to display.
Examples:
svetlanna.visualization.show_specs
Display setup structure with interactive specs preview.
Returns:
-
SpecsWidget–Widget with element tree and per-element specs HTML.
Examples:
svetlanna.visualization.show_stepwise_forward
show_stepwise_forward(
*specsable: Specsable,
input: Tensor,
simulation_parameters: SimulationParameters,
types_to_plot: tuple[StepwisePlotTypes, ...] = (
"I",
"phase",
),
slices_to_plot: (
Mapping[str, Index | tuple[Index, ...]] | None
) = None
) -> StepwiseForwardWidget
Display stepwise wavefront propagation for setup elements.
The function registers forward hooks on torch.nn.Module elements,
runs a forward pass for each provided root element, captures intermediate
outputs, renders them as images, and returns an interactive widget.
Parameters:
-
input(Tensor) –Input wavefront.
-
simulation_parameters(SimulationParameters) –Simulation parameters
-
types_to_plot(tuple[StepwisePlotTypes, ...], default:('I', 'phase')) –Field properties to plot, by default (
"I","phase"). -
slices_to_plot(Mapping[str, Index | tuple[Index, ...]] | None, default:None) –Axis slices to apply before plotting each captured output. Default is
None.
Returns:
-
StepwiseForwardWidget–Widget containing setup structure and captured per-element outputs.
Examples:
Basic usage:
Spatial slicing with boolean masks:
Use named axis slicing to focus on a region of interest. Plot only the central area:
Integer indexing for named axes:
Select a specific value from a named axis (e.g., wavelength channel).
Slicing unnamed axes (batch dimensions):
Use the special key "_" with a tuple of slices for unnamed leading axes.
Combining named and unnamed slicing:
You can mix both approaches.
Named axes override positional slices from "_".