The sel_from_plot module

This module provides interactive plotting functionalities for selecting the mode to extract. It is designed to work with Frequency Domain Decomposition (FDD) and Stochastic Subspace Identification (SSI) algorithms, enabling users to visually inspect and interact with stabilization charts and plots of the singular value of the PSD matrix. The module integrates matplotlib plots into a Tkinter GUI, allowing for intuitive interaction such as pole selection through mouse clicks and keyboard shortcuts.

Classes:
SelFromPlot: A class for creating interactive plots where users can select or

deselect poles for further analysis in OMA. It supports various types of plots (FDD, SSI, pLSCF) and provides utilities for saving figures, toggling legends, and handling user inputs through a graphical interface.

Key Features:
  • Interactive selection of poles directly from stabilization charts and PSD plots.

  • Compatibility with FDD, SSI, and pLSCF algorithm outputs.

  • Integration of matplotlib plots within a Tkinter window for enhanced user interaction.

  • Support for exporting plots and managing display settings like legends and pole visibility.

References:

This module is inspired by and expands upon functionalities found in the pyEMA package [ZBGS20], offering specialized features tailored for the pyOMA2 package’s requirements.

Note

To select a peack/pole from a plot hold the SHIFT button and left click with the mouse. To remove from selection the last peack/pole added hold the SHIFT button and right click with the mouse. To remove from selection the closest peack/pole hold the SHIFT button and middle click with the mouse.

Warning

The module is designed to be used as part of the pyOMA2 package and relies on its internal data structures and algorithms.

Module for interactive plots. Part of the pyOMA2 package. Authors: Dag Pasca Diego Margoni

This module provides the SelFromPlot class for interactive selection of poles in operational modal analysis plots. It supports FDD, SSI, and pLSCF methods and integrates matplotlib plots into a Tkinter window for user interaction.

class pyoma2.support.sel_from_plot.SelFromPlot(algo: BaseAlgorithm, freqlim: Tuple[float, float] = None, plot: Literal['FDD', 'SSI', 'pLSCF'] = 'FDD')[source]

Bases: object

A class for interactive selection of poles.

This class integrates matplotlib plots into a Tkinter window, enabling users to interactively select or deselect poles using mouse clicks and keyboard shortcuts. It supports FDD, SSI, and pLSCF methods for operational modal analysis. The design and functionality of this class is strongly inspired by the pyEMA module [ZBGS20].

algo

An instance of a base algorithm class that provides necessary data for plotting.

Type:

BaseAlgorithm

freqlim

Upper frequency limit for the plot, defaults to half the Nyquist frequency if not provided.

Type:

tuple, optional

plot

Type of plot to be displayed. Supported values are “FDD”, “SSI”, and “pLSCF”.

Type:

str

root

Root widget of the Tkinter application.

Type:

tkinter.Tk

sel_freq

List of selected frequencies.

Type:

list

shift_is_held

Flag to track if the SHIFT key is held down during mouse interactions.

Type:

bool

fig

Matplotlib Figure object for plotting.

Type:

matplotlib.figure.Figure

ax2

Axes object for the figure.

Type:

matplotlib.axes.Axes

MARKER

Line2D object for displaying selected points on the plot.

Type:

matplotlib.lines.Line2D

show_legend

Flag to control the visibility of the legend in the plot.

Type:

int

hide_poles

Flag to control the visibility of unstable poles in the plot.

Type:

int

__init__(algo: BaseAlgorithm, freqlim: Tuple[float, float] = None, plot: Literal['FDD', 'SSI', 'pLSCF'] = 'FDD')[source]

Initializes the SelFromPlot class with specified algorithm, frequency limit, and plot type.

Parameters:
  • algo (BaseAlgorithm) – An instance of a base algorithm class providing necessary data for plotting.

  • freqlim (tuple, optional) – Upper frequency limit for the plot, defaults to half the Nyquist frequency if not provided.

  • plot (str, optional) – Type of plot to be displayed. Supported values are “FDD”, “SSI”, and “pLSCF”. Default is “FDD”.

get_closest_freq() None[source]

Selects the frequency closest to the mouse click location for FDD plots.

get_closest_pole(plot: Literal['SSI', 'pLSCF']) None[source]

Selects the pole closest to the mouse click location for SSI or pLSCF plots.

Parameters:

plot (str) – Type of plot (“SSI” or “pLSCF”) for which the pole is being selected.

on_click_FDD(event) None[source]

Handles mouse click events for FDD plots.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – The mouse event triggered on the plot.

on_click_SSI(event, plot: Literal['SSI', 'pLSCF']) None[source]

Handles mouse click events for SSI or pLSCF plots.

Parameters:
  • event (matplotlib.backend_bases.MouseEvent) – The mouse event triggered on the plot.

  • plot (str) – Type of plot (“SSI” or “pLSCF”) where the event occurred.

on_closing() None[source]

Handles the closing event of the Tkinter window.

on_key_press(event) None[source]

Handles key press events for interactive pole selection.

Parameters:

event (matplotlib.backend_bases.KeyEvent) – The key event triggered on the plot.

on_key_release(event) None[source]

Handles key release events.

Parameters:

event (matplotlib.backend_bases.KeyEvent) – The key event triggered on the plot.

plot_stab(plot: Literal['SSI', 'pLSCF'], update_ticks: bool = False) None[source]

Plots the stabilization chart for SSI or pLSCF methods.

Parameters:
  • plot (str) – Type of plot to be displayed (“SSI” or “pLSCF”).

  • update_ticks (bool, optional) – Flag indicating whether to update tick marks for selected poles. Default is False.

plot_svPSD(update_ticks: bool = False) None[source]

Plots the Singular Values of the Power Spectral Density matrix for FDD analysis.

Parameters:

update_ticks (bool, optional) – Flag indicating whether to update tick marks for selected frequencies. Default is False.

save_this_figure() None[source]

Saves the current plot to a file.

show_help() None[source]

Displays a help dialog with instructions for selecting poles.

sort_selected_poles() None[source]

Sorts the selected poles based on their frequencies.

toggle_hide_poles(x: int) None[source]

Toggles the visibility of unstable poles in the plot.

Parameters:

x (int) – Flag indicating whether to hide (1) or show (0) unstable poles.

toggle_legend(x: int) None[source]

Toggles the visibility of the legend in the plot.

Parameters:

x (int) – Flag indicating whether to show (1) or hide (0) the legend.