Plotter

Module for DMD plotting.

_enforce_ratio(goal_ratio, supx, infx, supy, infy)[source]

Computes the right value of supx,infx,supy,infy to obtain the desired ratio in plot_eigs(). Ratio is defined as

dx = supx - infx
dy = supy - infy
max(dx,dy) / min(dx,dy)
Parameters
  • goal_ratio (float) – the desired ratio.

  • supx (float) – the old value of supx, to be adjusted.

  • infx (float) – the old value of infx, to be adjusted.

  • supy (float) – the old value of supy, to be adjusted.

  • infy (float) – the old value of infy, to be adjusted.

Return tuple

a tuple which contains the updated values of supx,infx,supy,infy in this order.

_plot_limits(dmd, narrow_view)[source]
plot_eigs(dmd, show_axes=True, show_unit_circle=True, figsize=(8, 8), title='', narrow_view=False, dpi=None, filename=None)[source]

Plot the eigenvalues.

Parameters
  • dmd (pydmd.DMDBase) – DMD instance.

  • show_axes (bool) – if True, the axes will be showed in the plot. Default is True.

  • show_unit_circle (bool) – if True, the circle with unitary radius and center in the origin will be showed. Default is True.

  • figsize (tuple(int,int)) – tuple in inches defining the figure size. Default is (8, 8).

  • title (str) – title of the plot.

  • bool (narrow_view) – if True, the plot will show only the smallest rectangular area which contains all the eigenvalues, with a padding of 0.05. Not compatible with show_axes=True. Default is False.

  • int (dpi) – If not None, the given value is passed to plt.figure.

  • filename (str) – if specified, the plot is saved at filename.

plot_eigs_mrdmd(dmd, show_axes=True, show_unit_circle=True, figsize=(8, 8), title='', level=None, node=None, filename=None)[source]

Plot the eigenvalues.

Parameters
  • show_axes (bool) – if True, the axes will be showed in the plot. Default is True.

  • show_unit_circle (bool) – if True, the circle with unitary radius and center in the origin will be showed. Default is True.

  • figsize (tuple(int,int)) – tuple in inches of the figure.

  • title (str) – title of the plot.

  • level (int) – plot only the eigenvalues of specific level.

  • node (int) – plot only the eigenvalues of specific node.

  • filename (str) – if specified, the plot is saved at filename.

plot_modes_2D(dmd, snapshots_shape=None, index_mode=None, filename=None, x=None, y=None, order='C', figsize=(8, 8))[source]

Plot the DMD Modes.

Parameters
  • dmd (pydmd.DMDBase) – DMD instance.

  • snapshots_shape – Shape of the snapshots.

  • index_mode (int or sequence(int)) – the index of the modes to plot. By default, all the modes are plotted.

  • filename (str) – if specified, the plot is saved at filename.

  • x (numpy.ndarray) – domain abscissa.

  • y (numpy.ndarray) – domain ordinate

  • order ({'C', 'F', 'A'}, default 'C'.) – read the elements of snapshots using this index order, and place the elements into the reshaped array using this index order. It has to be the same used to store the snapshot. ‘C’ means to read/ write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to read / write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest. Note that the ‘C’ and ‘F’ options take no account of the memory layout of the underlying array, and only refer to the order of indexing. ‘A’ means to read / write the elements in Fortran-like index order if a is Fortran contiguous in memory, C-like order otherwise.

  • figsize (tuple(int,int)) – tuple in inches defining the figure size. Default is (8, 8).

plot_snapshots_2D(dmd, snapshots_shape=None, index_snap=None, filename=None, x=None, y=None, order='C', figsize=(8, 8))[source]

Plot the snapshots.

Parameters
  • dmd (pydmd.DMDBase) – DMD instance.

  • snapshots_shape – Shape of the snapshots.

  • index_snap (int or sequence(int)) – the index of the snapshots to plot. By default, all the snapshots are plotted.

  • filename (str) – if specified, the plot is saved at filename.

  • x (numpy.ndarray) – domain abscissa.

  • y (numpy.ndarray) – domain ordinate

  • order ({'C', 'F', 'A'}, default 'C'.) – read the elements of snapshots using this index order, and place the elements into the reshaped array using this index order. It has to be the same used to store the snapshot. ‘C’ means to read/ write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to read / write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest. Note that the ‘C’ and ‘F’ options take no account of the memory layout of the underlying array, and only refer to the order of indexing. ‘A’ means to read / write the elements in Fortran-like index order if a is Fortran contiguous in memory, C-like order otherwise.

  • figsize (tuple(int,int)) – tuple in inches defining the figure size. Default is (8, 8).

plot_summary(dmd, *, x=None, y=None, t=None, d=1, continuous=False, snapshots_shape=None, index_modes=(0, 1, 2), filename=None, order='C', figsize=(12, 8), dpi=200, tight_layout_kwargs=None, main_colors=('r', 'b', 'g'), mode_color='k', mode_cmap='bwr', dynamics_color='tab:blue', rank_color='tab:orange', circle_color='tab:blue', sval_ms=8, max_eig_ms=10, max_sval_plot=50, title_fontsize=14, label_fontsize=12, plot_semilogy=False, flip_continuous_axes=False)[source]

Generate a 3 x 3 summarizing plot that contains the following components: - the singular value spectrum of the data - the discrete-time and continuous-time DMD eigenvalues - the DMD modes specified by the index_modes parameter - the time dynamics that correspond with each plotted mode The number of singular values used for the DMD fit are highlighted. All eigenvalues, modes, and dynamics are sorted according to the magnitude of their corresponding amplitude value, i.e. their significance in the fit. Correspondence between eigenvalues, modes, and dynamics is indicated via color coordination.

Parameters
  • dmd (pydmd.DMDBase) – fitted DMD instance.

  • x (np.ndarray or iterable) – Points along the 1st spatial dimension where data has been collected.

  • y (np.ndarray or iterable) – Points along the 2nd spatial dimension where data has been collected. Note that this parameter is only applicable when the data snapshots are 2-D, which must be indicated with snapshots_shape.

  • t ({numpy.ndarray, iterable} or {int, float}) – The times of data collection, or the time-step between snapshots. Note that time information must be accurate in order to accurately visualize eigenvalues and times of the dynamics. For non-BOPDMD models, the entries of t are assumed to be uniformly-spaced, and if not provided, TimeDict information is used. This parameter is ignored if an instance of BOPDMD is provided.

  • d (int) – Number of delays applied to the data passed to the DMD instance. If d is greater than 1, then each plotted mode will be the average mode taken across all d delays.

  • continuous (bool) – Whether or not the eigenvalues of the given DMD instance are continuous-time. If False, the eigenvalues are assumed to be the discrete-time eigenvalues. If True, the eigenvalues are taken to be the continuous-time eigenvalues. Note that continuous is automatically assumed to be True if a BOPDMD model is given.

  • snapshots_shape (iterable) – Shape of the snapshots. If not provided, the shape of the snapshots and modes is assumed to be the flattened space dim of the snapshot data. Provide as width, height dimension.

  • index_modes (iterable) – Indices of the modes to plot after they have been sorted based on significance. At most three may be provided. By default, the first three leading modes are plotted.

  • filename (str) – If specified, the plot is saved at filename.

  • order ({"C", "F", "A"}) – Read the elements of snapshots using this index order, and place the elements into the reshaped array using this index order. It has to be the same used to store the snapshot. “C” means to read/write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. “F” means to read/write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest. Note that the “C” and “F” options take no account of the memory layout of the underlying array, and only refer to the order of indexing. “A” means to read/write the elements in Fortran-like index order if a is Fortran contiguous in memory, C-like order otherwise. “C” is used by default.

  • figsize (iterable) – Width, height in inches.

  • dpi (int) – Figure resolution.

  • tight_layout_kwargs (dict) – Dictionary of tight_layout parameters.

  • main_colors (iterable) – Colors used to denote eigenvalue, mode, dynamics associations.

  • mode_color (str) – Color used to plot the modes, if modes are 1-D.

  • mode_cmap (str) – Colormap used to plot the modes, if modes are 2-D.

  • dynamics_color (str) – Color used to plot the dynamics.

  • rank_color (str) – Color used to highlight the rank of the DMD fit and all DMD eigenvalues aside from those highlighted by index_modes.

  • circle_color (str) – Color used to plot the unit circle.

  • sval_ms (int) – Marker size of all singular values.

  • max_eig_ms (int) – Marker size of the most prominent eigenvalue. The marker sizes of all other eigenvalues are then scaled according to eigenvalue significance.

  • max_sval_plot (int) – Maximum number of singular values to plot.

  • title_fontsize (int) – Fontsize used for subplot titles.

  • label_fontsize (int) – Fontsize used for axis labels.

  • plot_semilogy (bool) – Whether or not to plot the singular values on a semilogy plot. If True, a semilogy plot is used.

  • flip_continuous_axes (bool) – Whether or not to swap the real and imaginary axes on the continuous eigenvalues plot. If True, the real axis will be vertical and the imaginary axis will be horizontal, and vice versa.