open_viewmin
#
Subpackages#
open_viewmin.filter_tree_plot
open_viewmin.filter_tree_plot_Qt
open_viewmin.filter_tree_plot_Qt.menus
open_viewmin.filter_tree_plot_Qt.menus.add_actors_widgets
open_viewmin.filter_tree_plot_Qt.menus.glyph_modify
open_viewmin.filter_tree_plot_Qt.menus.main_menus
open_viewmin.filter_tree_plot_Qt.menus.menu_utilities
open_viewmin.filter_tree_plot_Qt.menus.mesh_options
open_viewmin.filter_tree_plot_Qt.menus.record
open_viewmin.filter_tree_plot_Qt.menus.streamlines_modify
open_viewmin.filter_tree_plot_Qt.menus.visualization_options
open_viewmin.filter_tree_plot_Qt.widgets_Qt
open_viewmin.filter_tree_plot_Qt.filter_tree_plot_Qt
open_viewmin.filter_tree_plot_Qt.settings_Qt
open_viewmin.nematic
Submodules#
Package Contents#
Classes#
Class for reusable PyVista filters. |
|
Extend PyVista Plotter class to organize meshes into a "filter tree" so that |
|
Implement some PyVista functionality, with filter trees, in the PyVistaQt |
|
Plotter class for nematic liquid crystals visualization, with the |
|
Plotter class for nematic liquid crystals visualization, with the |
|
Class for creating re-usable widgets |
- class open_viewmin.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 (open_viewmin.FilterTreePlot) – Parent plotter
name (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).
- property array_names#
Get mesh’s dataset names
- Return type:
list[str]
- 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
- property normal#
- property orientations#
- property origin#
- property parent_filter_formula#
Get parent mesh’s filter formula
- Return type:
- property parent_mesh#
Get parent mesh
- Return type:
pyvista.dataset
- 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#
- __getitem__(key)#
Access mesh’s datasets in dictionary-like manner
- __repr__()#
Print keyword arguments to self.__init__ and their current values
- Return type:
str
- __setitem__(key, set_to)#
Set mesh’s datasets in dictionary-like manner
- _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 filter_formula’s do_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)#
- 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()
- inherit(filter_kwarg)#
- 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 self.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 actors
- Return type:
list of vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor
- update_children()#
Update child meshes
Calls update function of each filter formula named in self.children
- class open_viewmin.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.
- class open_viewmin.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
- property actor_control_toolbars#
Get toolbars controlling individual actors
- Returns:
Dictionary of toolbars
- Return type:
dict
- _assign_keypress_events()#
Assign actions to keyboard keys.
- _enable_3_lights(only_active=False)#
- _enable_lightkit(only_active=False)#
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 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_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)#
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
- customize_controls_dock()#
Modify settings of controls area
- 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)#
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.
- open_files_dialog(sort=True)#
Launch GUI widget for selecting files to import
- Parameters:
sort (bool, optional) – Whether to sort filenames by timestamp
- refresh()#
Re-apply all filter formulas to refresh meshes
- remove_actor_completely(actor_name)#
- 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=False)#
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_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 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_orbit_dlg(**kwargs)#
- show_editor()#
Show editor widget controlling actors’ visibility
- 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
- 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
- class open_viewmin.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
,NematicPlotNoQt
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 open_viewmin.FilterTreePlot
- auto_setup(notebook=False)#
Routines to run after first importing data.
Add nematic-specific items to the “Calculate” menu
- 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) –
- Returns:
callback that refreshes Jones planes by re-applying the control slider widgets
- Return type:
callable()
- class open_viewmin.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 open_viewmin.FilterTreePlot
- property num_boundaries#
returns: Number of boundary objects :rtype: int
- 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[numpy.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)#
- analyze_disclination_at_picked_point(**kwargs)#
- analyze_disclinations(defects_mesh_name='defects', n_centroids=50, tangents_glyph_name=None, **kwargs)#
- analyze_disclinations_at_points(points_mesh_name, radius=3, n_samples=16, use_ints=False)#
- auto_setup(notebook=True)#
Routines to run after first importing data.
- 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_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_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_rotation_vector_n()#
- create_fullmesh(dat=None, mesh_name='fullmesh', frame_num=None)#
- 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:
numpy.ndarray
- load(filenames, **kwargs)#
- max_re_eigval(a)#
Maximum real part of eigenvalue for eigenvalues in an array of 3x3 matrices
- Parameters:
a (numpy.ndarray | pyvista.pyvista_ndarray) – Array of 3x3 matrices
- Returns:
Maximum real part of eigenvalues
- Return type:
numpy.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 (numpy.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) –
- pick_point_analyze_disclination(**kwargs)#
- plot_director_glyphs_on_circuits(points_mesh_name, circuits_formula, result_name='director_on_circuits', defects_mesh_name='defects')#
- 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 (numpy.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 (numpy.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:
numpy.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)#
- class open_viewmin.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 (open_viewmin.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.
- property widget#
Get widget
- Return type:
VTK widget
- 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)#
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.