Skip to content

visualtools

CycleBuilder

Builds pyvista PolyData from cycle DataFrame and updates data based on timestep.

Attributes:

Name Type Description
coords ndarray

Coordinates of the scalar field.

cycles DataFrame

DataFrame containing cycle data.

scalar_column str

Name of the column containing scalar data.

pv_object PolyData

Built pyvista object.

coords = coords instance-attribute

cycles = cycles instance-attribute

pv_object = pv.PolyData() instance-attribute

scalar_column = scalar_column instance-attribute

__init__(coords, cycles, scalar_column=None)

Initialize a CycleBuilder with coordinates and cycle data.

Parameters:

Name Type Description Default
coords ndarray

Array of vertex coordinates with shape (N, 3).

required
cycles DataFrame

DataFrame containing cycle data for each vertex.

required
scalar_column str | None

Name of the column in cycles to use as scalar values. If None, no scalar column is assigned. Defaults to None.

None

Attributes:

Name Type Description
coords ndarray

Stored vertex coordinates.

cycles DataFrame

Stored cycle data.

scalar_column str | None

Column used for scalar values, if provided.

pv_object PolyData | None

PyVista PolyData object, initially None.

build()

Build pyvista object from cycle data.

Returns:

Type Description
PolyData

pv.PolyData: Built pyvista object.

update(timestep, prev_time=-1.0)

Update pyvista object based on timestep.

Parameters:

Name Type Description Default
timestep int

Timestep to update the object for.

required
prev_time float

Previous timestep value for updates.

-1.0

Returns:

Type Description
PolyData

pv.PolyData: Updated pyvista object.

EpmSlider

Bases: Slider

Slider widget for visualizing phase mapping and cycles in EPM data.

This widget allows interactive visualization of phasefields, critical points (CBs), forks, and wavefronts.

epm = epm instance-attribute

__init__(epm)

Initialize the EpmSlider with optional visualization layers.

Parameters:

Name Type Description Default
epm ExtendedPhaseMapping

ExtendedPhaseMapping object containing phasefield and cycle data.

required

add_critical_cycles(name='CBs', scalar_column='top_charge', cmap='bwr', line_width=7.5, clim=(-1, 1), **kwargs)

Add critical cycles (CBs) to the slider visualization.

add_noncritical_cycles(name='forks', color='white', line_width=7.5, **kwargs)

Add non-critical cycles (forks) to the slider visualization.

add_phasefield(name='phasefield', interpolate_before_map=False, clim=(-np.pi, np.pi), cmap='twilight', **kwargs)

Add the phasefield scalar field to the slider.

add_points(points, scalars, label, position, name=None, **kwargs)

Add a point cloud with a checkbox toggle.

add_wavefronts(name='wavefronts', color='green', line_width=7.5, **kwargs)

Add wavefront cycles to the slider visualization.

toggle(name, flag)

Toggle actor visibility.

Plot

General class for plotting.

Attributes:

Name Type Description
plotter Plotter

PyVista plotter object.

builders dict

Dictionary of object builders.

visible_objects list

List of visible objects.

actors dict

Dictionary of pyvista actors.

actors = {} instance-attribute

builders = {} instance-attribute

plotter = pv.Plotter() instance-attribute

visible_objects = [] instance-attribute

__init__()

Initialize the Plot object.

add_data(name, builder, **kwargs)

Add a new data object to the plot, along with its builder and configuration.

Parameters:

Name Type Description Default
name str

Name of the data object.

required
builder ObjectBuilder

Builder instance for the data object.

required
**kwargs Any

Optional keyword arguments for the mesh.

{}

add_opacity_slider()

Add an opacity slider widget to the plotter for adjusting mesh opacity.

show()

Show the Plot window.

update_opacity(value)

Update the opacity of the phasefield mesh.

Parameters:

Name Type Description Default
value float

Opacity to update the phasefield mesh to.

required

ScalarFieldBuilder

Builds pyvista PolyData from scalar field data and updates based on timestep.

Attributes:

Name Type Description
points ndarray

Coordinates of the scalar field.

faces array

Cells of the scalar field.

scalars ndarray

Scalar field data.

pv_object PolyData

Built pyvista object.

faces = faces instance-attribute

points = points instance-attribute

pv_object: pv.PolyData | None = None instance-attribute

scalars = scalars instance-attribute

scalars_name = scalars_name instance-attribute

time_axis = time_axis instance-attribute

__init__(points, faces, scalars, scalars_name='scalars', time_axis=None)

Initialize a mesh with coordinates, cells, and scalar values.

Parameters:

Name Type Description Default
points ndarray

Array of vertex coordinates with shape (N, 3).

required
faces ndarray

Array defining the mesh connectivity.

required
scalars ndarray

Array of scalar values associated with vertices.

required
scalars_name str

Name of scalars.

'scalars'
time_axis ndarray

Array indicating the timesteps of the scalars.

None

build()

Build pyvista object from scalar field data.

Returns:

Type Description
PolyData

pv.PolyData: Built pyvista object.

update(timestep, prev_time=-1.0)

Update pyvista object based on timestep.

Parameters:

Name Type Description Default
timestep int

Timestep to update the object for.

required
prev_time float

Previous timestep value for updates. Defaults to -1.0.

-1.0

Returns:

Type Description
PolyData

pv.PolyData: Updated pyvista object.

Slider

Bases: Plot

Slider class for visualizing data over time and updating opacity.

Attributes:

Name Type Description
data dict

Dictionary of data to visualize.

builders dict

Dictionary of object builders.

visible_objects list

List of visible objects.

actors dict

Dictionary of pyvista actors.

plotter Plotter

PyVista plotter object.

current_time_index int

Current time index.

time_axis ndarray | None

Array of time values for the slider.

slider_widget

The PyVista slider widget instance.

current_time_index = 0 instance-attribute

slider_widget = None instance-attribute

time_axis = time_axis instance-attribute

__init__(time_axis)

Initialize the Slider.

Parameters:

Name Type Description Default
time_axis ndarray | None

Array of time values for the slider. If None, must be set before using time-dependent features.

required

add_time_slider()

Add a time slider widget to the plotter for time navigation.

key_press_callback(obj, event)

Handle key press events for time navigation in the slider.

Parameters:

Name Type Description Default
obj vtkObject

VTK object triggering the event.

required
event vtkEvent

VTK event.

required

show()

Show the slider window, initialize objects, sliders, and event handlers.

update_objects(time, prev_time=-1.0)

Update the objects in the slider for a given timestep.

Parameters:

Name Type Description Default
prev_time float

Previous timestep to update the objects for.

-1.0
time float

Current timestep to update the objects for.

required

update_time(value)

Update the slider to a specific time value.

Parameters:

Name Type Description Default
value float

Time to update the slider to.

required

update_time_by_index(index)

Update the slider to a specific time index.

Parameters:

Name Type Description Default
index int

Index of the time to update the slider to.

required