open_viewmin#
open-ViewMin project top-level module
Subpackages#
Submodules#
Classes#
Class for reusable PyVista filters. |
|
PyVista Plotter with meshes organized into a "filter tree". |
|
Implement some PyVista functionality, with filter trees, in the PyVistaQt |
|
Plotter class for nematic liquid crystals visualization, |
|
Plotter class for nematic liquid crystals visualization, with the |
|
Class for creating re-usable widgets |
Package Contents#
- class FilterFormula(plotter, name=None, parent_mesh_name=None, filter_callable=None, filter_kwargs=None, mesh_kwargs=None, random=None, has_actor=True, in_place=False, ovm_info=None, widget_name=None, apply_upon_creation=True, children=None, colorbar=None, **extra_filter_kwargs)#
Class for reusable PyVista filters.
- Parameters:
plotter (
FilterTreePlot
) – Parent plottername (str or None) – Name of filter formula and its mesh. Pass None to default to plotter’s default mesh name.
parent_mesh_name (str or None) – Name of parent mesh. Pass None to default to plotter’s default mesh name.
filter_callable (callable(), str, or None) – Function of parent mesh that returns a callable, which when called applies a filter to (re-)create a child mesh. Pass None to use an “identity filter”, making the parent its own child.
filter_kwargs (dict or None, optional) – Dictionary of keyword arguments supplied to the function returned by filter_callable. None is equivalent to dict().
mesh_kwargs (dict or None, optional) – Dictionary of keyword arguments to pyvista.Plotter.add_mesh for customization of mesh visualization. None is equivalent to dict().
random (bool or None, optional) – Whether to use random sampling, if applicable.
has_actor (bool, optional) – Whether to create an actor visualizing the mesh.
in_place (bool, optional) – Whether to modify a mesh in-place rather than creating a child mesh.
ovm_info (dict or None) – Dictionary of keyword arguments for ad-hoc purposes. None is equivalent to dict().
widget_name (str or None) – Name of widget, if applicable, that creates this filter formula
apply_upon_creation (bool, optional) – Whether to apply the filter formula, creating its mesh, immediately upon creating the filter formula.
children (list of str, or None, optional) – List of names of child meshes. None is equivalent to [].
colorbar (VTK scalar bar actor or None, optional) – Existing colorbar actor, if applicable.
**extra_filter_kwargs (dict, optional) – Extra keyword arguments to append to filter_kwargs (for convenience).
- __getitem__(key)#
Access mesh’s datasets in dictionary-like manner
- __repr__()#
Print keyword arguments to
FilterFormula
and their current values- Return type:
str
- __setitem__(key, set_to)#
Set mesh’s datasets in dictionary-like manner
- _inherit(filter_kwarg)#
If this FilterFormula has no value currently assigned to filter_kwarg, try to inherit the value from an ancestor FilterFormula
- Parameters:
filter_kwarg (str)
- Return type:
inherited_filter_keyword_argument
- _interpret_color_or_scalars(mesh_kwargs)#
Check if mesh coloring should be updated as a solid color or color array.
- Parameters:
mesh_kwargs (dict) – Mesh visualizing settings
- Returns:
Whether to update solid color, whether to update color array, and mesh visualizing settings dictionary
- Return type:
(bool, bool, dict)
- _remove_bad_mesh_kwargs(mesh_kwargs)#
Remove unexpected keyword arguments to pyvista.Plotter.add_mesh
- Parameters:
mesh_kwargs (dict) – Mesh visualization settings
- Returns:
Mesh visualization settings with bad keyword arguments removed
- Return type:
dict
- _update_actor_color_array()#
Visualize mesh with color array
- _update_actor_solid_color()#
Visualize mesh with solid color
- add_calculation(name, calc_callable)#
Create a data array for this mesh that is recalculated whenever the mesh is updated. The function accomplishing this is added to the
FilterFormula
’sdo_after_update
list.Example: If we have a
NematicPlot
p, with a glyphs filter_formula called “director”, the following creates a scalar data array holding the normal component of the “director” orientation field.>>> p["director"].add_calculation("normal_component", lambda a: np.inner(a.orientations, a.normal))
Equivalently, you can assign calc_callable as the value corresponding to key name:
>>> p["director"]["normal_component"] = lambda a: np.inner(a.orientations, a.normal)
- Parameters:
name (str)
calc_callable (callable()) – Function mapping filter_formula to calculated data array.
- add_filter(filter_callable, **kwargs)#
Create a callable that returns a filter formula whose parent mesh is this formula’s child mesh
Used for dictionary-style assignment of new filter formula to plotter.
- Parameters:
filter_callable (callable()) – Function mapping new mesh name to new filter formula
kwargs (dict, optional) – Keyword arguments to FilterFormula
- Return type:
callable()
- add_glyphs(**kwargs)#
Create a glyphs child filter formula
- Parameters:
kwargs (dict, optional)
- Returns:
Function of new mesh name; adds glyphs filter formula
- Return type:
callable()
- color_by_active_scalars(categories=None)#
Set mesh’s color array to most recently used scalar dataset
- Parameters:
categories (bool, optional)
- get_auto_color()#
Get next color in plotter’s color sequence
- Returns:
color rgb values
- Return type:
tuple(float)
- get_centroids(num_centroids=10, ref_pt_idx=0, mesh_name_to_probe=None)#
Add centroids filter formula
Child filter formula probes a given mesh at centroids calculated from the points of this filter formula’s mesh.
- Parameters:
num_centroids (int, optional) – Number of centroids
ref_pt_idx (int, optional) – Index of starting point for calculating centroids
mesh_name_to_probe (str or None, optional) – Name of mesh to probe (source of datasets). Pass None to default to self.plotter.default_mesh_name.
- Returns:
Name of sampled (child) mesh
- Return type:
str
- get_circuits(mesh_to_probe_name=None, normals_name=None, radius=3, n_samples=100, use_ints=False)#
Add circuits filter formula
- Parameters:
mesh_to_probe_name (str) – Name of mesh to probe
normals_name (str or None, optional) – Name of vectors dataset defined on mesh_of_circuit_centers to be used as normal directions to circuits. Pass None to default to name of active_vectors dataset of parent mesh.
radius (float, optional) – Radius of each circuit
n_samples (int, optional) – Number of circuits
use_ints (bool, optional) – Whether to round coordinates of circuit points to integers
- Returns:
Name of sampled (child) mesh, or None if no child mesh was created.
- Return type:
str or None
- get_eigenvec(tensors_name=None, evec_idx=-1, new_dataset_name=None)#
Calculate an eigenvector of symmetric second-rank tensor dataset
- Parameters:
tensors_name (str or None, optional) – Name of symmetric rank-2 tensors dataset. Pass None to default to name of most recently created symmetric rank-2 tensors dataset.
evec_idx (int, optional) – Index of eigenvector to take, ordered by ascending eigenvalues
new_dataset_name (str or None) – Name of vector dataset storing eigenvector. Pass None to default to “_eigenvec” appended to tensors_name.
- Return type:
numpy.ndarray
- give_colorbar_unique_title()#
Check if color bar lacks a title, and assign one if so
- Returns:
Color bar title
- Return type:
str
- static handle_filter_or_numpy(filter_result, parent_mesh, filter_name)#
Properly handle filter results that may be mesh or array
If the filter result is an array, assigns the filter result as a new dataset on a copy of the parent mesh.
- Parameters:
filter_result (pyvista.dataset or numpy.ndarray) – Result of filter
parent_mesh (pyvista.dataset) – Parent mesh
filter_name (str) – Name for new dataset in case filter_result is an array.
- Returns:
New child mesh
- Return type:
pyvista.dataset
- hide()#
Make mesh’s actor invisible
- static identity_callable(mesh)#
Get a filter formula callable that simply copies the parent mesh
- Parameters:
mesh (pyvista.dataset)
- Return type:
callable()
- make_sure_parent_knows_about_me()#
Make sure that this filter formula’s name is in the parent mesh filter formula’s list of children
- remove_child_relationship_to_all_parents()#
Cause any meshes claiming this mesh as a child to forget that relationship, a prerequisite for deleting this mesh.
- remove_colorbar()#
Remove color bar for this filter formula’s mesh
- set(**mesh_kwargs)#
Shorthand for
update_actor()
- Parameters:
**mesh_kwargs – New or modified keyword arguments to pyvista.Plotter.add_mesh
- Returns:
Updated actor
- Return type:
vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor
- set_glyph_shape(new_shape, **geom_args)#
Modify shape of glyphs
- Parameters:
new_shape (str) – Shape name
geom_args (dict, optional) – Keyword arguments for shape
- set_glyphs_scale(new_scale)#
Set global scale factor for glyphs
- Parameters:
new_scale (float) – New scale factor
- set_glyphs_stride(new_stride)#
Set spacing between glyphs
- Parameters:
new_stride (int) – New spacing
- static string_to_filter(filter_string)#
Convert filter name to callable
Convert string name of PyVista filter to a callable that produces that filter. If the argument is not a string, return the argument (for cases where the filter callable is passed rather than its string name).
- Parameters:
filter_string (str or object)
- Returns:
callable() – Function mapping existing mesh to a new mesh via the named filter.
object – If filter_string is not a string, returns filter_string
- update(update_actor=True, ovm_info=None, **filter_kwargs)#
Update a mesh by calling its creator filter
- Parameters:
update_actor (bool, optional) – Whether to update the actor visualizing the mesh
ovm_info (dict or None, optional) – New or modified items for mesh settings dictionary
**filter_kwargs – New or modified keyword arguments for filter callable
- Returns:
Updated child mesh
- Return type:
pyvista.dataset
- update_actor(is_new=False, **mesh_kwargs)#
Update or create mesh visualizing actor
- Parameters:
is_new (bool, optional) – Whether actor has just been created (to avoid duplicate warnings)
mesh_kwargs (dict, optional) – New or modified keyword arguments to pyvista.Plotter.add_mesh
- Returns:
Updated actor
- Return type:
vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor
- update_children()#
Update child meshes
Calls update function of each filter formula named in self.children
- _allowed_args_to_add_mesh#
- property array_names#
- Get mesh's dataset names
- Return type:
list[str]
- colorbar#
- do_after_update = []#
- filter_kwargs#
- has_actor#
- in_place#
- property is_filter_tree_root#
- Check whether mesh is a root of the filter tree
- Return type:
bool
- property is_glyphs#
- Check whether mesh is glyphs
- Return type:
bool
- property mesh#
- Get child mesh
- Return type:
pyvista.dataset
- mesh_kwargs#
- property normal#
- Normal vector to plane
- Return type:
numpy.ndarray
- property orientations#
- Get orientations data array for glyphs; `None` for non-glyphs
- property origin#
- Origin of plane
- Return type:
numpy.ndarray
- ovm_info#
- property parent_filter_formula#
- Get parent mesh's filter formula
- Return type:
- property parent_mesh#
- Get parent mesh
- Return type:
pyvista.dataset
- parent_mesh_name#
- plotter#
- property points#
- Get mesh's points
- Return type:
numpy.ndarray
- property random#
- Check whether random sampling has been selected
- Return type:
bool
- property root_ancestor#
- root (possibly self) of filter tree from which this filter formula
- property descends#
- widget_name#
- class FilterTreePlot(filenames=None, user_settings=None, theme=None, reader=ovm_utilities.fast_import, dims=None, data_stride=1, **kwargs)#
Bases:
pyvista.Plotter
PyVista Plotter with meshes organized into a “filter tree”.
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()
- __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 checkbox
- Parameters:
callback (callable)
current_val (bool)
size (int)
position (tuple(float), optional)
color_on (pyvista.plotting.colors.Color, optional)
kwargs – keyword arguments to :meth:pyvista.Plotter.add_checkbox_button_widget
- _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)#
- Parameters:
callback (callable)
mesh_name (str)
current_val (float, optional)
min_val (float, optional)
max_val (float, optional)
title (str, optional)
title_height (float, optional)
style (str, optional) – Options in pyvista.global_theme.slider_styles
label_height (float)
pointa (tuple(float), optional)
pointb (tuple(float), optional)
loc (str, optional) – Slider location by keyword; options are “top left”, “bottom left”, “bottom right”. If any other string or None is given, slider is positioned in top right.
kwargs – keyword arguments to
pyvista.Plotter.add_slider_widget()
- Return type:
vtk.vtkSliderWidget
- _set_pyvista_plotter_properties()#
Initialization choices for PyVista Plotter
- _visibility_callback(actor_name)#
- actor_names()#
Names of all actors in filters tree.
- Returns:
List of actor names.
- Return type:
list[str]
- 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
FilterFormula
- 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 isosurface slider
- Parameters:
mesh_name (str)
min_val (float, optional)
max_val (float, optional)
title (str, optional)
title_height (float)
style (str, optional) – Options in pyvista.global_theme.slider_styles
label_height (float, optional)
pointa (tuple(float), optional)
pointb (tuple(float), optional)
loc (str, optional) – Slider location by keyword; options are “top left”, “bottom left”, “bottom right”. If any other string or None is given, slider is positioned in top right.
kwargs – keyword arguments to
_add_inplot_slider()
- Return type:
vtk.vtkSliderWidget
- 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 slider for threshold
- Parameters:
mesh_name (str)
min_val (float, optional)
max_val (float, optional)
title (str, optional)
title_height (float, optional)
style (str, optional) – Options in pyvista.global_theme.slider_styles
label_height (float, optional)
pointa (tuple(float), optional)
pointb (tuple(float), optional)
loc (str, optional) – Slider location by keyword; options are “top left”, “bottom left”, “bottom right”. If any other string or None is given, slider is positioned in top right.
kwargs – keyword arguments to
_add_inplot_slider()
- add_visibility_checkbox(actor_name, size=50, position=None, **kwargs)#
Add checkbox to toggle an actor’s visibility
- Parameters:
actor_name (str)
size (int)
position (tuple(float), optional)
kwargs – Keyword arguments to
_add_checkbox_generic()
- add_widget_checkbox(widget_name, size=50, position=None, background_color='red', **kwargs)#
Add checkbox that activates/deactivates a widget
- Parameters:
widget_name (str)
size (int)
position (tuple(float), optional)
background_color (str)
kwargs – Keyword arguments to
_add_checkbox_generic()
- 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
WidgetFormula
- Returns:
The new widget formula, or None if none was created.
- Return type:
WidgetFormula
or None
- array_dims()#
System array-size dimensions.
- Returns:
(array_Lx, array_Ly, array_Lz)
- Return type:
tuple(int)
- 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 (np.ndarray)
filename (str)
do_load_frame (bool, optional) – Whether to view the frame
- colorbar_titles()#
Get titles of all scalar bars
- Returns:
List of scalar bar titles
- Return type:
list[str]
- colorbars()#
Get list of all existing colorbars (scalar bars) for filter tree actors.
- Return type:
list of VTK scalar bar actors
- 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 (np.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
- dims()#
System linear dimensions.
- Returns:
(Lx, Ly, Lz)
- Return type:
tuple(int)
- disable_eye_dome_lighting()#
- disable_shadows()#
- do_orbit()#
Move camera along orbit path
Removes actor named “orbit”, if it exists, before starting the motion.
- 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/version/stable/user-guide/themes.
- Returns:
New PyVista Plotter containing this Plotter’s actors.
- Return type:
pyvista.Plotter
- filter_tree_roots()#
Names of meshes whose generating
FilterFormula
‘s are roots of the filter tree- Return type:
list[str]
- 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_points()#
Get array of coordinates belonging to root mesh “fullmesh”
- Returns:
Array of point coordinates.
- Return type:
np.ndarray
- get_widget(widget_name)#
Get widget by name
- Parameters:
widget_name (str)
- Return type:
vtkmodules.vtkInteractionWidgets.vtk3DWidget
- get_widget_formula(widget_name)#
Get
WidgetFormula
by name- Parameters:
widget_name (str)
- Return type:
- hide_all_actors()#
Make all actors invisible
- hide_all_meshes()#
Make actors of all meshes invisible
- 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
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.
- mesh_names()#
Names of all meshes in filters tree.
- Returns:
List of mesh names.
- Return type:
list[str]
- 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.
- 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]
- num_frames()#
Number of frames in timeseries data.
- static organize_filenames(filenames, mpi_group=True)#
For data to be imported, sort filenames alphabetically after grouping MPI files appropriately.
- Parameters:
filenames (list[str] | str)
mpi_group (bool)
- Return type:
list[str]
- 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)#
Create a FilterFormula with the sample filter probing a picked mesh at a picked point
- Parameters:
result_name (str, optional) – Name of new FilterFormula; defaults to “_probed” appended to name of picked mesh
- Returns:
result_name – Name of new FilterFormula
- Return type:
str
- 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)#
Save all meshes to .vtk files
- Parameters:
file_prefix (str) – File location will be [mesh_name].vtk appended to this.
- 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 plotter’s background color(s)
If called with no arguments, retrieves color from FilterTreePlot.settings[“background_color”], defaulting to black. Otherwise, args and kwargs are sent to pyvista.Plotter.set_background.
- Parameters:
args
kwargs
- set_lights_intensity(intensity)#
Rescale intensity of all lights.
- Parameters:
intensity (float)
- set_orbit(**kwargs)#
Set orbit properties and get its camera locations
- Parameters:
kwargs – keyword arguments to set_orbit_kwargs()
- Returns:
Orbit points
- Return type:
pyvista.core.pointset.PolyData
- set_orbit_kwargs(factor=3.0, n_points=20, viewup=None, shift=0.0, step=0.1)#
Modify camera orbit
- Parameters:
factor (float) – orbit radius relative to data extent
n_points (int) – number of points subdividing circle at which to generate images
viewup (iterable[float], optional) – orientation vector for camera’s up direction
shift (float) – translation of camera location along viewup
step (float) – orbit speed in seconds per frame
- Returns:
vis – Visibility of orbit points actor
- Return type:
bool
- 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 visibility of an actor
- Parameters:
actor (VTK actor)
- Returns:
new_visibility
- Return type:
bool
- toggle_eye_dome_lighting()#
Switch eye dome lighting on/off
- 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()#
Turn shadow rendering on/off
- toggle_stereo_render()#
Turn anaglyph stereo 3D effect on/off
- 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.filter_tree_plot.filter_formulas.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.filter_tree_plot.filter_formulas.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.
- actors_color_cycle#
- array_dims_defined = False#
- axes = None#
- data = []#
- data_stride#
- property default_mesh#
- default_mesh_name#
- filenames = []#
- filter_formulas#
- frame_data = []#
- frame_num#
- property fullmesh#
- geometric_objects#
- is_enabled_eye_dome_lighting#
- meshes_dict#
- oVM_theme#
- off_screen#
- orbit_kwargs#
- orbit_path#
- settings#
- title#
- widget_formulas#
- widgets#
- class FilterTreePlotQt(filenames=None, user_settings=None, theme=None, reader=ovm_utilities.fast_import, **kwargs)#
Bases:
open_viewmin.filter_tree_plot.filter_tree_plot.FilterTreePlot
,pyvistaqt.BackgroundPlotter
Implement some PyVista functionality, with filter trees, in the PyVistaQt GUI
- 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
kwargs (dict, optional) – Keyword arguments to open_viewmin.FilterTreePlot
- _assign_keypress_events()#
Assign actions to keyboard keys.
Get a menu with a given title
- Parameters:
parent (PyQt5.QtWidgets.QMenuBar) – Menu bar to search
title (str) – Title of menu
- Returns:
Menu
- Return type:
PyQt5.QtWidgets.QMenu
- _init_procedures_after_data_import()#
Initialization steps that can be carried out only after some data is imported
- add_filter_formula(name=None, **kwargs)#
- add_slice_with_controls(scalars_name, mesh_to_slice_name='fullmesh')#
Create a callable that adds a slice filter formula controlled by sliders and buttons in the controls area.
- Parameters:
scalars_name (str or None) – Name of scalar dataset to use for coloring the slice. Pass None to use a solid color.
mesh_to_slice_name (str, optional) – Name of parent mesh to slice
- Return type:
callable()
- add_widget_formula(name=None, **kwargs)#
- customize_controls_dock()#
Modify settings of controls area
- enable_pyvista_3_lights(only_active=False)#
- enable_pyvista_lightkit(only_active=False)#
- initialize_plotter(**kwargs)#
Override parent class’s plotter initialization to use pyvistaqt.BackgroundPlotter instead of pyvista.Plotter
- Parameters:
kwargs (dict, optional) – Keyword arguments to pyvistaqt.BackgroundPlotter
- load(filenames, **kwargs)#
- open_files_dialog(sort=True)#
Launch GUI widget for selecting files to import
- Parameters:
sort (bool, optional) – Whether to sort filenames by timestamp
- refresh()#
- remove_actor_completely(actor_name)#
- remove_mesh_completely(mesh_name, remove_children=True)#
- rename_mesh(from_name, to_name, do_refresh=False)#
- save_html(filename=None)#
Export plotter scene as interactive html widget
- Parameters:
filename (str or None) – Filename to write to. Pass None to launch GUI file selector.
- save_mesh(mesh_name, mesh_filename=None)#
Export a mesh.
Note that the allowed file types depend on the type of mesh.
- Parameters:
mesh_name (str) – Mesh name
mesh_filename (str or None) – File to write to. Pass None to launch GUI file selector.
- save_meshes_launch_dialog(file_prefix=None)#
- set_actor_visibility(actor, visibility)#
- set_orbit_dlg(**kwargs)#
- show_editor()#
Show editor widget controlling actors’ visibility
- update_actor(actor_name, **kwargs)#
- update_filter(mesh_name, update_actor=False, **kwargs)#
- update_filters_tree()#
- update_frame_spinbox()#
Update the spinbox controlling the frame
- view_frame(frame_num=0, **kwargs)#
Use one of the imported data files as the source for all datasets
- property actor_control_toolbars#
- Get toolbars controlling individual actors
- Returns:
Dictionary of toolbars
- Return type:
dict
- controls_dock_scroll_area#
- controls_dock_widget#
- controls_dock_window#
- dock_widgets#
- filters_tree_widget_items#
- finished_setup = False#
- frame_num = 0#
- settings_Qt_dict#
- the_refresh_toolbar#
- toolbars#
- window_size#
- class NematicPlot(filenames=None, q0=0.0, user_settings=None, data_format='open-Qmin', sep='\t', reader=None, theme=None, dims=None, data_stride=1, **kwargs)#
Bases:
open_viewmin.filter_tree_plot_Qt.filter_tree_plot_Qt.FilterTreePlotQt
,open_viewmin.nematic.nematic_plot.nematic_plot_no_qt.NematicPlotNoQt
Plotter class for nematic liquid crystals visualization, with the filters tree, in a Qt window.
- Parameters:
filenames (list[str], str, or None, optional) – Files to import.
q0 (float, optional) – Chiral wavenumber for cholesteric (chiral nematic) ground state, used in free energy calculations.
user_settings (dict or None, optional) – Customizations to default plotter settings.
data_format (['open-Qmin' | 'Qmin' | 'director'], optional) – Formatting style of data text files to import; used only if parameter reader has value None.
sep (str, optional) – Column delimiter for imported text file(s)
reader (callable() or None, optional) – Function for reading data from text files; set to None to use the data_format (and, optionally, sep) parameters to determine data import behavior.
theme (['dark' | 'document' | 'paraview' | None], optional) – PyVista plot theme
dims (tuple(int) or None) – System size; used only if filenames is None.
data_stride (int, optional) – Data spacing; used only if filenames is None.
kwargs (dict, optional) – Keyword arguments to
FilterTreePlot
- auto_setup(notebook=False)#
Add nematic-specific items to the “Calculate” menu
- setup_defects()#
Automatic setup for defects visualization
- setup_director()#
Automatic setup for director visualization
- show_jones(**kwargs)#
Display optical transmission, calculated from Jones matrices, on three planes.
- Parameters:
kwargs (dict, optional)
- Returns:
callback that refreshes Jones planes by re-applying the control slider widgets
- Return type:
callable()
- reader#
- class NematicPlotNoQt(filenames=None, q0=0.0, user_settings=None, data_format='open-Qmin', sep='\t', reader=None, theme=None, off_screen=False, notebook=True, **kwargs)#
Bases:
open_viewmin.filter_tree_plot.filter_tree_plot.FilterTreePlot
- Plotter class for nematic liquid crystals visualization, with the
filters tree but without Qt.
- Parameters:
filenames (list[str], str, or None, optional) – Files to import.
q0 (float, optional) – Chiral wavenumber for cholesteric (chiral nematic) ground state, used in free energy calculations.
user_settings (dict or None, optional) – Customizations to default plotter settings.
data_format (['open-Qmin' | 'Qmin' | 'director'], optional) – Formatting style of data text files to import; used only if parameter reader has value None.
sep (str, optional) – Column delimiter for imported text file(s)
reader (callable() or None, optional) – Function for reading data from text files; set to None to use the data_format (and, optionally, sep) parameters to determine data import behavior.
theme ([‘dark’ | ‘document’ | ‘paraview’ | None], optional) – PyVista plot theme
off_screen (bool, optional) – Whether to render off-screen
notebook (bool, optional) – Whether to display inside of a Jupyter notebook
**kwargs – Keyword arguments to
FilterTreePlot
- static Q33_from_Q5(q5)#
Convert 5-component Q-tensor information to 3x3 matrix
- static Q_from_n(director_data)#
Create Q-tensor array from director data assuming S_0=1
- _legacy_qmin_import(qtensor_filename)#
Reader for output from older Qmin (a.k.a. nematicvXX) code.
Note that while only the “Qtensor_…” files are supplied directly, this routine expects the associated “Qmatrix_…” files to be in the same directory.
- Parameters:
qtensor_filename (str) – Filenames of “Qtensor_…”
- Returns:
Imported data
- Return type:
list[np.ndarray]
- _pre_init(q0, data_format, reader, sep)#
Portion of initialization to run before open_viewmin.FilterTreePlot.__init__()
- Parameters:
q0 (float) – Chiral wavenumber
data_format (['open-Qmin' | 'Qmin' | 'director'], optional) – Formatting style of data text files to import; used only if parameter reader has value None.
reader (callable() or None, optional) – Function for reading data from text files; set to None to use the data_format (and, optionally, sep) parameters to determine data import behavior.
sep (str, optional) – Column delimiter for imported text file(s)
- Returns:
Reader
- Return type:
callable()
- add_circuits_around_points(points_mesh_name, normals_name, radius=3, n_samples=16, use_ints=False)#
Create small, closed-loop meshes around a set of points, for use in plotting director winding near disclinations.
- Parameters:
points_mesh_name (str)
normals_name (str)
radius (float)
n_samples (int)
use_ints (bool)
- Return type:
- analyze_disclination_at_picked_point(**kwargs)#
Show director winding character at a picked point on a disclination
- Parameters:
**kwargs (dict, optional) – Keyword arguments to
analyze_disclinations_at_points()
- analyze_disclinations(defects_mesh_name='defects', n_centroids=50, tangents_glyph_name=None, **kwargs)#
For several “centroid” points along disclination lines, show the director winding character.
- Parameters:
defects_mesh_name (str)
n_centroids (int)
tangents_glyph_name (str, optional)
**kwargs (dict, optional) – Keyword arguments to
analyze_disclinations_at_points()
- analyze_disclinations_at_points(points_mesh_name, radius=3, n_samples=16, use_ints=False)#
- Parameters:
points_mesh_name (str)
radius (int)
n_samples (int)
use_ints (bool)
- Return type:
- auto_setup(notebook=True)#
Routines to run after first importing data.
- calculate_D_tensor(refresh=True)#
Calculate Schimming-Viñals tensor.
Creates the tensor array “D_tensor”, and the symmetric tensor arrays “D^T D” and “D D^T”.
- calculate_Westin_metrics()#
Calculate Westin scalars measures from the Q-tensor.
Creates the scalar arrays “Westin_l”, “Westin_p”, “Westin_s”.
- calculate_and_show_defect_tangent(glyph_stride=2, field_name=None, scale='nematic_sites', mesh_name='defects', threshold=0.4)#
Display disclination line tangent vectors as glyphs
- Parameters:
glyph_stride (int, optional) – Typical spacing between glyphs
field_name (str or None, optional) – Proposed name for new tangent vector field array
scale (str, optional) – Name of scalar array to use for glyph size scale.
mesh_name (str, optional) – Name of defects mesh
threshold (float or None, optional) – Minimum value of 1/S for deciding which points to include in tangent calculation.
- Returns:
Name of new glyphs mesh
- Return type:
str
- calculate_chi_tensor(refresh=True)#
Calculate Efrati-Irvine handedness pseudotensor.
Creates the tensor array “Chi”, the symmetric tensor arrays “Chi^T Chi” and “Chi Chi^T”, and the vector array “Omega from Chi”. Note that this calculation extends Efrati and Irvine’s construction to the Q-tensor rather than relying on the director field.
- calculate_defect_tangent(threshold=0.4, mesh_name='defects', field_name=None)#
Calculate the unit tangent field to defect lines.
- Parameters:
threshold (float or None, optional) – Minimum value of 1/S for deciding which points to include in tangent calculation.
mesh_name (str, optional) – Name of defects mesh
field_name (str or None, optional) – Proposed name for new tangent vector field array
- Returns:
Name of new tangent vector field array
- Return type:
str
- calculate_frank_energy_comps()#
Calculate splay, twist, and bend Frank free energy densities and related quantities.
- calculate_n_gradients(refresh=True)#
Calculate gradients of director field
- calculate_rotation_vector_n()#
Calculate a combination of derivatives on the director field that, for an ideal disclination, gives the rotation vector (a.k.a. Frank vector) up to sign.
- 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 (np.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
- static director_data_import(filename, sep='\t')#
Import nematic director data and convert it into Q-tensor data in the open-Qmin data_format.
- Parameters:
filename (str)
sep (str, optional)
- Returns:
Q-tensor data in the open-Qmin data_format.
- Return type:
np.ndarray
- load(filenames, **kwargs)#
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.
- static max_re_eigval(a)#
Maximum real part of eigenvalue for eigenvalues in an array of 3x3 matrices
- Parameters:
a (np.ndarray | pyvista.pyvista_ndarray) – Array of 3x3 matrices
- Returns:
Maximum real part of eigenvalues
- Return type:
np.ndarray
- static n_from_Q(q_matrix)#
Get director from 3x3-matrix Q-tensor data
- nematic_calculations(dat, mesh)#
Assign Q-tensor and director field data to a mesh, and conduct calculations based on them.
- Parameters:
dat (np.ndarray) – Data array of floats in the open-Qmin data_format: x y z Qxx Qxy Qxz Qyy Qyz site_type S
mesh (pyvista.DataSet)
- num_boundaries()#
Number of boundary objects
- Returns:
Number of boundary objects
- Return type:
int
- pick_point_analyze_disclination(**kwargs)#
Enable surface picking mode and analyze director winding about the picked point, assumed to be on a disclination.
- Parameters:
**kwargs (dict, optional) – Keyword arguments to
analyze_disclinations_at_points()
- plot_director_glyphs_on_circuits(points_mesh_name, circuits_formula, result_name='director_on_circuits', defects_mesh_name='defects')#
Show director glyphs on small, closed-loop measuring circuits around disclinations at given points.
- Parameters:
points_mesh_name (str)
circuits_formula (
FilterFormula
)result_name (str)
defects_mesh_name (str)
- Return type:
- post_init()#
Portion of initialization to run after open_viewmin.FilterTreePlot.__init__()
- set_director(director_data, mesh_name=None)#
Set director orientation data directly from an array.
- Parameters:
director_data (np.ndarray)
mesh_name (str or None, optional) – Name of mesh on which to define director
- set_q0(q0)#
Set energetically preferred cholesteric wavenumber.
(Re)calculates arrays that depend on q0.
- Parameters:
q0 (float) – Chiral wavenumber
- set_qtensor(q_data, mesh)#
Set Q-tensor data directly from an array.
- Parameters:
q_data (np.ndarray) – Q-tensor data with each row formatted as [Qxx, Qxy, Qxz, Qyy, Qyz]
mesh (pyvista.DataSet)
- Returns:
Q-tensor data reformatted such that each row contains the nine elements of the symmetric Q-tensor matrix, flattened.
- Return type:
np.ndarray
- setup_boundaries(separate_meshes=False)#
Add isosurface or isosurfaces for boundaries.
- Parameters:
separate_meshes (bool, optional) – Whether to create a separate isosurface mesh for each boundary.
- setup_defects()#
Add single-value isosurface of uniaxial order to visualize defects
- setup_director()#
Add glyphs to visualize nematic director on a plane controlled by a plane widget
- show_jones(**kwargs)#
Display optical transmission, calculated from Jones matrices, on three planes.
- Parameters:
**kwargs (dict, optional)
- do_auto_setup = False#
- q0#
- reader#
- xyz_arrays#
- class WidgetFormula(plotter, name=None, mesh_name=None, enabled=True, callback=None, creator=None, configure=None, widget_args=None, **kwargs)#
Class for creating re-usable widgets
- Parameters:
plotter (
FilterTreePlot
)name (str or None) – Name of widget. Pass None to default to “_widget” appended to parent_mesh_name.
mesh_name (str or None) – Name of mesh controlled by widget. Pass None to default to plotter’s default mesh name.
enabled (bool, optional) – Whether to initialize widget as enabled.
callback (callable()) – Function mapping (plotter, parent_mesh_name) to a callable that applies the widget to update its mesh.
creator (callable()) – Function creating the widget. First argument must be a function of the kind created by callback(plotter, parent_mesh_name). Must also accept all arguments in widget_args and keyword arguments in kwargs.
configure (callable() or None, optional) – Function configuring a widget based on previously existing widget, mapping the widget to a two-element tuple (enabled: bool, widget_args: tuple). Pass None to ignore.
widget_args (tuple or None) – Positional arguments, besides callback, to creator. None is equivalent to empty tuple.
kwargs (dict, optional) – Keyword arguments to creator.
- apply()#
Create the widget and apply it to create the mesh it controls
- check_existing_widget_configuration()#
Get information to configure widget according to previous settings
- Returns:
Whether widget is enabled; widget arguments.
- Return type:
(bool, tuple)
- get_creator_func()#
If
self.creator
is a string, get the corresponding callable- Return type:
callable()
- set_color(*widget_color)#
Set widget color
Note that this does not control the color of any mesh.
- Parameters:
widget_color (tuple) – Color as rgb floats, or as one-element tuple containing string of color name or hex value.
- set_outline_visibility(visibility: int)#
Set visibility of a widget’s box outline
- Parameters:
visibility (int) – Make outline visible unless visibility equals 0.
- update()#
Update mesh controlled by widget.
Configure widget according to previous settings, then apply the widget’s callback.
- callback#
- color = None#
- configure#
- creator#
- enabled#
- plotter#
- property widget#
- Get widget
- Return type:
VTK widget
- widget_kwargs#