https://github.com/ethanjameslew/koopmania
a little library to help me with things involving Koopman operators
https://github.com/ethanjameslew/koopmania
data-driven-model dmd dynamic-mode-decomposition dynamical-systems kernel-methods koopman koopman-operators
Last synced: 4 months ago
JSON representation
a little library to help me with things involving Koopman operators
- Host: GitHub
- URL: https://github.com/ethanjameslew/koopmania
- Owner: EthanJamesLew
- License: bsd-3-clause
- Created: 2021-10-19T15:31:09.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-03T06:06:47.000Z (over 3 years ago)
- Last Synced: 2023-03-04T05:23:33.318Z (over 2 years ago)
- Topics: data-driven-model, dmd, dynamic-mode-decomposition, dynamical-systems, kernel-methods, koopman, koopman-operators
- Language: Python
- Homepage:
- Size: 168 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Koopmania: Library for Koopman Operator Based Data-Driven Analysis

This is a (work in progress) little library to help me with research involving Koopman
operators. It features
* Estimators - scikit-like estimators to fit systems from data. These can be
continuous or discrete time systems.
* Observables - a way of creating Koopman observables easily. These can be
specified symbolically or numerically.## Example Usage
### Create Systems
Create systems from symbolic equations
```python
import koopmania as km
import sympy as sp# van der pol model
x0, x1 = sp.symbols('x0 x1')
xdot = [x1, (1 - x0**2) * x1 - x0]my_system = km.SymbolicContinuousSystem((x0, x1), xdot)
```### Create Observables
```python
import koopmania as km
import sympy as sp# create observables from symbolic expressions
x0, x1 = sp.symbols('x0 x1')
observable_map = [sp.cos(0.5*x0 + 0.2*x1), sp.sin(x1)]
my_obs = km.SymbolicObservable((x0, x1), observable_map)# use existing observables
q_obs = km.QuadraticObservable(2)# combine observables together
obs = my_obs | q_obs
```### Learn Systems from Data
```python
import koopmania as km# learn a system from trajectory data X, Xn
obs = km.QuadraticObservable(2)
est = km.KoopmanSystemEstimator(obs, sampling_period=0.1)
est.fit(X, Xn)# my learned system
est.system# predict the next state (after one sampling period)
est.predict(initial_value)
```### Visualize Systems
```python
import koopmania.visualizer as kviz
import matplotlib.pyplot as plt# show vector field
fig, ax = plt.subplots()
viewer = kviz.SystemViewer(system)
viewer.plot_quiver(ax)
plt.show()
```