Skip to content

Commit

Permalink
Merge pull request PyDMD#36 from ndem0/fix
Browse files Browse the repository at this point in the history
Add figsize parameter, fix bug
  • Loading branch information
ndem0 committed Nov 8, 2017
2 parents 369521d + 11e9350 commit 43b03ba
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions pydmd/dmdbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def __init__(self, svd_rank=0, tlsq_rank=0, exact=False):
@property
def dmd_timesteps(self):
"""
numpy.ndarray: the time intervals of the reconstructed system.
Get the timesteps of the reconstructed states.
:return: the time intervals of the original snapshots.
:rtype: numpy.ndarray
"""
return np.arange(
self.dmd_time['t0'], self.dmd_time['tend'] + self.dmd_time['dt'],
Expand Down Expand Up @@ -96,7 +99,8 @@ def eigs(self):
"""
Get the eigenvalues of A tilde.
:return: self._eigs: the eigenvalues from the eigendecomposition of `atilde`.
:return: self._eigs: the eigenvalues from the eigendecomposition of
`atilde`.
:rtype: numpy.ndarray
"""
return self._eigs
Expand Down Expand Up @@ -303,7 +307,13 @@ def plot_eigs(
plt.show()

def plot_modes_2D(
self, index_mode=None, filename=None, x=None, y=None, order='C'
self,
index_mode=None,
filename=None,
x=None,
y=None,
order='C',
figsize=(8, 8)
):
"""
Plot the DMD Modes.
Expand Down Expand Up @@ -360,7 +370,7 @@ def plot_modes_2D(
basename, ext = os.path.splitext(filename)

for idx in index_mode:
fig = plt.figure()
fig = plt.figure(figsize=figsize)
fig.suptitle('DMD Mode {}'.format(idx))

real_ax = fig.add_subplot(1, 2, 1)
Expand Down Expand Up @@ -404,13 +414,19 @@ def plot_modes_2D(
plt.show()

def plot_snapshots_2D(
self, index_snap=None, filename=None, x=None, y=None, order='C'
self,
index_snap=None,
filename=None,
x=None,
y=None,
order='C',
figsize=(8, 8)
):
"""
Plot the snapshots.
:param snapshots int or sequence of int: the index of the modes to
plot. By default, all the modes are plotted.
:param snapshots int or sequence of int: the index of the snapshots to
plot. By default, all the snapshots are plotted.
:param filename str: filename
:param x numpy.ndarray: domain abscissa
:param y numpy.ndarray: domain ordinate
Expand Down Expand Up @@ -452,15 +468,15 @@ def plot_snapshots_2D(
snapshots = np.append(self._X, self._Y[:, -1].reshape(-1, 1), axis=1)

if index_snap is None:
index_snap = list(range(self._modes.shape[1]))
index_snap = list(range(snapshots.shape[1]))
elif isinstance(index_snap, int):
index_snap = [index_snap]

if filename:
basename, ext = os.path.splitext(filename)

for idx in index_snap:
fig = plt.figure()
fig = plt.figure(figsize=figsize)
fig.suptitle('Snapshot {}'.format(idx))

snapshot = snapshots.T[idx].real.reshape(xgrid.shape, order=order)
Expand Down

0 comments on commit 43b03ba

Please sign in to comment.