pyOMA.core.PlotMSH.ModeShapePlot#

class pyOMA.core.PlotMSH.ModeShapePlot(geometry_data, stabil_calc=None, modal_data=None, prep_signals=None, merged_data=None, selected_mode=[0, 0], amplitude=1, real=False, scale=0.2, dpi=100, nodecolor='dimgrey', nodemarker='o', nodesize=20, beamcolor='dimgrey', beamstyle='-', linewidth=1, callback_fun=None, fig=None, save_ani_path=None)[source]#

Bases: object

This class is used for displaying modal values and modeshapes obtained by one of the classes derived from ModalBase as part the of the pyOMA project (Bauhaus-Universität Weimar, Institut für Strukturmechanik).

Drawing abilities (outdated):
  • creation of 3d plots using matplotlib’s mplot3 from the matplotlib toolkit

  • adjusting axis limits for each of the three axis i.e. zoom view, shift view (along single and multiple axis’)

  • change the viewport e.g. x, y, z and isometric view

  • rotating and zooming through mouse interaction is currently supported by matplotlib, whereas panning is not

  • animate the currently displayed deformed structure

  • save the still frame

currently not supported (outdated):
  • 3D surface plots, as they are not properly supported by the underlying matplotlib api

  • saving of the animation as a movie file

  • drawing multiple modeshapes into one plot

  • plot modeshape in a single call from a script i.e. use static methods

Todo

  • clean up animation methods * move trace objects into a separate class method * use class methods to draw animated modeshapes * only update class objects in animation * implement enable/disable {nodes,lines, connecting lines, trace lines, etc.)

  • remove “real modeshape” functionality as it might mislead inexperienced users

  • Fix parent-childs assignment: assemble child displacement from the

    weighted sum of raw mode shape (channel) data of the parents to allow for multiple channel averaging into a single child displacement, afterwards transform to polar coordinates

__init__(geometry_data, stabil_calc=None, modal_data=None, prep_signals=None, merged_data=None, selected_mode=[0, 0], amplitude=1, real=False, scale=0.2, dpi=100, nodecolor='dimgrey', nodemarker='o', nodesize=20, beamcolor='dimgrey', beamstyle='-', linewidth=1, callback_fun=None, fig=None, save_ani_path=None)[source]#

Initializes the class object and automatically checks, which of the below use cases have to be considered

Variable in PlotMSH

Merging Routine

single-setup

poger/preger

poser merging

modal_freq.

modal_data

modal_data

merged_data

modal_damping

modal_data

modal_data

merged_data

modeshapes

modal_data

modal_data

merged_data

num_channels

prep_signals

modal_data

merged_data

chan_dofs

prep_signals

modal_data

merged_data

select_modes

stabil_data

stabil_data

merged_data

nodes

geometry_data

geometry_data

geometry_data

lines

geometry_data

geometry_data

geometry_data

parent-childs

geometry_data

geometry_data

geometry_data

Parameters:
  • geometry_data (PreProcessingTools.GeometryProcessor, required) – Object containing all the necessary geometry information.

  • stabil_calc (StabilDiagram.StabilCalc, optional) – Object containing the information, which modes were selected from modal_data.

  • modal_data (ModalBase.ModalBase, optional) – Object of one the classes derived from ModalBase.ModalBase, containing the estimated modal parameters at multiple model orders.

  • prep_signals (PreProcessingTools.PreProcessSignals, optional) – Object containing the signals data and information about it.

  • merged_data (PostProcessingTools.MergePoSER, SSICovRef.PogerSSICovRef, optional) – Object containing the merged data

  • selected_mode (list, optional) – List of [model_order, mode_index] to define the mode that is displayed upon startup

  • amplitude (float, optional) – Scaling factor to scale the magnitude of mode shape displacements

  • real (bool, optional) – Whether to plot only the real part or the magnitude of the complex modal coordinates

  • scale (float, optional) – Scaling factor for other elements such as arrows, etc. as a fraction of the current view limits

  • dpi (float, optional) – Resolution of the drawing canvas

  • nodecolor (matplotlib color, optional) – Color which is used to draw the nodes

  • nodemarker (matplotlib marker, optional) – Marker which is used to draw the nodes

  • nodesize (float, optional) – Marker size for the nodes

  • beamcolor (matplotlib color, optional) – Color which is used to draw the lines

  • beamstyle (matplotlib linestyle, optional) – Linestyle which is used to draw the lines

  • linewidth (float, optional) – Line width which is used to draw the lines

  • callback_fun (function, optional) – A function that is executed upon changing to a new mode, allows to print mode information or change some other behaviour of the class. It takes the class itself and the mode index as its parameters.

  • fig (matplotlib.figure.Figure, optional) – A matplotlib figure created externally to draw the mode shapes, if an external GUI is used.

Methods

__init__(geometry_data[, stabil_calc, ...])

Initializes the class object and automatically checks, which of the below use cases have to be considered

add_chan_dof(chan, node, az, elev, chan_name, i)

Draws an arrow indicating a channel-DOF assignment.

add_cn_line(i)

Draws a line between the displaced and the undisplaced node.

add_line(line, i)

Add a line by adding the start node and end node to the internal line table and draws that line between the two nodes.

add_nd_line(line, i)

Add a non-displaced line, which acts as a mesh-reference for the displaced lines.

add_node(x, y, z, i)

Adds a node to the internal node table and initializes zero-value displacements for this node to the internal displacements table.

add_parent_child(i_m, x_m, y_m, z_m, i_sl, ...)

Takes parent-child definitions and adds these definitions to the internal parent-child table.

animate()

Create necessary objects to animate the currently displayed deformed structure.

change_amplitude([amplitude])

Changes the amplitude of the mode shape, and redraws the modeshapes based on this amplitude.

change_mode([frequency, index, mode_index])

If the user selects a new mode: plots the mode shape and returns modal values e.g. to a GUI caller.

change_part(b)

Change, which part of the complex number modeshapes should be drawn and redraw the modeshapes

change_viewport([viewport])

Change the viewport e.g. azimuth and elevation and refresh the canvas.

draw_axis()

Draw the axis arrows.

draw_chan_dofs()

Draw arrows and numbers for all channel-DOF assignments stored in the channel - DOF assignment table of PreProcessingTools.GeometrProcessor

draw_lines()

Draws all line from the line list of PreProcessingTools.GeometryProcessor The currently stored displacement values are used for moving the nodes.

draw_msh()

Draw mode shapes by assigning displacement values to the nodes based on the channel - DOF assignments and the parent - child definitions.

draw_nodes()

draw_parent_childs()

Draw arrows for all parent-child definitions stored in the internal parent-child definition table.

filter_and_animate_data([callback])

Animate the acquired vibration data to check the real vibration displacement of the structure against the identified modes.

get_frequencies()

refresh_axis([visible])

Refresh the axis arrows and make them visible/invisible, e.g. after programmatically changing visibility flags.

refresh_chan_dofs([visible])

Refresh the arrows indicating the channel-dof assignments and make them visible/invisible, e.g. after programmatically changing visibility flags.

refresh_cn_lines([visible])

Refresh the connecting lines and make them visible/invisible, e.g. after programmatically changing visibility flags.

refresh_lines([visible])

Refresh the lines and make them visible/invisible, e.g. after programmatically changing visibility flags.

refresh_nd_lines([visible])

Refresh the non-displaced lines and make them visible/invisible, e.g. after programmatically changing visibility flags.

refresh_nodes([visible])

Refresh the nodes and make them visible/invisible, e.g. after programmatically changing visibility flags.

refresh_parent_childs([visible])

Refresh the parent-child arrows and make them visible/invisible, e.g. after programmatically changing visibility flags.

reset_view()

save_plot([path])

Save the curently displayed frame as a graphics file

set_equal_aspect()

stop_ani()

Convenience method to stop the animation and restore the still plot

take_chan_dof(chan, node, dof)

Remove the arrow and text objects associated with the channel - DOF assignment.

take_line(line)

Remove a line between to nodes.

take_node(x, y, z, node)

Remove a node at given coordinates and all objects connected to this node first (there should not be any).

take_parent_child(i_m, x_m, y_m, z_m, i_sl, ...)

Remove the two arrows associated with the parent-child definition.

Attributes

merged_data

identify which merging routine has been used ensure all required objects were provided warn if unneeded objects were provided extract needed parameters

add_chan_dof(chan, node, az, elev, chan_name, i)[source]#

Draws an arrow indicating a channel-DOF assignment. Annotates the arrow with the the channel name. Stores the two plot objects in a table and removes any objects that might be in the table at the desired index i.e. avoid duplicate arrows/texts.

Parameters:
  • chan (integer) – Index of the channel.

  • node (integer) – Index of the node in the internal node table

  • az (float) – Azimuth and elevation of the DOF assignment

  • elev (float) – Azimuth and elevation of the DOF assignment

  • chan_name (str) – Name of the channel to annotate

  • i (integer) – Table index for the plot objects.

Todo

  • arrow lengths do not scale with the total dimension of the plot

add_cn_line(i)[source]#

Draws a line between the displaced and the undisplaced node.

Parameters:

i (integer) – Index of the node

add_line(line, i)[source]#

Add a line by adding the start node and end node to the internal line table and draws that line between the two nodes. Stores the line object in a table and removes any objects that might be in the table at the desired place, i.e. avoid duplicate lines

Parameters:
  • line (2-tuple of integer) – The indices of the start- and end-node of the line

  • i (integer) – Index of the line, must be previously determined

add_nd_line(line, i)[source]#

Add a non-displaced line, which acts as a mesh-reference for the displaced lines. Works analogously to self.add_line

Parameters:
  • line (2-tuple of integer) – The indices of the start- and end-node of the line

  • i (integer) – Index of the line, must be previously determined

add_node(x, y, z, i)[source]#

Adds a node to the internal node table and initializes zero-value displacements for this node to the internal displacements table. Draws a single point at the coordinates and annotates it with its number. Stores the two plot objects in a table and removes any objects that might be in the table at the desired place to avoid duplicate nodes.

Parameters:
  • x (float) – 3D-coordinates of the node

  • y (float) – 3D-coordinates of the node

  • z (float) – 3D-coordinates of the node

  • i (integer) – Index of the node, must be previously determined

add_parent_child(i_m, x_m, y_m, z_m, i_sl, x_sl, y_sl, z_sl, i)[source]#

Takes parent-child definitions and adds these definitions to the internal parent-child table. Draws an arrow indicating the DOF at each node of parent and child. Arrows at equal positions and direction will be offset to avoid overlapping. Stores the two arrow objects in a table and removes any objects that might be in the table at the desired index i.e. avoid duplicate arrows

Parameters:
  • i_m (integer) – Index of the parent node

  • x_m (float) – Scale factor for each parent DOF.

  • y_m (float) – Scale factor for each parent DOF.

  • z_m (float) – Scale factor for each parent DOF.

  • i_sl (integer) – Index of the child node

  • x_sl (float) – Scale factor for each child DOF.

  • y_sl (float) – Scale factor for each child DOF.

  • z_sl (float) – Scale factor for each child DOF.

animate()[source]#

Create necessary objects to animate the currently displayed deformed structure.

If self.save_ani_path is given, the animation will be saved to that folder. The numbering of the files follows the order in which the modes were selected in the stabilization diagram.

change_amplitude(amplitude=None)[source]#

Changes the amplitude of the mode shape, and redraws the modeshapes based on this amplitude.

Parameters:

amplitude (float, optional)

change_mode(frequency=None, index=None, mode_index=None)[source]#

If the user selects a new mode: plots the mode shape and returns modal values e.g. to a GUI caller.

Parameters:
  • frequency (float,optional) – A search for the closest frequency in the list of already selected indices (self.selected_indices) is performed

  • index (integer, optional) – Alternatively, the index of the wanted mode can be directly given

  • mode_index (integer, optional) – The number of the mode in the list of currently selected modes

Returns:

  • order_index (integer) – Model order of the selected mode

  • mode_index (integer) – Index of the selected mode at model order

  • frequency (float) – natural frequency of the selected mode

  • damping (float) – damping ratio of the selected mode

  • MPC (float, optional) – Modal phase colinearity of the selected mode, if available from an instance of StabilDiagram.StabilCalc1

  • MP (float, optional) – Mean phase of the selected mode, if available from an instance of StabilDiagram.StabilCalc1

  • MPD (float, optional) – Mean phase deviation of the selected mode, if available from an instance of StabilDiagram.StabilCalc1

change_part(b)[source]#

Change, which part of the complex number modeshapes should be drawn and redraw the modeshapes

Parameters:

b (bool) – If b, draws the magnitude of the modal coordinated, else phase information is considered. Default: b = False

change_viewport(viewport=None)[source]#

Change the viewport e.g. azimuth and elevation and refresh the canvas

Parameters:

viewport ({'X', 'Y', 'Z', 'ISO', optional) – The viewport to set.

draw_axis()[source]#

Draw the axis arrows. Length is based on the current data limits. Removes the current arrows if the exist.

draw_chan_dofs()[source]#

Draw arrows and numbers for all channel-DOF assignments stored in the channel - DOF assignment table of PreProcessingTools.GeometrProcessor

draw_lines()[source]#

Draws all line from the line list of PreProcessingTools.GeometryProcessor The currently stored displacement values are used for moving the nodes.

draw_msh()[source]#

Draw mode shapes by assigning displacement values to the nodes based on the channel - DOF assignments and the parent - child definitions. Draws the displaced nodes and beams.

Todo

  • The computation of resulting magnitude and phase angles for displacements based on parent-child definitions is currently more or less broken. It should be possible, even in 3D to compute exact solutions.

draw_nodes()[source]#

‘ Draws nodes from the node list of PreProcessingTools.GeometryData The currently stored displacement values are used for moving the nodes.

draw_parent_childs()[source]#

Draw arrows for all parent-child definitions stored in the internal parent-child definition table.

filter_and_animate_data(callback=None)[source]#

Animate the acquired vibration data to check the real vibration displacement of the structure against the identified modes.

get_frequencies()[source]#
Returns:

frequencies – Identified frequencies of all currently selected modes.

Return type:

list

merged_data#

identify which merging routine has been used ensure all required objects were provided warn if unneeded objects were provided extract needed parameters

refresh_axis(visible=None)[source]#

Refresh the axis arrows and make them visible/invisible, e.g. after programmatically changing visibility flags.

Parameters:

visible (bool, ooptional) – Visibility flag for the axis arrows

refresh_chan_dofs(visible=None)[source]#

Refresh the arrows indicating the channel-dof assignments and make them visible/invisible, e.g. after programmatically changing visibility flags.

Will not be shown in displaced mode (modeshape)

Parameters:

visible (bool, ooptional) – Visibility flag for the channel-dof assignment arrows

refresh_cn_lines(visible=None)[source]#

Refresh the connecting lines and make them visible/invisible, e.g. after programmatically changing visibility flags.

Parameters:

visible (bool, ooptional) – Visibility flag for the non-displaced lines

refresh_lines(visible=None)[source]#

Refresh the lines and make them visible/invisible, e.g. after programmatically changing visibility flags.

Parameters:

visible (bool, ooptional) – Visibility flag for the lines

refresh_nd_lines(visible=None)[source]#

Refresh the non-displaced lines and make them visible/invisible, e.g. after programmatically changing visibility flags.

Parameters:

visible (bool, ooptional) – Visibility flag for the non-displaced lines

refresh_nodes(visible=None)[source]#

Refresh the nodes and make them visible/invisible, e.g. after programmatically changing visibility flags.

Parameters:

visible (bool, ooptional) – Visibility flag for the nodes

refresh_parent_childs(visible=None)[source]#

Refresh the parent-child arrows and make them visible/invisible, e.g. after programmatically changing visibility flags.

Will not be shown in displaced mode (modeshape)

Parameters:

visible (bool, ooptional) – Visibility flag for the parent-child arrows

reset_view()[source]#
  • restore viewport

  • restore axis’ limits

  • reset displacements values for all nodes

save_plot(path=None)[source]#

Save the curently displayed frame as a graphics file

Parameters:

path (str (valid filepath), optional) – The full path, including the extension, where to save the graphic.

stop_ani()[source]#

Convenience method to stop the animation and restore the still plot

take_chan_dof(chan, node, dof)[source]#

Remove the arrow and text objects associated with the channel - DOF assignment.

Parameters:
  • chan (integer) – Index of the channel.

  • node (integer) – Index of the node in the internal node table

  • dof (3-tuple {az,elev,chan_name}) –

    az, elev: float

    Azimuth and elevation of the DOF assignment

    chan_name: str

    Name of the channel to annotate

take_line(line)[source]#

Remove a line between to nodes. If the plot objects are already in their displaced state, the comparison between the actual coordinates and these objects have to account for displacement by comparing to an interval of coordinates. Remove the non-displaced lines, too.

Parameters:

line (2-tuple of integers) – Tuple containg the indices of the start- and end-nodes

take_node(x, y, z, node)[source]#

Remove a node at given coordinates and all objects connected to this node first (there should not be any). Remove the patch objects from the plot and remove the coordinates from the node and displacement tables.

Parameters:
  • x (float) – Coordinates of the node

  • y (float) – Coordinates of the node

  • z (float) – Coordinates of the node

  • node (integer) – Index of the node

Todo

  • Function presumably breaks in the second for loop, because geometry_data and the internal tables become out of sync.

take_parent_child(i_m, x_m, y_m, z_m, i_sl, x_sl, y_sl, z_sl)[source]#

Remove the two arrows associated with the parent-child definition.

Parameters:
  • i_m (integer) – Index of the parent node

  • x_m (float) – Scale factor for each parent DOF.

  • y_m (float) – Scale factor for each parent DOF.

  • z_m (float) – Scale factor for each parent DOF.

  • i_sl (integer) – Index of the child node

  • x_sl (float) – Scale factor for each child DOF.

  • y_sl (float) – Scale factor for each child DOF.

  • z_sl (float) – Scale factor for each child DOF.