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]

Visualize and animate 3D mode shapes using PyVista.

geo

Geometric model containing sensor positions and topology.

Type:

Geometry2

res

Modal analysis results (mode shapes, frequencies).

Type:

BaseResult | None

__init__(geo: Geometry2, res: BaseResult | None = None)[source]

Initialize the plotter.

Parameters:
  • geo (Geometry2) – Geometric model with sensor coordinates and connectivity.

  • res (BaseResult | None, default=None) – Modal analysis results containing mode shapes and frequencies.

Raises:

ImportError – If PyVista or PyVistaQt is not installed.

animate_mode(mode_nr: int = 1, scaleF: float = 1.0, show_lines: bool = True, show_surf: bool = True, def_sett: dict | None = None, save_gif: bool = False, pl: Plotter | None = None) Plotter | str[source]

Animate a mode shape oscillation. Optionally save as GIF.

Parameters:
  • mode_nr (int, default=1) – Mode number to animate (1-based).

  • scaleF (float, default=1.0) – Scale factor for oscillation amplitude.

  • show_lines (bool, default=True) – Whether to render connection lines during animation.

  • show_surf (bool, default=True) – Whether to render surface faces during animation.

  • def_sett (dict or None, default=None) – Plot settings for animation frames; falls back to default.

  • save_gif (bool, default=False) – If True, saves animation as a GIF and returns its filepath.

  • pl (pv.Plotter or None, default=None) – Existing plotter instance to use. If None, a new one is created.

Raises:

ValueError – If modal results (res) are not provided.

Returns:

Plotter instance for live animation, or filepath string if GIF saved.

Return type:

pv.Plotter or str

plot_geo(*, scaleF: float = 1.0, col_sens: str = 'red', show_points: bool = True, points_sett: dict | None = None, show_lines: bool = True, lines_sett: dict | None = None, show_surf: bool = True, surf_sett: dict | None = None, pl: Plotter | None = None, background: bool = True, notebook: bool = False) Plotter[source]

Plot the raw geometry: points, lines, surfaces, and sensor arrows.

Parameters:
  • scaleF (float, default=1.0) – Scale factor for arrow length.

  • col_sens (str, default="red") – Color for sensor arrows.

  • show_points (bool, default=True) – Whether to render sensor points.

  • points_sett (dict or None, default=None) – Plot settings for points; falls back to default.

  • show_lines (bool, default=True) – Whether to render sensor connection lines.

  • lines_sett (dict or None, default=None) – Plot settings for lines; falls back to default.

  • show_surf (bool, default=True) – Whether to render surface faces.

  • surf_sett (dict or None, default=None) – Plot settings for surfaces; falls back to default.

  • pl (pv.Plotter or None, default=None) – Existing plotter instance to use.

  • background (bool, default=True) – Whether to use a background Qt plotter if creating new.

  • notebook (bool, default=False) – Whether to create a notebook-compatible plotter.

Returns:

The configured plotter with raw geometry.

Return type:

pv.Plotter

plot_mode(mode_nr: int = 1, scaleF: float = 1.0, show_lines: bool = True, show_surf: bool = True, def_sett: dict | None = None, undef_sett: dict | None = None, pl: Plotter | None = None, background: bool = True, notebook: bool = False) Plotter[source]

Plot a single mode shape with optional undeformed geometry.

Parameters:
  • mode_nr (int, default=1) – Mode number to visualize (1-based).

  • scaleF (float, default=1.0) – Scale factor for deformation amplitude.

  • show_lines (bool, default=True) – Whether to render connection lines on mode shape.

  • show_surf (bool, default=True) – Whether to render surface faces on mode shape.

  • def_sett (dict or None, default=None) – Plot settings for deformed shape; falls back to default.

  • undef_sett (dict or None, default=None) – Plot settings for undeformed shape; falls back to default.

  • pl (pv.Plotter or None, default=None) – Existing plotter instance to use.

  • background (bool, default=True) – Whether to use a background Qt plotter if creating new.

  • notebook (bool, default=False) – Whether to create a notebook-compatible plotter.

Raises:

ValueError – If modal results (res) are not provided or mode_nr is out of range.

Returns:

The configured plotter with mode shape.

Return type:

pv.Plotter