open_viewmin.filter_tree_plot.filter_tree_plot
#
Define class extending pyvista.Plotter with filter formulas and a filters tree
Module Contents#
Classes#
Extend PyVista Plotter class to organize meshes into a "filter tree" so that |
- class open_viewmin.filter_tree_plot.filter_tree_plot.FilterTreePlot(filenames=None, user_settings=None, theme=None, reader=ovm_utilities.fast_import, dims=None, data_stride=1, **kwargs)#
Bases:
pyvista.Plotter
Extend PyVista Plotter class to organize meshes into a “filter tree” so that updates to any mesh are automatically followed by updates to its child meshes and actors, recursively.
- Parameters:
filenames (list[str], str, or None, optional) – Files to import.
user_settings (dict or None, optional) – Customizations to default plotter settings.
theme (['dark' | 'document' | 'paraview' | None], optional) – PyVista plot theme
reader (callable()) – Function to import and process data files
dims (tuple of ints or None, optional) – System dimensions used if no filenames are given.
data_stride (int, optional) – Spacing between grid sites used if no filenames are given.
kwargs (dict, optional) – Keyword arguments to pyvista.Plotter
- property actor_names#
Names of all actors in filters tree.
- Returns:
List of actor names.
- Return type:
list[str]
- property array_dims#
System array-size dimensions.
- Returns:
(array_Lx, array_Ly, array_Lz)
- Return type:
tuple(int)
- property colorbar_titles#
Get titles of all scalar bars
- Returns:
List of scalar bar titles
- Return type:
list[str]
- property colorbars#
Get list of all existing colorbars (scalar bars) for filter tree actors.
- Return type:
list of VTK scalar bar actors
- property default_mesh#
- property default_mesh_name#
- property dims#
System linear dimensions.
- Returns:
(Lx, Ly, Lz)
- Return type:
tuple(int)
- property filter_tree_roots#
- property fullmesh#
- property mesh_names#
Names of all meshes in filters tree.
- Returns:
List of mesh names.
- Return type:
list[str]
- property non_filter_tree_actor_names#
List actors that don’t belong to open_viewmin’s filter tree.
- Returns:
List of actor names.
- Return type:
list[str]
- property num_frames#
Number of frames in timeseries data.
- property points#
Get array of coordinates belonging to root mesh “fullmesh”
- Returns:
Array of point coordinates.
- Return type:
numpy.ndarray
- __getitem__(mesh_name)#
Mimic dictionary key-value behavior for mesh names and meshes.
- Parameters:
mesh_name (str) –
- Return type:
- __repr__()#
Represent plotter as a textual representation of its filters tree.
- Returns:
Textual representation of filters tree.
- Return type:
str
- __setitem__(mesh_name, filter_formula_lambda)#
Mimic dictionary key-value behavior for mesh names and meshes.
- Parameters:
mesh_name (str) –
filter_formula_lambda (callable()) – Callable that creates filter formula
- Return type:
- _add_checkbox_generic(callback, current_val, size=50, position=None, color_on=None, **kwargs)#
- _add_inplot_slider(callback, mesh_name, current_val=None, min_val=None, max_val=None, title=None, title_height=0.03, style='classic', label_height=0.03, pointa=None, pointb=None, loc='top right', **kwargs)#
- _set_pyvista_plotter_properties()#
Initialization choices for PyVista Plotter
- _visibility_callback(actor_name)#
- add_axes()#
Add x,y,z axes widget.
- add_filter_formula(name=None, **kwargs)#
Add a filter formula to the plotter.
- Parameters:
name (str or None, optional) – Name of new mesh. Pass None to do nothing.
**kwargs – Keyword arguments to open_viewmin.FilterFormula.__init__.
- Returns:
New child mesh created by filter formula, or None if no filter formula was created.
- Return type:
pyvista.dataset or None
- add_isosurface_slider(mesh_name, min_val=None, max_val=None, title=None, title_height=0.02, style='classic', label_height=0.02, pointa=None, pointb=None, loc='top right', **kwargs)#
- add_plane_widget(*args, **kwargs)#
Overload add_plane_widget to take a string argument as name of mesh controlled by widget.
- Parameters:
*args (tuple, optional) –
**kwargs (dict, optional) –
- Return type:
vtkmodules.vtkInteractionWidgets.vtkImplicitPlaneWidget
- add_root_mesh(mesh, mesh_name='fullmesh')#
Add a filter formula as a new root of the filter tree.
- Parameters:
mesh (pyvista.DataSet) – PyVista mesh
mesh_name (str, optional) – Name of the new root mesh.
- Returns:
Name of the new root mesh (possibly altered to avoid overwriting existing mesh names).
- Return type:
str
- add_threshold_slider(mesh_name, min_val=None, max_val=None, title=None, title_height=0.02, style='classic', label_height=0.02, pointa=None, pointb=None, loc='top right', **kwargs)#
- add_visibility_checkbox(actor_name, size=50, position=None, **kwargs)#
- add_widget_checkbox(widget_name, size=50, position=None, background_color='red', **kwargs)#
- add_widget_formula(name=None, **kwargs)#
Add a widget formula to the plotter.
- Parameters:
name (str or None, optional) – Name of new widget. Pass None to do nothing.
kwargs (dict, optional) – Keyword arguments to open_viewmin.WidgetFormula.__init__
- Returns:
The new widget formula, or None if none was created.
- Return type:
open_viewmin.WidgetFormula or None
- assign_file_data_to_frame(file_data, filename, do_load_frame=True)#
Store data from a file as a new frame in the plotter’s timeseries data.
- Parameters:
file_data (numpy.ndarray) –
filename (str) –
do_load_frame (bool, optional) – Whether to view the frame
- copy_all_actors(to_plotter)#
Copy actors to another plotter, such as for displaying in Jupyter notebooks.
- Parameters:
to_plotter (pyvista.Plotter) –
- Return type:
None
- create_fullmesh(dat=None, mesh_name='fullmesh', frame_num=None)#
Create a uniform grid mesh as a root mesh for the filter tree.
- Parameters:
dat (numpy.ndarray, optional) – Data array, with first three columns holding integer coordinates X, Y, Z.
mesh_name (str, optional) – Name of root mesh.
frame_num (int or None, optional) – Frame number for this root mesh. Pass None to append as a new frame.
- Returns:
Frame number and new root mesh.
- Return type:
int, pyvista.dataset
- disable_eye_dome_lighting()#
- disable_shows()#
- do_orbit()#
- enable_eye_dome_lighting()#
- enable_shadows()#
- extract_actors(jupyter_backend='trame')#
Set up a new PyVista plotter with a copy of all this plotter’s actors.
- Parameters:
jupyter_backend (str, optional) – PyVista plotting backend. See https://docs.pyvista.org/api/ plotting/_autosummary/pyvista.themes.DefaultTheme.jupyter_backend .html.
- Returns:
New PyVista plotter containing this plotter’s actors.
- Return type:
pyvista.Plotter
- find_actor_for_scalar_bar(scalar_bar)#
Get the name of the filter tree mesh corresponding to a given scalar bar.
- Parameters:
scalar_bar (VTK scalar bar actor) –
- Returns:
Mesh name
- Return type:
str
- first_frame()#
View first frame in data timeseries.
- get_actor(actor_name)#
Return actor with a given name, if it exists.
- Parameters:
actor_name (str) – Name of actor.
- Returns:
PyVista actor.
- Return type:
vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor
- get_actor_name(actor)#
Given an actor, return its name.
- Parameters:
actor (vtkOpenGLActor) – PyVista actor.
- Returns:
Name of actor.
- Return type:
str
- get_filter_formula(actor_name)#
Get the formula needed to re-create an actor from its parent mesh.
- Parameters:
actor_name (str) – Name of the actor.
- Returns:
Actor recipe.
- Return type:
types.SimpleNamespace
- get_grandparent_mesh_name(actor_or_mesh_name)#
Get the name of the parent of the parent of a given actor or mesh.
- Parameters:
actor_or_mesh_name (str) – Name of actor of mesh
- Returns:
Name of grandparent mesh.
- Return type:
str
- get_mesh(mesh_name)#
Return mesh with a given name, if it exists. For non-mesh actors, return parent mesh.
- Parameters:
mesh_name (str) –
- Returns:
PyVista mesh
- Return type:
pyvista.DataSet
- get_mesh_name(mesh)#
Get the name of a given mesh.
- Parameters:
mesh (pyvista.DataSet) –
- Returns:
name of the mesh
- Return type:
str
- get_widget(widget_name)#
- get_widget_formula(widget_name)#
- hide_all_actors()#
- hide_all_meshes()#
- hide_orbit()#
Remove the mesh visualizing the camera orbit.
- initialize_plotter(**kwargs)#
Run pyvista.Plotter initialization.
Note: This is removed from __init__() for purposes of multiple inheritance of open_viewmin.NematicPlot.
- last_frame()#
View last frame in data timeseries.
- load(filenames, reader=ovm_utilities.fast_import, mpi_group=True, do_load_frame=True)#
Import a file or files.
- Parameters:
filenames (str or list[str]) – Files to load.
reader (callable, optional) – Function to read each file.
mpi_group (bool, optional) – Whether to stitch files together as separate outputs from the same timestep from an MPI run.
do_load_frame (bool, optional) – Whether to view the frame containing the loaded data.
- name_mesh_without_overwriting(mesh_name)#
Modify a proposed new mesh name to be distinct from existing mesh names
- Parameters:
mesh_name (str) – Proposed mesh name
- Returns:
Distinct mesh name to use
- Return type:
str
- name_widget_without_overwriting(widget_name)#
- Modify a proposed new widget name to be distinct from existing
widget names
- Parameters:
widget_name (str) – Proposed widget name
- Returns:
Distinct widget name to use
- Return type:
str
- next_frame()#
View next frame in data timeseries.
- static organize_filenames(filenames, mpi_group=True)#
- play(pause_time=0.5)#
In-GUI animation; will be slow because it loads and renders on the fly
- previous_frame()#
View previous frame in data timeseries.
- probe_at_picked_surface_point(result_name=None)#
- refresh()#
Re-apply all filter formulas to refresh meshes
- remove_mesh_completely(mesh_name, remove_children=True)#
Remove a mesh (filter or actor) from the plotter and from the filters tree.
- Parameters:
mesh_name (str) – Name of mesh to remove.
remove_children (bool, optional) – Whether to recursively remove all meshes descended from this mesh in the filters tree.
- Return type:
None
- rename_mesh(from_name, to_name, do_refresh=True)#
Copy a mesh in the filters tree by copying its recipe.
- Parameters:
from_name (str) – Name of mesh to copy.
to_name (str) – Name of new mesh.
do_refresh (bool, optional) – Whether to create the mesh anew from its filter after renaming.
- Return type:
None
- save_meshes(file_prefix)#
- scalar_fields(mesh_name='fullmesh')#
List names of datasets with one value at each site.
- Parameters:
mesh_name (str or pyvista.DataSet) – PyVista mesh or its name.
- Returns:
List of array names.
- Return type:
list[str]
- set_actor_visibility(actor, visibility: bool)#
Set visibility of a mesh or meshes
- Parameters:
actor (str, sequence of str, VTK actor, or sequence of VTK actors) –
visibility (bool) – Whether mesh(es) are to be visible.
- set_background(*args, **kwargs)#
- set_lights_intensity(intensity)#
Rescale intensity of all lights.
- Parameters:
intensity (float) –
- set_orbit(**kwargs)#
- set_orbit_kwargs(factor=3.0, n_points=20, viewup=None, shift=0.0, step=0.1)#
- show_orbit()#
Add a mesh of points visualizing the camera orbit.
- symmetric_tensor_fields(mesh_name='fullmesh')#
List names of datasets with nine values at each site, whose corresponding 3x3 matrix is everywhere symmetric.
- Parameters:
mesh_name (str or pyvista.DataSet) – PyVista mesh or its name.
- Returns:
List of array names.
- Return type:
list[str]
- tensor_fields(mesh_name='fullmesh')#
List names of datasets with nine values at each site.
- Parameters:
mesh_name (str or pyvista.DataSet) – PyVista mesh or its name.
- Returns:
List of array names.
- Return type:
list[str]
- static toggle_actor_visibility(actor)#
- toggle_eye_dome_lighting()#
- toggle_filter_tree_actor_visibility(actor_name)#
Toggle visibility of a mesh in the filter tree.
- Parameters:
actor_name (str) – Name of mesh
- toggle_floor()#
Toggle visibility of floor (-z) plane.
- toggle_last_colorbar()#
Toggle visibility of most recently modified colorbar.
- toggle_orbit_visibility(toggle=True)#
Toggle visibility of mesh visualizing camera orbit.
- toggle_scalar_bar_visibility(scalar_bar_actor)#
Toggle visibility of a scalar bar
- Parameters:
scalar_bar_actor (VTK scalar bar actor) –
- toggle_shadows()#
- toggle_stereo_render()#
- unique_array_names(mesh=None)#
Get array names for datasets attached to a mesh, deleting duplicates.
- Parameters:
mesh (str or pyvista.DataSet) – PyVista mesh or name of mesh
- Returns:
Mesh along with the list of unique array names.
- Return type:
(pyvista.DataSet, list[str])
- update_actor(actor_name, **kwargs)#
Update a filter formula’s mesh visualization options.
Shorthand for `self.get_filter_formula(ellipsoid_mesh_name).set()
- Parameters:
actor_name (str) – Name of filter formula
**kwargs – Keyword arguments to `open_viewmin.FilterFormula.set
- update_filter(mesh_name, update_actor=False, **kwargs)#
Update a filter formula.
Shorthand for self.get_filter_formula(parent_mesh_name).update().
- Parameters:
mesh_name (str) – Name of filter formula
update_actor (bool, optional) – Whether to update an actor immediately after updating its mesh.
kwargs (dict, optional) – Keyword arguments to open_viewmin.FilterFormula.update
- vector_fields(mesh='fullmesh')#
List names of datasets with three values at each site.
- Parameters:
mesh (str or pyvista.DataSet) – PyVista mesh or its name.
- Returns:
List of array names.
- Return type:
list[str]
- view_frame(frame_num=0, keep_camera_dist=True)#
Use one of the (already imported) sets of data as the source for all PyVista meshes, e.g. for generating a frame of an animation from timeseries data.
- Parameters:
frame_num (int, optional) – Index in self.data of the timeframe to display.
keep_camera_dist (bool, optional) – Whether to force camera to maintain position after frame load.