Skip to content

Commit 19a7586

Browse files
authored
Added quickstart guide
1 parent 960a620 commit 19a7586

File tree

1 file changed

+50
-27
lines changed

1 file changed

+50
-27
lines changed

README.md

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
## Table of contents
4848
* [Description](#description)
4949
* [Dependencies and installation](#dependencies-and-installation)
50+
* [Quickstart guide](#quickstart-guide)
5051
* [Examples and Tutorials](#examples-and-tutorials)
51-
* [Using PyDMD](#using-pydmd)
5252
* [Awards](#awards)
5353
* [References](#references)
5454
* [Developers and contributors](#developers-and-contributors)
@@ -91,6 +91,54 @@ and then install the package in [development mode](https://setuptools.pypa.io/en
9191
### Dependencies
9292
The core features of **PyDMD** depend on `numpy` and `scipy`. In order to use the plotting functionalities you will also need `matplotlib`.
9393

94+
## Quickstart Guide
95+
To perform DMD, simply begin by initializing a PyDMD module that implements your DMD method of choice. Models may then be fitted by calling the `fit()` method and passing in the necessary data. This step performs the DMD algorithm, after which users may use PyDMD plotting tools in order to visualize their results.
96+
97+
```python3
98+
from pydmd import DMD
99+
from pydmd.plotter import plot_summary
100+
101+
# Build an exact DMD model with 15 spatiotemporal modes.
102+
dmd = DMD(svd_rank=15)
103+
104+
# Fit the DMD model.
105+
# X = (n, m) numpy array of time-varying snapshot data.
106+
dmd.fit(X)
107+
108+
# Plot a summary of the key spatiotemporal modes.
109+
plot_summary(dmd)
110+
```
111+
112+
PyDMD modules can also be wrapped with data preprocessors if desired. These wrappers will preprocess the data and postprocess data reconstructions automatically.
113+
```python3
114+
from pydmd.preprocessing import zero_mean_preprocessing
115+
116+
# Build and fit an exact DMD model with data centering.
117+
centered_dmd = zero_mean_preprocessing(DMD(svd_rank=15))
118+
centered_dmd.fit(X)
119+
```
120+
121+
Users may also build highly complex DMD models with PyDMD. Below is an example of how one might build and fit a customized Optimized DMD model with bagging, eigenvalue constraints, and custom variable projection arguments.
122+
```python3
123+
from pydmd import BOPDMD
124+
125+
# Build a bagging, optimized DMD (BOP-DMD) model.
126+
bopdmd = BOPDMD(
127+
svd_rank=15, # Rank of the DMD fit.
128+
num_trials=100, # Number of bagging trials to perform.
129+
trial_size=0.5, # Use 50% of the total number of snapshots per trial.
130+
eig_constraints={"imag", "conjugate_pairs"}, # Eigenvalues must be imaginary and conjugate pairs.
131+
varpro_opts_dict={"tol":0.2, "verbose":True}, # Set convergence tolerance and use verbose updates.
132+
)
133+
134+
# Fit the BOP-DMD model.
135+
# X = (n, m) numpy array of time-varying snapshot data
136+
# t = (m,) numpy array of times of data collection
137+
bopdmd.fit(X, t)
138+
```
139+
140+
Note that modules and functions may be parameterized by a variety of inputs for added customization, so we generally recommend that new users refer to our [module documentation](https://pydmd.github.io/PyDMD/code.html), [plotting tool documentation](https://pydmd.github.io/PyDMD/plotter.html), and to our module-specific [tutorials](tutorials/README.md) for more information.
141+
94142
## Examples and Tutorials
95143
You can find useful tutorials on how to use the package in the [tutorials](tutorials/README.md) folder.
96144

@@ -105,31 +153,6 @@ Here we show a simple application (taken from [tutorial 2](tutorials/tutorial2/t
105153
<em>The system evolution reconstructed with dynamic mode decomposition</em>
106154
</p>
107155

108-
## Using PyDMD
109-
To perform DMD, simply begin by initializing a PyDMD module that implements your DMD method of choice. Here, we demonstrate how a user might build a customized BOP-DMD model. Models may then be fitted by calling the `fit()` method and passing in the necessary data. This step performs the DMD algorithm, after which users may use PyDMD plotting tools in order to visualize their results.
110-
```python3
111-
from pydmd import BOPDMD
112-
from pydmd.plotter import plot_summary
113-
114-
# Build a bagging, optimized DMD (BOP-DMD) model.
115-
dmd = BOPDMD(
116-
svd_rank=15, # rank of the DMD fit
117-
num_trials=100, # number of bagging trials to perform
118-
trial_size=0.5, # use 50% of the total number of snapshots per trial
119-
eig_constraints={"imag", "conjugate_pairs"}, # constrain the eigenvalue structure
120-
varpro_opts_dict={"tol":0.2, "verbose":True}, # set variable projection parameters
121-
)
122-
123-
# Fit the DMD model.
124-
# X = (n, m) numpy array of time-varying snapshot data
125-
# t = (m,) numpy array of times of data collection
126-
dmd.fit(X, t)
127-
128-
# Display a summary of the DMD results.
129-
plot_summary(dmd)
130-
```
131-
Note that modules and functions may be parameterized by a variety of inputs for added customization, so we generally recommend that new users refer to module documentation, plotting tool documentation, and to our module-specific [tutorials](tutorials/README.md) for more information.
132-
133156
For users who are unsure of which DMD method is best for them, we provide the following flow chart, which outlines how one might choose an appropriate DMD variant based on specific problem types or data sets.
134157

135158
<p align="center">
@@ -214,4 +237,4 @@ Beyond this, PyDMD has also been supported by some dedicated projects that have
214237
<a href="https://numfocus.org/sponsored-projects/affiliated-projects">
215238
<img src="readme/numfocus-affiliated-project.png" width="300" />
216239
</a>
217-
</p>
240+
</p>

0 commit comments

Comments
 (0)