The pyvista_plotter module
This module, part of the pyOMA2 package, provides tools for visualizing and animating mode shapes derived from Operational Modal Analysis (OMA). It offers a flexible interface to create interactive 3D visualizations of mode shapes, incorporating both structural geometry and mode shape data from OMA results. The module leverages PyVista for rich 3D visualizations and supports saving animations as GIFs.
- Classes:
PvGeoPlotter: A class to plot and animate mode shapes in 3D. It takes geometry and result objects as inputs and provides functionalities to visualize mode shapes with various customizable options such as scale factor, view type, and others.
Warning
The module is designed for use within the pyOMA2 package. It requires OMA results and geometry data specific to the structures being analyzed.
Created on Sat Jun 8 21:25:39 2024
@author: dagpa
- class pyoma2.support.geometry.pyvista_plotter.PvGeoPlotter(geo: Geometry2, res: BaseResult | None = None)[source]
Bases:
BasePlotter[Geometry2]A class to visualize and animate mode shapes in 3D using pyvista.
This class provides methods for plotting geometry, mode shapes, and animating mode shapes, utilizing the pyvista and pyvistaqt libraries for visualization.
- Parameters:
geo (Geometry2) – The geometric data of the model, which includes sensor coordinates and other structural information.
Res (Union[BaseResult, MsPoserResult], optional) – The result data containing mode shapes and frequency data (default is None).
- Raises:
ImportError – If pyvista or pyvistaqt are not installed, an error is raised when attempting to instantiate the class.
- __init__(geo: Geometry2, res: BaseResult | None = None)[source]
Initialize the class with geometric and result data. Ensure that the pyvista and pyvistaqt libraries are installed.
- animate_mode(mode_nr: int = 1, scaleF: float = 1.0, plot_lines: bool = True, plot_surf: bool = True, def_sett: dict = 'default', saveGIF: bool = False, pl=None) pv.Plotter[source]
Animate the mode shape for the given mode number.
- Parameters:
mode_nr (int, optional) – The mode number to animate (default is 1).
scaleF (float, optional) – Scale factor for the deformation (default is 1.0).
plot_lines (bool, optional) – Whether to plot lines connecting sensor points (default is True).
plot_surf (bool, optional) – Whether to plot surface meshes (default is True).
def_sett (dict or str, optional) – Settings for the deformed plot (default is ‘default’, which applies preset settings).
saveGIF (bool, optional) – If True, the animation is saved as a GIF (default is False).
pl (pyvista.Plotter, optional) – Existing plotter instance to use (default is None, which creates a new plotter).
- Returns:
The plotter object used for the animation.
- Return type:
pyvista.Plotter
- plot_geo(scaleF=1, col_sens='red', plot_points=True, points_sett='default', plot_lines=True, lines_sett='default', plot_surf=True, surf_sett='default', pl=None, bg_plotter: bool = True, notebook: bool = False)[source]
Plot the 3D geometry of the model, including points, lines, and surfaces.
- Parameters:
scaleF (float, optional) – Scale factor for the sensor vectors (default is 1).
col_sens (str, optional) – Color for the sensor points and arrows (default is ‘red’).
plot_points (bool, optional) – Whether to plot sensor points (default is True).
points_sett (dict or str, optional) – Settings for plotting points (default is ‘default’, which applies preset settings).
plot_lines (bool, optional) – Whether to plot lines representing connections between sensors (default is True).
lines_sett (dict or str, optional) – Settings for plotting lines (default is ‘default’, which applies preset settings).
plot_surf (bool, optional) – Whether to plot surfaces (default is True).
surf_sett (dict or str, optional) – Settings for plotting surfaces (default is ‘default’, which applies preset settings).
pl (pyvista.Plotter, optional) – Existing plotter instance to use (default is None, which creates a new plotter).
bg_plotter (bool, optional) – Whether to use a background plotter for visualization (default is True).
notebook (bool, optional) – If True, a plotter for use in Jupyter notebooks is created (default is False).
- Returns:
The plotter object used for visualization.
- Return type:
pyvista.Plotter
Notes
If pyvistaqt is used, a background plotter will be created. If running in a notebook environment, a pyvista plotter with notebook support is used.
- plot_mode(mode_nr: int = 1, scaleF: float = 1.0, plot_lines: bool = True, plot_surf: bool = True, plot_undef: bool = True, def_sett: dict = 'default', undef_sett: dict = 'default', pl=None, bg_plotter: bool = True, notebook: bool = False)[source]
Plot the mode shape of the structure for a given mode number.
- Parameters:
mode_nr (int, optional) – The mode number to plot (default is 1).
scaleF (float, optional) – Scale factor for the deformation (default is 1.0).
plot_lines (bool, optional) – Whether to plot lines connecting sensor points (default is True).
plot_surf (bool, optional) – Whether to plot surface meshes (default is True).
plot_undef (bool, optional) – Whether to plot the undeformed shape of the structure (default is True).
def_sett (dict or str, optional) – Settings for the deformed plot (default is ‘default’, which applies preset settings).
undef_sett (dict or str, optional) – Settings for the undeformed plot (default is ‘default’, which applies preset settings).
pl (pyvista.Plotter, optional) – Existing plotter instance to use (default is None, which creates a new plotter).
bg_plotter (bool, optional) – Whether to use a background plotter for visualization (default is True).
notebook (bool, optional) – If True, a plotter for use in Jupyter notebooks is created (default is False).
- Returns:
The plotter object used for visualization.
- Return type:
pyvista.Plotter
- Raises:
ValueError – If the result (Res) data is not provided when plotting a mode shape.