pylbo.visualisation.modes.mode_figure

Classes

ModeFigure

Main class to hold the figure, axes and colorbar for eigenmode visualisations.

Module Contents

class pylbo.visualisation.modes.mode_figure.ModeFigure(figsize: tuple[int, int], data: pylbo.visualisation.modes.mode_data.ModeVisualisationData, show_ef_panel: bool)

Bases: pylbo.visualisation.figure_window.FigureWindow

Main class to hold the figure, axes and colorbar for eigenmode visualisations.

Parameters:
fig

The figure.

Type:

matplotlib.figure.Figure

axes

The axes.

Type:

dict[str, matplotlib.axes.Axes]

cbar

The colorbar.

Type:

matplotlib.colorbar.Colorbar

cbar_ax

The axes for the colorbar.

Type:

matplotlib.axes.Axes

data

Data object containing all data associated with the selected eigenmode.

Type:

ModeVisualisationData

u1_data

The data for the \(u_1\) coordinate.

Type:

np.ndarray

u2_data

The data for the \(u_2\) coordinate.

Type:

Union[float, np.ndarray]

u3_data

The data for the \(u_3\) coordinate.

Type:

Union[float, np.ndarray]

ef_data

The data for the eigenfunction.

Type:

list[dict]

time_data

The data for the time.

Type:

Union[float, np.ndarray]

omega_txt

The text for the \(\omega\) label.

Type:

matplotlib.text.Text

k2k3_txt

The text for the \(k_2-k_3\) label.

Type:

matplotlib.text.Text

u2u3_txt

The text for the \(u_2-u_3\) label.

Type:

matplotlib.text.Text

t_txt

The text for the time label.

Type:

matplotlib.text.Text

cbar = None
_cbar_hspace = 0.01
_show_ef_panel
_annotate = True
axes
cbar_ax
data
_view = None
ef_data = []
solution_shape = None
_solutions = 0
_check_if_number(val: float, attr_name: str) float

Checks if a given value is a number.

Parameters:
  • val (float) – The value to check.

  • attr_name (str) – The name of the value.

Raises:

ValueError – If the value is not a number.

_check_if_array(array: numpy.ndarray, attr_name: str) numpy.ndarray

Checks is a given value is a numpy array.

Parameters:
  • array (np.ndarray) – The value to check.

  • attr_name (str) – The name of the value.

Raises:

ValueError – If the value is not a numpy array.

abstract set_plot_arrays() None

Sets the arrays used for plotting. This should implement setting of u1_data, u2_data, u3_data, t_data and ef_data.

calculate_mode_solution(efdata: dict, u2: float | numpy.ndarray, u3: float | numpy.ndarray, t: float | numpy.ndarray) numpy.ndarray

Calculates the mode solution.

Parameters:
  • efdata (dict) – The data for the eigenfunction. This should be a dictionary with the keys 'ef' and 'omega', with 'ef'``containing the eigenfunction and ``'omega' the corresponding eigenvalue.

  • u2 (Union[float, np.ndarray]) – The data for the \(u_2\) coordinate.

  • u3 (Union[float, np.ndarray]) – The data for the \(u_3\) coordinate.

  • t (Union[float, np.ndarray]) – The data for the time.

Returns:

The mode solution.

Return type:

np.ndarray

property ax: matplotlib.axes.Axes

returns: Alias for the axes containing the eigenmode solution view. :rtype: matplotlib.axes.Axes

property solutions: numpy.ndarray

returns: The solutions for the eigenmode :rtype: np.ndarray

draw() None
abstract draw_solution() None
draw_textboxes() None
draw_eigenfunction() None

Draws the eigenfunction(s) to the figure.

add_axes_labels() None
_create_cbar_axes(width: float) matplotlib.axes.Axes

Creates the axes for the colorbar.

Parameters:

width (float) – The width of the colorbar axes.

Returns:

The axes for the colorbar.

Return type:

matplotlib.axes.Axes

get_view_xlabel() str
get_view_ylabel() str
get_view_cbar_label() str
add_omega_txt(ax, **kwargs) None

Creates a textbox on the axis with the value of the eigenfrequency.

Parameters:
  • ax (Axes) – The axes to use for the textbox.

  • **kwargs – Additional keyword arguments to pass to add_axis_label().

add_k2k3_txt(ax, **kwargs) None

Creates a textbox on the figure with the value of the k2 and k3 coordinates.

Parameters:
  • ax (Axes) – The axes to use for the textbox.

  • **kwargs – Additional keyword arguments to pass to add_axis_label().

add_u2u3_txt(ax, **kwargs) None

Creates a textbox on the figure with the value of the \(u_2-u_3\) coordinates.

Parameters:
  • ax (Axes) – The axes to use for the textbox.

  • **kwargs – Additional keyword arguments to pass to add_axis_label().

add_t_txt(ax, **kwargs) None
_create_figure_layout(figsize: tuple[int, int]) tuple[matplotlib.figure.Figure, dict]

Create the figure layout for the visualisation. Two panels are created: the top one for the eigenfunction and the bottom one for the visualisation.

Parameters:

figsize (tuple[int, int]) – The size of the figure.

Returns:

  • fig (~matplotlib.figure.Figure) – The figure to use for the visualisation.

  • axes (dict) – The axes to use for the visualisation.

create_animation(times: numpy.ndarray, filename: str, fps: float = 10, dpi: int = 200) None

Creates an animation of the eigenmode solution over a given time interval.

Parameters:
  • times (np.ndarray) – The times at which to create the animation.

  • filename (str) – The filename of the animation.

  • fps (float) – The frames per second of the animation.

  • dpi (int) – The resolution of the animation.