The mpl_plotter module

This module, part of the pyOMA2 package, is dedicated to visualising mode shapes from Operational Modal Analysis (OMA) results. It provides an interface to create 3D visualisations of mode shapes, integrating the geometry of the structure and the mode shape data from OMA analysis. The module leverages Matplotlib’s capabilities to create visualizations that can be interactively viewed or saved.

Classes:

Geo1MplPlotter: A class to plot mode shapes in 3D specifically for geometry 1. It takes geometry and result objects as inputs and provides functionalities to visualise mode shapes with various customizable options such as scale factor, view type, and others.

Geo2MplPlotter: A class to plot mode shapes in 3D specifically for geometry 2. It takes geometry and result objects as inputs and provides functionalities to visualise 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 Sun Jun 9 12:48:34 2024

@author: dagpa

class pyoma2.support.geometry.mpl_plotter.Geo1MplPlotter(geo: T_Geo, res: BaseResult | None = None)[source]

Bases: MplPlotter[Geometry1]

A class to plot mode shapes in 3D using Geometry1.

plot_geo(scaleF: int = 1, view: Literal['3D', 'xy', 'xz', 'yz'] = '3D', col_sns: str = 'red', col_sns_lines: str = 'red', col_BG_nodes: str = 'gray', col_BG_lines: str = 'gray', col_BG_surf: str = 'gray', col_txt: str = 'red') Tuple[Figure, Axes][source]

Plots the geometry (type 1) of tested structure.

This method visualizes the geometry of a structure, including sensor placements and directions. It allows customization of the plot through various parameters such as scaling factor, view type, and options to remove fill, grid, and axis from the plot.

Parameters:
  • scaleF (int, optional) – The scaling factor for the sensor direction quivers. A higher value results in longer quivers. Default is 1.

  • view ({'3D', 'xy', 'xz', 'yz'}, optional) – The type of view for plotting the geometry. Options include 3D and 2D projections on various planes. Default is “3D”.

  • remove_fill (bool, optional) – If True, removes the fill from the plot. Default is True.

  • remove_grid (bool, optional) – If True, removes the grid from the plot. Default is True.

  • remove_axis (bool, optional) – If True, removes the axis labels and ticks from the plot. Default is True.

Raises:

ValueError – If Geo is not defined in the setup.

Returns:

A tuple containing the figure and axis objects of the plot. This can be used for further customization or saving the plot externally.

Return type:

tuple

plot_mode(mode_nr: int, scaleF: int = 1, view: Literal['3D', 'xy', 'xz', 'yz'] = '3D', col_sns: str = 'red', col_sns_lines: str = 'red', col_BG_nodes: str = 'gray', col_BG_lines: str = 'gray', col_BG_surf: str = 'gray') Tuple[Figure, Axes][source]

Plots a 3D mode shape for a specified mode number using the Geometry1 object.

Parameters:
  • Geo (Geometry1) – Geometry object containing sensor coordinates and other information.

  • mode_nr (int) – Mode number to visualize.

  • scaleF (int, optional) – Scale factor for mode shape visualization. Default is 1.

  • view ({'3D', 'xy', 'xz', 'yz'}, optional) – View for the 3D plot. Default is ‘3D’.

  • remove_fill (bool, optional) – Whether to remove fill from the plot. Default is True.

  • remove_grid (bool, optional) – Whether to remove grid from the plot. Default is True.

  • remove_axis (bool, optional) – Whether to remove axis from the plot. Default is True.

Returns:

A tuple containing the matplotlib figure and axes of the mode shape plot.

Return type:

Any

class pyoma2.support.geometry.mpl_plotter.Geo2MplPlotter(geo: T_Geo, res: BaseResult | None = None)[source]

Bases: MplPlotter[Geometry2]

A class to plot mode shapes in 3D using Geometry2.

plot_geo(scaleF: int = 1, view: Literal['3D', 'xy', 'xz', 'yz'] = '3D', col_sns: str = 'red', col_sns_lines: str = 'black', col_sns_surf: str = 'lightcoral', col_BG_nodes: str = 'gray', col_BG_lines: str = 'gray', col_BG_surf: str = 'gray', col_txt: str = 'red') Tuple[Figure, Axes][source]

Plots the geometry (type 2) of tested structure.

This method creates a 3D or 2D plot of a specific geometric configuration (geo2) with customizable features such as scaling factor, view type, and visibility options for fill, grid, and axes. It involves plotting sensor points, directions, and additional geometric elements if available.

Parameters:
  • scaleF (int, optional) – Scaling factor for the quiver plots representing sensors’ directions. Default is 1.

  • view ({'3D', 'xy', 'xz', 'yz'}, optional) – Specifies the type of view for the plot. Can be a 3D view or 2D projections on various planes. Default is “3D”.

  • remove_fill (bool, optional) – If True, the plot’s fill is removed. Default is True.

  • remove_grid (bool, optional) – If True, the plot’s grid is removed. Default is True.

  • remove_axis (bool, optional) – If True, the plot’s axes are removed. Default is True.

Raises:

ValueError – If geo2 is not defined in the setup.

Returns:

Returns a tuple containing the figure and axis objects of the matplotlib plot. This allows for further customization or saving outside the method.

Return type:

tuple

plot_mode(mode_nr: int | None, scaleF: int = 1, view: Literal['3D', 'xy', 'xz', 'yz'] = '3D', color: str = 'cmap', *args, **kwargs) Tuple[Figure, Axes][source]

Plots a 3D mode shape for a specified mode number using the Geometry2 object.

Parameters:
  • geo2 (Geometry2) – Geometry object containing nodes, sensor information, and additional geometrical data.

  • mode_nr (int) – Mode number to visualize.

  • scaleF (int, optional) – Scale factor for mode shape visualization. Default is 1.

  • view ({'3D', 'xy', 'xz', 'yz', 'x', 'y', 'z'}, optional) – View for the 3D plot. Default is ‘3D’.

  • remove_fill (bool, optional) – Whether to remove fill from the plot. Default is True.

  • remove_grid (bool, optional) – Whether to remove grid from the plot. Default is True.

  • remove_axis (bool, optional) – Whether to remove axis from the plot. Default is True.

  • *args – Additional arguments for customizations.

  • **kwargs – Additional arguments for customizations.

Returns:

A tuple containing the matplotlib figure and axes of the mode shape plot.

Return type:

Tuple[plt.Figure, plt.Axes]

class pyoma2.support.geometry.mpl_plotter.MplPlotter(geo: T_Geo, res: BaseResult | None = None)[source]

Bases: BasePlotter[T_Geo]

An abstract base class for plotting geometry and mode shapes using Matplotlib.