scivianna.extension package
Scivianna Extension Module
The extension module provides extensible components that add functionality to visualization panels in Scivianna. Extensions can be attached to panels to provide additional controls, tools, and features.
Files
File |
Description |
|---|---|
|
Package initialization file |
|
Base class for all panel extensions |
|
3D coordinates and axis configuration extension |
|
Coupling-specific controls (time widget, play button) |
|
Widget for selecting displayed fields |
|
File upload and loading interface |
|
Layout management and panel arrangement tools |
|
Tool for setting 1D plots |
|
Serialization and state save/load functionality |
|
AI-powered assistant for visualization help |
|
Icon images for extension UI elements |
Extension System
Extensions are modular components that can be:
Added to any visualization panel
Configured independently
Serialized and restored with panel state
Triggered by user interactions or events
Built-in Extensions
Layout Extension (layout.py)
Manages panel arrangement, frame switching, and interface selection.
Coupling Extension (coupling.py)
Provides time management widget and play/pause controls for coupled simulations.
Field Selector (field_selector.py)
Dropdown widget for selecting which data field to visualize.
File Loader (file_loader.py)
Interface for uploading and loading data files from local or server storage.
Line Selector (line_selector.py)
Interactive tool for setting 1D plots.
Axes Extension (axes.py)
Controls for 3D coordinate display and axis configuration.
Save/Load Extension (save_load_extension.py)
Enables saving panel configurations and restoring them later.
AI Assistant (ai_assistant.py)
Provides AI-powered help and suggestions for visualization tasks.
Creating Custom Extensions
Custom extensions can be created, see the extension.py file for full API.
from scivianna.extension.extension import Extension
class MyCustomExtension(Extension):
def __init__(self, slave, plotter, panel):
super().__init__(slave, plotter, panel)
# Initialize extension
def make_panel(self):
# Return Panel UI for this extension
return pn.Column(...)
def on_mouse_clic(self, location, cell_id):
# Handle mouse click events
pass
def on_file_load(self, file_path, file_label):
# Handle file loading events
pass
Extension Lifecycle
Creation: Extensions are instantiated with slave, plotter, and panel references
Panel Building:
make_panel()returns the UI componentsEvent Registration: Callbacks are registered for mouse events, file loads, etc.
State Management:
to_json()andfrom_json()handle serialization
Submodules
scivianna.extension.ai_assistant module
scivianna.extension.axes module
- class scivianna.extension.axes.Axes(slave: ComputeSlave, plotter: Plotter2D, panel: VisualizationPanel)
Bases:
ExtensionExtension to load files and send them to the slave.
- async async_update_data()
- classmethod from_json(extension: Axes, info_dict: dict) Axes
Restores the extension from its information dict.
- get_uv() Tuple[ndarray, ndarray]
Gets the normal direction vectors from the FloatInput objects.
- Returns:
Vectors U, V
- Return type:
Tuple[np.ndarray, np.ndarray]
- make_gui() Viewable
Returns a panel viewable to display in the extension tab.
- Returns:
Viewable to display in the extension tab
- Return type:
pn.viewable.Viewable
- on_frame_change(u_vector, v_vector)
Function called when the 2D viewport updates its u and v vectors
- Parameters:
u_vector (Tuple[float, float, float]) – Horizontal vector
v_vector (Tuple[float, float, float]) – Vertical vector
- on_range_change(u_bounds, v_bounds, w_value)
Function called when the viewport range was updated.
- Parameters:
y_bounds (Tuple[float, float]) – Bounds along the U axis
v_bounds (Tuple[float, float]) – Bounds along the V axis
w_value (Tuple[float, float]) – Coordinate along the W axis
- to_json() dict
Returns a dictionary with the information required to rebuild the extension.
- Returns:
Information dictionary
- Return type:
dict
- toggle_axis_visibility(*args, **kwargs)
Hides and shows the figure axis
- Parameters:
_ (Any) – Button clic event
- trigger_update(*args, **kwargs)
- update_data()
- update_widgets_visibility()
scivianna.extension.coupling module
- class scivianna.extension.coupling.CouplingExtension(layout: GenericLayout, slave: ComputeSlave, plotter: Plotter2D, panel: VisualizationPanel, **params)
Bases:
Extension,ParameterizedExtension to start coupling simulations.
- add_time_value(value: float)
Adds a new time value to the slide widget
- Parameters:
value (float) – Time value to add
- classmethod from_json(extension: CouplingExtension, info_dict: dict) CouplingExtension
Restores the extension from its information dict. The show_play_button is willingly not saved as it doesn’t make sense to restore it.
- Parameters:
extension (CouplingExtension) – Extension instance to restore
info_dict (dict) – Dictionary containing extension state information
- Returns:
Restored extension
- Return type:
- icon: str
Extension icon, displayed on the tabs list
- make_gui() Viewable
Returns a panel viewable to display in the extension tab.
- Returns:
Viewable to display in the extension tab
- Return type:
pn.viewable.Viewable
- name = 'CouplingExtension'
- panel: VisualizationPanel
Panel to which the extension is attached
- provide_options() dict[str, any]
Provide the option extension option dictionnary
- Returns:
Extension option dictionnary
- Return type:
Dict[str, Any]
- request_recompute(event)
Request a recompute task on all panels, which will trigger the addition of a periodict update on the panels
- Parameters:
event (bool) – If the call is from a button press or release
- show_play_button = False
- slave: ComputeSlave
Slave computing the displayed data
- title: str
Extension title, displayed on top of the extension side bar
- to_json() dict
Returns a dictionary with the information required to rebuild the extension. The show_play_button is willingly not saved as it doesn’t make sense to restore it.
- Returns:
Information dictionary
- Return type:
dict
scivianna.extension.extension module
- class scivianna.extension.extension.Extension(title: str, icon: str, slave: ComputeSlave, plotter: Plotter2D, panel: VisualizationPanel)
Bases:
objectDefinition of a generic scivianna extension. An extension provides a range of tools to customize and interract with the plotting panel and slave.
- description: str = ''
Extension short documentation
- classmethod from_json(extension: Extension, info_dict: dict) Extension
Restores the extension from its information dict.
- icon: str
Extension icon, displayed on the tabs list
- iconsize: str = '6em'
- make_gui() Viewable
Returns a panel viewable to display in the extension tab.
- Returns:
Viewable to display in the extension tab
- Return type:
pn.viewable.Viewable
- on_field_change(field_name: str)
Function called when the user requests a displayed field change
- Parameters:
field_name (str) – Name of the new displayed field
- on_file_load(file_path: str, file_key: str)
Function called when the user requests a change of field on the GUI
- Parameters:
file_path (str) – Path of the loaded file
file_key (str) – Key associated to the loaded file
- on_frame_change(u_vector: Tuple[float, float, float], v_vector: Tuple[float, float, float])
Function called when the 2D viewport updates its u and v vectors
- Parameters:
u_vector (Tuple[float, float, float]) – Horizontal vector
v_vector (Tuple[float, float, float]) – Vertical vector
- on_mouse_clic(screen_location: Tuple[float, float], space_location: Tuple[float, float, float], cell_id: str | int)
Function called when the mouse clics on the plot
- Parameters:
screen_location (Tuple[float, float]) – Mouse location on screen
space_location (Tuple[float, float, float]) – Mouse targeted location in space
cell_id (Union[str, int]) – Currently hovered cell
- on_mouse_move(screen_location: Tuple[float, float], space_location: Tuple[float, float, float], cell_id: str | int)
Function called when the mouse moves on the plot
- Parameters:
screen_location (Tuple[float, float]) – Mouse location on screen
space_location (Tuple[float, float, float]) – Mouse targeted location in space
cell_id (Union[str, int]) – Currently hovered cell
- on_range_change(u_bounds: Tuple[float, float], v_bounds: Tuple[float, float], w_value: float)
Function called when the viewport range was updated.
- Parameters:
y_bounds (Tuple[float, float]) – Bounds along the U axis
v_bounds (Tuple[float, float]) – Bounds along the V axis
w_value (Tuple[float, float]) – Coordinate along the W axis
- on_updated_data(data: Data2D)
Function called when the displayed data is being updated. Extension can edit the data on its way to the plotter.
- Parameters:
data (Data2D) – Data to display
- panel: VisualizationPanel
Panel to which the extension is attached
- provide_options() Dict[str, Any]
Provide a set of options to give to the slave for its update
- Returns:
Options dictionnary
- Return type:
Dict[str, Any]
- slave: ComputeSlave
Slave computing the displayed data
- title: str
Extension title, displayed on top of the extension side bar
- to_json() dict
Returns a dictionary with the information required to rebuild the extension.
- Returns:
Information dictionary
- Return type:
dict
scivianna.extension.field_selector module
- class scivianna.extension.field_selector.FieldSelector(slave: ComputeSlave, plotter: Plotter2D, panel: VisualizationPanel)
Bases:
ExtensionExtension used to select the displayed field and edit its colors.
- classmethod from_json(extension: FieldSelector, info_dict: dict) FieldSelector
Restores the extension from its information dict.
- Parameters:
extension (FieldSelector) – Extension instance to restore
info_dict (dict) – Dictionary containing extension state information
- Returns:
Restored extension
- Return type:
- make_gui() Viewable
Returns a panel viewable to display in the extension tab.
- Returns:
Viewable to display in the extension tab
- Return type:
pn.viewable.Viewable
- on_field_change(field_name: str)
Function called when the user requests a displayed field change
- Parameters:
field_name (str) – Name of the new displayed field
- on_file_load(file_path: str, file_key: str)
Function called when the user requests a change of field on the GUI
- Parameters:
file_path (str) – Path of the loaded file
file_key (str) – Key associated to the loaded file
- on_updated_data(data: Data2D)
Function called when the displayed data is being updated. Extension can edit the data on its way to the plotter.
- Parameters:
data (Data2D) – Data to display
- receive_colormap_change(*args, **kwargs)
Receive a field change from the visualization panel
- to_json() dict
Returns a dictionary with the information required to rebuild the extension.
- Returns:
Information dictionary
- Return type:
dict
- trigger_colormap_change(*args, **kwargs)
Trigger a field change in the visualization panel
- trigger_field_change(*args, **kwargs)
Trigger a field change in the visualization panel
- trigger_update(*args, **kwargs)
Trigger a color map change in the visualization panel
- scivianna.extension.field_selector.set_colors_list(data: Data2D, slave: ComputeSlave, coloring_label: str, color_map: str, center_colormap_on_zero: bool, options: Dict[str, Any])
Sets in a Data2D the list of colors for a field per polygon.
- Parameters:
data (Data2D) – Geometry data
slave (ComputeSlave) – Slave to which request values
coloring_label (str) – Field to color
color_map (str) – Colormap in which select colors
center_colormap_on_zero (bool) – Center the color map on zero
options (Dict[str, Any]) – Plot extra options
- Raises:
NotImplementedError – The field visualisation mode is not implemented.
scivianna.extension.file_loader module
- class scivianna.extension.file_loader.FileLoader(slave: ComputeSlave, plotter: Plotter2D, panel: VisualizationPanel)
Bases:
ExtensionExtension to load files and send them to the slave.
- classmethod from_json(extension: FileLoader, info_dict: dict) FileLoader
Restores the extension from its information dict.
- Parameters:
extension (FileLoader) – Extension instance to restore
info_dict (dict) – Dictionary containing extension state information
- Returns:
Restored extension
- Return type:
- make_gui() Viewable
Returns a panel viewable to display in the extension tab.
- Returns:
Viewable to display in the extension tab
- Return type:
pn.viewable.Viewable
- to_json() dict
Returns a dictionary with the information required to rebuild the extension.
- Returns:
Information dictionary
- Return type:
dict
scivianna.extension.layout module
- class scivianna.extension.layout.LayoutExtension(layout: GenericLayout, slave: ComputeSlave, plotter: Plotter2D, panel: VisualizationPanel)
Bases:
ExtensionExtension to load files and send them to the slave.
- add_widget(widget: Widget)
- change_code_interface(*args, **kwargs)
- change_to_frame(frame_name: str)
- interface_selector
Current edited frame selector
- make_gui() Viewable
Returns a panel viewable to display in the extension tab.
- Returns:
Viewable to display in the extension tab
- Return type:
pn.viewable.Viewable
- set_to_frame(*args, **kwargs)
scivianna.extension.line_selector module
- class scivianna.extension.line_selector.LineSelector(slave: ComputeSlave, plotter: Plotter1D, panel: VisualizationPanel)
Bases:
ExtensionExtension used to select the displayed line in a Panel1D.
- classmethod from_json(extension: LineSelector, info_dict: dict) LineSelector
Restores the extension from its information dict.
- Parameters:
extension (LineSelector) – Extension instance to restore
info_dict (dict) – Dictionary containing extension state information
- Returns:
Restored extension
- Return type:
- make_gui() Viewable
Returns a panel viewable to display in the extension tab.
- Returns:
Viewable to display in the extension tab
- Return type:
pn.viewable.Viewable
- on_file_load(file_path: str, file_key: str)
Function called when the user requests a change of field on the GUI
- Parameters:
file_path (str) – Path of the loaded file
file_key (str) – Key associated to the loaded file
- set_x_scale(*args, **kwargs)
- set_y_scale(*args, **kwargs)
- to_json() dict
Returns a dictionary with the information required to rebuild the extension.
- Returns:
Information dictionary
- Return type:
dict
- trigger_field_change(*args, **kwargs)
Trigger a field change in the visualization panel
scivianna.extension.save_load_extension module
- class scivianna.extension.save_load_extension.SaveLoadExtension(slave: ComputeSlave, plotter: Plotter2D, panel: VisualizationPanel)
Bases:
Extension- load_file(*args, **kwargs)
Load frame from file
- make_gui() Viewable
Returns a panel viewable to display in the extension tab.
- Returns:
Viewable to display in the extension tab
- Return type:
pn.viewable.Viewable
- save_file(*args, **kwargs)
Save frame in file