open_viewmin.filter_tree_plot.filter_tree_plot ============================================== .. py:module:: open_viewmin.filter_tree_plot.filter_tree_plot .. autoapi-nested-parse:: Define class extending `pyvista.Plotter` with filter formulas and a filters tree Classes ------- .. autoapisummary:: open_viewmin.filter_tree_plot.filter_tree_plot.FilterTreePlot Module Contents --------------- .. py:class:: FilterTreePlot(filenames=None, user_settings=None, theme=None, reader=ovm_utilities.fast_import, dims=None, data_stride=1, **kwargs) Bases: :py:obj:`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. :param filenames: Files to import. :type filenames: list[str], str, or None, optional :param user_settings: Customizations to default plotter settings. :type user_settings: dict or None, optional :param theme: PyVista plot theme :type theme: ['dark' | 'document' | 'paraview' | None], optional :param reader: Function to import and process data files :type reader: callable() :param dims: System dimensions used if no filenames are given. :type dims: tuple of ints or None, optional :param data_stride: Spacing between grid sites used if no filenames are given. :type data_stride: int, optional :param kwargs: Keyword arguments to :meth:`pyvista.Plotter` :type kwargs: dict, optional .. py:method:: __getitem__(mesh_name) Mimic dictionary key-value behavior for mesh names and meshes. :param mesh_name: :type mesh_name: str :rtype: :class:`~open_viewmin.filter_tree_plot.filter_formulas.FilterFormula` .. py:method:: __repr__() Represent plotter as a textual representation of its filters tree. :returns: Textual representation of filters tree. :rtype: str .. py:method:: __setitem__(mesh_name, filter_formula_lambda) Mimic dictionary key-value behavior for mesh names and meshes. :param mesh_name: :type mesh_name: str :param filter_formula_lambda: Callable that creates filter formula :type filter_formula_lambda: callable() :rtype: :class:`~open_viewmin.filter_tree_plot.filter_formulas.FilterFormula` .. py:method:: _add_checkbox_generic(callback, current_val, size=50, position=None, color_on=None, **kwargs) Add checkbox :param callback: :type callback: callable :param current_val: :type current_val: bool :param size: :type size: int :param position: :type position: tuple(float), optional :param color_on: :type color_on: pyvista.plotting.colors.Color, optional :param kwargs: keyword arguments to :meth:pyvista.Plotter.add_checkbox_button_widget .. py:method:: _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) :param callback: :type callback: callable :param mesh_name: :type mesh_name: str :param current_val: :type current_val: float, optional :param min_val: :type min_val: float, optional :param max_val: :type max_val: float, optional :param title: :type title: str, optional :param title_height: :type title_height: float, optional :param style: Options in pyvista.global_theme.slider_styles :type style: str, optional :param label_height: :type label_height: float :param pointa: :type pointa: tuple(float), optional :param pointb: :type pointb: tuple(float), optional :param loc: 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. :type loc: str, optional :param kwargs: keyword arguments to :meth:`pyvista.Plotter.add_slider_widget` :rtype: vtk.vtkSliderWidget .. py:method:: _set_pyvista_plotter_properties() Initialization choices for PyVista Plotter .. py:method:: _visibility_callback(actor_name) .. py:method:: actor_names() Names of all actors in filters tree. :returns: List of actor names. :rtype: list[str] .. py:method:: add_axes() Add x,y,z axes widget. .. py:method:: add_filter_formula(name=None, **kwargs) Add a filter formula to the plotter. :param name: Name of new mesh. Pass `None` to do nothing. :type name: str or `None`, optional :param \*\*kwargs: Keyword arguments to :class:`~open_viewmin.filter_tree_plot.filter_formulas.FilterFormula` :returns: New child mesh created by filter formula, or `None` if no filter formula was created. :rtype: pyvista.dataset or `None` .. py:method:: 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 :param mesh_name: :type mesh_name: str :param min_val: :type min_val: float, optional :param max_val: :type max_val: float, optional :param title: :type title: str, optional :param title_height: :type title_height: float :param style: Options in pyvista.global_theme.slider_styles :type style: str, optional :param label_height: :type label_height: float, optional :param pointa: :type pointa: tuple(float), optional :param pointb: :type pointb: tuple(float), optional :param loc: 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. :type loc: str, optional :param kwargs: keyword arguments to :meth:`_add_inplot_slider` :rtype: vtk.vtkSliderWidget .. py:method:: add_plane_widget(*args, **kwargs) Overload add_plane_widget to take a string argument as name of mesh controlled by widget. :param \*args: :type \*args: tuple, optional :param \*\*kwargs: :type \*\*kwargs: dict, optional :rtype: vtkmodules.vtkInteractionWidgets.vtkImplicitPlaneWidget .. py:method:: add_root_mesh(mesh, mesh_name='fullmesh') Add a filter formula as a new root of the filter tree. :param mesh: PyVista mesh :type mesh: pyvista.DataSet :param mesh_name: Name of the new root mesh. :type mesh_name: str, optional :returns: Name of the new root mesh (possibly altered to avoid overwriting existing mesh names). :rtype: str .. py:method:: 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 :param mesh_name: :type mesh_name: str :param min_val: :type min_val: float, optional :param max_val: :type max_val: float, optional :param title: :type title: str, optional :param title_height: :type title_height: float, optional :param style: Options in pyvista.global_theme.slider_styles :type style: str, optional :param label_height: :type label_height: float, optional :param pointa: :type pointa: tuple(float), optional :param pointb: :type pointb: tuple(float), optional :param loc: 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. :type loc: str, optional :param kwargs: keyword arguments to :meth:`_add_inplot_slider` .. py:method:: add_visibility_checkbox(actor_name, size=50, position=None, **kwargs) Add checkbox to toggle an actor's visibility :param actor_name: :type actor_name: str :param size: :type size: int :param position: :type position: tuple(float), optional :param kwargs: Keyword arguments to :meth:`_add_checkbox_generic` .. py:method:: add_widget_checkbox(widget_name, size=50, position=None, background_color='red', **kwargs) Add checkbox that activates/deactivates a widget :param widget_name: :type widget_name: str :param size: :type size: int :param position: :type position: tuple(float), optional :param background_color: :type background_color: str :param kwargs: Keyword arguments to :meth:`_add_checkbox_generic` .. py:method:: add_widget_formula(name=None, **kwargs) Add a widget formula to the plotter. :param name: Name of new widget. Pass `None` to do nothing. :type name: str or `None`, optional :param \*\*kwargs: Keyword arguments to :class:`~open_viewmin.filter_tree_plot.widget_formulas.WidgetFormula` :type \*\*kwargs: dict, optional :returns: The new widget formula, or `None` if none was created. :rtype: :class:`~open_viewmin.filter_tree_plot.widget_formulas.WidgetFormula` or `None` .. py:method:: array_dims() System array-size dimensions. :returns: `(array_Lx, array_Ly, array_Lz)` :rtype: tuple(int) .. py:method:: 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. :param file_data: :type file_data: np.ndarray :param filename: :type filename: str :param do_load_frame: Whether to view the frame :type do_load_frame: bool, optional .. py:method:: colorbar_titles() Get titles of all scalar bars :returns: List of scalar bar titles :rtype: list[str] .. py:method:: colorbars() Get list of all existing colorbars (scalar bars) for filter tree actors. :rtype: list of VTK scalar bar actors .. py:method:: copy_all_actors(to_plotter) Copy actors to another plotter, such as for displaying in Jupyter notebooks. :param to_plotter: :type to_plotter: pyvista.Plotter :rtype: None .. py:method:: create_fullmesh(dat=None, mesh_name='fullmesh', frame_num=None) Create a uniform grid mesh as a root mesh for the filter tree. :param dat: Data array, with first three columns holding integer coordinates X, Y, Z. :type dat: np.ndarray, optional :param mesh_name: Name of root mesh. :type mesh_name: str, optional :param frame_num: Frame number for this root mesh. Pass `None` to append as a new frame. :type frame_num: int or `None`, optional :returns: Frame number and new root mesh. :rtype: int, pyvista.dataset .. py:method:: dims() System linear dimensions. :returns: `(Lx, Ly, Lz)` :rtype: tuple(int) .. py:method:: disable_eye_dome_lighting() .. py:method:: disable_shadows() .. py:method:: do_orbit() Move camera along orbit path Removes actor named "orbit", if it exists, before starting the motion. .. py:method:: enable_eye_dome_lighting() .. py:method:: enable_shadows() .. py:method:: extract_actors(jupyter_backend='trame') Set up a new PyVista plotter with a copy of all this plotter's actors. :param jupyter_backend: PyVista plotting backend. See https://docs.pyvista.org/version/stable/user-guide/themes. :type jupyter_backend: str, optional :returns: New PyVista `Plotter` containing this `Plotter`'s actors. :rtype: pyvista.Plotter .. py:method:: filter_tree_roots() Names of meshes whose generating :class:`~open_viewmin.filter_tree_plot.filter_formulas.FilterFormula` 's are roots of the filter tree :rtype: list[str] .. py:method:: find_actor_for_scalar_bar(scalar_bar) Get the name of the filter tree mesh corresponding to a given scalar bar. :param scalar_bar: :type scalar_bar: VTK scalar bar actor :returns: Mesh name :rtype: str .. py:method:: first_frame() View first frame in data timeseries. .. py:method:: get_actor(actor_name) Return actor with a given name, if it exists. :param actor_name: Name of actor. :type actor_name: str :returns: PyVista actor. :rtype: vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor .. py:method:: get_actor_name(actor) Given an actor, return its name. :param actor: PyVista actor. :type actor: vtkOpenGLActor :returns: Name of actor. :rtype: str .. py:method:: get_filter_formula(actor_name) Get the formula needed to re-create an actor from its parent mesh. :param actor_name: Name of the actor. :type actor_name: str :returns: Actor recipe. :rtype: types.SimpleNamespace .. py:method:: get_grandparent_mesh_name(actor_or_mesh_name) Get the name of the parent of the parent of a given actor or mesh. :param actor_or_mesh_name: Name of actor of mesh :type actor_or_mesh_name: str :returns: Name of grandparent mesh. :rtype: str .. py:method:: get_mesh(mesh_name) Return mesh with a given name, if it exists. For non-mesh actors, return parent mesh. :param mesh_name: :type mesh_name: str :returns: PyVista mesh :rtype: pyvista.DataSet .. py:method:: get_mesh_name(mesh) Get the name of a given mesh. :param mesh: :type mesh: pyvista.DataSet :returns: name of the mesh :rtype: str .. py:method:: get_points() Get array of coordinates belonging to root mesh "fullmesh" :returns: Array of point coordinates. :rtype: np.ndarray .. py:method:: get_widget(widget_name) Get widget by name :param widget_name: :type widget_name: str :rtype: vtkmodules.vtkInteractionWidgets.vtk3DWidget .. py:method:: get_widget_formula(widget_name) Get :class:`~open_viewmin.filter_tree_plot.widget_formulas.WidgetFormula` by name :param widget_name: :type widget_name: str :rtype: :class:`~open_viewmin.filter_tree_plot.widget_formulas.WidgetFormula` .. py:method:: hide_all_actors() Make all actors invisible .. py:method:: hide_all_meshes() Make actors of all meshes invisible .. py:method:: hide_orbit() Remove the mesh visualizing the camera orbit. .. py:method:: initialize_plotter(**kwargs) Run `pyvista.Plotter` initialization. Note: This is removed from `__init__()` for purposes of multiple inheritance of :class:`~open_viewmin.nematic.nematic.NematicPlot`. .. py:method:: last_frame() View last frame in data timeseries. .. py:method:: load(filenames, reader=ovm_utilities.fast_import, mpi_group=True, do_load_frame=True) Import a file or files. :param filenames: Files to load. :type filenames: str or list[str] :param reader: Function to read each file. :type reader: callable, optional :param mpi_group: Whether to stitch files together as separate outputs from the same timestep from an MPI run. :type mpi_group: bool, optional :param do_load_frame: Whether to view the frame containing the loaded data. :type do_load_frame: bool, optional .. py:method:: mesh_names() Names of all meshes in filters tree. :returns: List of mesh names. :rtype: list[str] .. py:method:: name_mesh_without_overwriting(mesh_name) Modify a proposed new mesh name to be distinct from existing mesh names :param mesh_name: Proposed mesh name :type mesh_name: str :returns: Distinct mesh name to use :rtype: str .. py:method:: name_widget_without_overwriting(widget_name) Modify a proposed new widget name to be distinct from existing widget names :param widget_name: Proposed widget name :type widget_name: str :returns: Distinct widget name to use :rtype: str .. py:method:: next_frame() View next frame in data timeseries. .. py:method:: non_filter_tree_actor_names() List actors that don't belong to open_viewmin's filter tree. :returns: List of actor names. :rtype: list[str] .. py:method:: num_frames() Number of frames in timeseries data. .. py:method:: organize_filenames(filenames, mpi_group=True) :staticmethod: For data to be imported, sort filenames alphabetically after grouping MPI files appropriately. :param filenames: :type filenames: list[str] | str :param mpi_group: :type mpi_group: bool :rtype: list[str] .. py:method:: play(pause_time=0.5) In-GUI animation; will be slow because it loads and renders on the fly .. py:method:: previous_frame() View previous frame in data timeseries. .. py:method:: probe_at_picked_surface_point(result_name=None) Create a `FilterFormula` with the `sample` filter probing a picked mesh at a picked point :param result_name: Name of new `FilterFormula`; defaults to "_probed" appended to name of picked mesh :type result_name: str, optional :returns: **result_name** -- Name of new `FilterFormula` :rtype: str .. py:method:: refresh() Re-apply all filter formulas to refresh meshes .. py:method:: remove_mesh_completely(mesh_name, remove_children=True) Remove a mesh (filter or actor) from the plotter and from the filters tree. :param mesh_name: Name of mesh to remove. :type mesh_name: str :param remove_children: Whether to recursively remove all meshes descended from this mesh in the filters tree. :type remove_children: bool, optional :rtype: None .. py:method:: rename_mesh(from_name, to_name, do_refresh=True) Copy a mesh in the filters tree by copying its recipe. :param from_name: Name of mesh to copy. :type from_name: str :param to_name: Name of new mesh. :type to_name: str :param do_refresh: Whether to create the mesh anew from its filter after renaming. :type do_refresh: bool, optional :rtype: None .. py:method:: save_meshes(file_prefix) Save all meshes to .vtk files :param file_prefix: File location will be `[mesh_name].vtk` appended to this. :type file_prefix: str .. py:method:: scalar_fields(mesh_name='fullmesh') List names of datasets with one value at each site. :param mesh_name: PyVista mesh or its name. :type mesh_name: str or pyvista.DataSet :returns: List of array names. :rtype: list[str] .. py:method:: set_actor_visibility(actor, visibility: bool) Set visibility of a mesh or meshes :param actor: :type actor: str, sequence of str, VTK actor, or sequence of VTK actors :param visibility: Whether mesh(es) are to be visible. :type visibility: bool .. py:method:: 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`. :param args: :param kwargs: .. py:method:: set_lights_intensity(intensity) Rescale intensity of all lights. :param intensity: :type intensity: float .. py:method:: set_orbit(**kwargs) Set orbit properties and get its camera locations :param kwargs: keyword arguments to `set_orbit_kwargs()` :returns: Orbit points :rtype: pyvista.core.pointset.PolyData .. py:method:: set_orbit_kwargs(factor=3.0, n_points=20, viewup=None, shift=0.0, step=0.1) Modify camera orbit :param factor: orbit radius relative to data extent :type factor: float :param n_points: number of points subdividing circle at which to generate images :type n_points: int :param viewup: orientation vector for camera's up direction :type viewup: iterable[float], optional :param shift: translation of camera location along `viewup` :type shift: float :param step: orbit speed in seconds per frame :type step: float :returns: **vis** -- Visibility of orbit points actor :rtype: bool .. py:method:: show_orbit() Add a mesh of points visualizing the camera orbit. .. py:method:: symmetric_tensor_fields(mesh_name='fullmesh') List names of datasets with nine values at each site, whose corresponding 3x3 matrix is everywhere symmetric. :param mesh_name: PyVista mesh or its name. :type mesh_name: str or pyvista.DataSet :returns: List of array names. :rtype: list[str] .. py:method:: tensor_fields(mesh_name='fullmesh') List names of datasets with nine values at each site. :param mesh_name: PyVista mesh or its name. :type mesh_name: str or pyvista.DataSet :returns: List of array names. :rtype: list[str] .. py:method:: toggle_actor_visibility(actor) :staticmethod: Toggle visibility of an actor :param actor: :type actor: VTK actor :returns: **new_visibility** :rtype: bool .. py:method:: toggle_eye_dome_lighting() Switch eye dome lighting on/off .. py:method:: toggle_filter_tree_actor_visibility(actor_name) Toggle visibility of a mesh in the filter tree. :param actor_name: Name of mesh :type actor_name: str .. py:method:: toggle_floor() Toggle visibility of floor (-z) plane. .. py:method:: toggle_last_colorbar() Toggle visibility of most recently modified colorbar. .. py:method:: toggle_orbit_visibility(toggle=True) Toggle visibility of mesh visualizing camera orbit. .. py:method:: toggle_scalar_bar_visibility(scalar_bar_actor) Toggle visibility of a scalar bar :param scalar_bar_actor: :type scalar_bar_actor: VTK scalar bar actor .. py:method:: toggle_shadows() Turn shadow rendering on/off .. py:method:: toggle_stereo_render() Turn anaglyph stereo 3D effect on/off .. py:method:: unique_array_names(mesh=None) Get array names for datasets attached to a mesh, deleting duplicates. :param mesh: PyVista mesh or name of mesh :type mesh: str or pyvista.DataSet :returns: Mesh along with the list of unique array names. :rtype: (pyvista.DataSet, list[str]) .. py:method:: update_actor(actor_name, **kwargs) Update a filter formula's mesh visualization options. Shorthand for `self.get_filter_formula(ellipsoid_mesh_name).set()` :param actor_name: Name of filter formula :type actor_name: str :param \*\*kwargs: Keyword arguments to :meth:`open_viewmin.filter_tree_plot.filter_formulas.FilterFormula.set` .. py:method:: update_filter(mesh_name, update_actor=False, **kwargs) Update a filter formula. Shorthand for `self.get_filter_formula(parent_mesh_name).update()`. :param mesh_name: Name of filter formula :type mesh_name: str :param update_actor: Whether to update an actor immediately after updating its mesh. :type update_actor: bool, optional :param \*\*kwargs: Keyword arguments to :meth:`open_viewmin.filter_tree_plot.filter_formulas.FilterFormula.update` :type \*\*kwargs: dict, optional .. py:method:: vector_fields(mesh='fullmesh') List names of datasets with three values at each site. :param mesh: PyVista mesh or its name. :type mesh: str or pyvista.DataSet :returns: List of array names. :rtype: list[str] .. py:method:: 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. :param frame_num: Index in `self.data` of the timeframe to display. :type frame_num: int, optional :param keep_camera_dist: Whether to force camera to maintain position after frame load. :type keep_camera_dist: bool, optional .. py:attribute:: actors_color_cycle .. py:attribute:: array_dims_defined :value: False .. py:attribute:: axes :value: None .. py:attribute:: data :value: [] .. py:attribute:: data_stride .. py:property:: default_mesh .. py:attribute:: default_mesh_name .. py:attribute:: filenames :value: [] .. py:attribute:: filter_formulas .. py:attribute:: frame_data :value: [] .. py:attribute:: frame_num .. py:property:: fullmesh .. py:attribute:: geometric_objects .. py:attribute:: is_enabled_eye_dome_lighting .. py:attribute:: meshes_dict .. py:attribute:: oVM_theme .. py:attribute:: off_screen .. py:attribute:: orbit_kwargs .. py:attribute:: orbit_path .. py:attribute:: settings .. py:attribute:: title .. py:attribute:: widget_formulas .. py:attribute:: widgets