svetlanna.visualization package

Submodules

svetlanna.visualization.widgets module

class svetlanna.visualization.widgets.ElementHTML(element_type: str | None, html: str)

Bases: object

Representation of an element in HTML format.

element_type: str | None
html: str
class svetlanna.visualization.widgets.SpecsWidget(**kwargs: Any)

Bases: AnyWidget

elements

An instance of a Python list.

structure_html

A trait for unicode strings.

class svetlanna.visualization.widgets.StepwiseForwardWidget(**kwargs: Any)

Bases: AnyWidget

elements

An instance of a Python list.

structure_html

A trait for unicode strings.

svetlanna.visualization.widgets.default_widget_html_method(index: int, name: str, element_type: str | None, subelements: list[ElementHTML]) str

Default _widget_html_ method used for rendering Specsable elements.

Parameters

indexint

The unique index of the element. Should be used as an id of HTML element containing the element.

namestr

Human readable name of the element

element_typestr | None

Human readable type of the element as a subelement, if any

subelementslist[ElementHTML]

Subelements of the element.

Returns

str

rendered HTML

svetlanna.visualization.widgets.draw_wavefront(wavefront: Tensor, simulation_parameters: SimulationParameters, types_to_plot: tuple[Literal['A', 'I', 'phase', 'Re', 'Im'], ...] = ('I', 'phase')) bytes

Show field propagation in the setup via widget. Currently only wavefronts of shape (W, H) are supported.

Parameters

wavefrontTensor

The Input wavefront

simulation_parametersSimulationParameters

Simulation parameters

types_to_plottuple[StepwisePlotTypes, …], optional

Field properties to plot, by default (‘I’, ‘phase’)

Returns

bytes

byte-coded image

svetlanna.visualization.widgets.generate_structure_html(subelements: list[_ElementInTree]) str

Generate HTML for a setup structure.

Parameters

subelementslist[_ElementInTree]

Elements tree

Returns

str

Rendered HTML

svetlanna.visualization.widgets.show_specs(*specsable: Specsable) SpecsWidget

Display a setup structure with interactive specs preview

Returns

SpecsWidget

The widget

svetlanna.visualization.widgets.show_stepwise_forward(*specsable: Specsable, input: Tensor, simulation_parameters: SimulationParameters, types_to_plot: tuple[Literal['A', 'I', 'phase', 'Re', 'Im'], ...] = ('I', 'phase')) StepwiseForwardWidget

Display the wavefront propagation through a setup structure using a widget interface. Currently only wavefronts of shape (W, H) are supported.

Parameters

inputtorch.Tensor

The Input wavefront

simulation_parametersSimulationParameters

Simulation parameters

types_to_plottuple[StepwisePlotTypes, …], optional

Field properties to plot, by default (‘I’, ‘phase’)

Returns

StepwiseForwardWidget

The widget

svetlanna.visualization.widgets.show_structure(*specsable: Specsable)

Display a setup structure using IPython’s HTML display. Useful for previewing specs hierarchies in notebooks.

Module contents

class svetlanna.visualization.ElementHTML(element_type: str | None, html: str)

Bases: object

Representation of an element in HTML format.

element_type: str | None
html: str
svetlanna.visualization.show_specs(*specsable: Specsable) SpecsWidget

Display a setup structure with interactive specs preview

Returns

SpecsWidget

The widget

svetlanna.visualization.show_stepwise_forward(*specsable: Specsable, input: Tensor, simulation_parameters: SimulationParameters, types_to_plot: tuple[Literal['A', 'I', 'phase', 'Re', 'Im'], ...] = ('I', 'phase')) StepwiseForwardWidget

Display the wavefront propagation through a setup structure using a widget interface. Currently only wavefronts of shape (W, H) are supported.

Parameters

inputtorch.Tensor

The Input wavefront

simulation_parametersSimulationParameters

Simulation parameters

types_to_plottuple[StepwisePlotTypes, …], optional

Field properties to plot, by default (‘I’, ‘phase’)

Returns

StepwiseForwardWidget

The widget

svetlanna.visualization.show_structure(*specsable: Specsable)

Display a setup structure using IPython’s HTML display. Useful for previewing specs hierarchies in notebooks.