Package: pykoopman
PyKoopmanis a Python package for computing data-driven approximations to the Koopman operator.Data-driven approximation of Koopman operatorGiven a nonlinear dynamical system,\begin{equation*}
x'(t) = f(x(t)),
\end{equation*}the Koopman operator governs the temporal evolution of the measurement function.
Unfortunately, it is an infinite-dimensional linear operator. Most of the time, one has to
project the Koopman operator onto a finite-dimensional subspace that is spanned by user-defined/data-adaptive functions.\begin{equation*}
z = \Phi(x).
\end{equation*}If the system state is also contained in such subspace, then effectively, the nonlinear dynamical system is (approximately)
linearized in a global sense.The goal of data-driven approximation of Koopman operator is to find such a set of
functions that span such lifted space and the transition matrix associated with the
lifted system.Structure of PyKoopmanPyKoopman package is centered around theKoopmanclass andKoopmanContinuousclass. It consists of two key componentsobservables: a set of observables functions, which spans the subspace for projection.regressor: the optimization algorithm to find the bestfitfor the
projection of Koopman operator.AfterKoopman/KoopmanContinuousobject has been created, it must be fit to data, similar to ascikit-learnmodel.
We designPyKoopmansuch that it is compatible toscikit-learnobjects and methods as much as possible.Features implementedObservable library for lifting the state into the observable spaceIdentity (for DMD/DMDc or in case users want to compute observables themselves):IdentityMultivariate polynomials:PolynomialTime delay coordinates:TimeDelayRadial basis functions:RadialBasisFunctionsRandom Fourier features:RandomFourierFeaturesCustom library (defined by user-supplied functions):CustomObservablesConcatenation of observables:ConcatObservablesSystem identification method for performing regressionDynamic mode decomposition:PyDMDRegressorDynamic mode decomposition with control:DMDcExtended dynamic mode decomposition:EDMDExtended dynamic mode decomposition with control:EDMDcKernel dynamic mode decomposition:KDMDHankel Alternative View of Koopman Analysis:HAVOKNeural Network DMD:NNDMDSparse construction of Koopman invariant subspaceMulti-task learning based on linearity consistencyExamples1.Learning how to create observables2.Learning how to compute time derivatives3.Dynamic mode decomposition on two mixed spatial signals4.Dynamic mode decomposition with control on a 2D linear system5.Dynamic mode decomposition with control (DMDc) for a 128D system6.Dynamic mode decomposition with control on a high-dimensional linear system7.Successful examples of using Dynamic mode decomposition on PDE system8.Unsuccessful examples of using Dynamic mode decomposition on PDE system9.Extended DMD for Van Der Pol System10.Learning Koopman eigenfunctions on Slow manifold11.Comparing DMD and KDMD for Slow manifold dynamics12.Extended DMD with control for chaotic duffing oscillator13.Extended DMD with control for Van der Pol oscillator14.Hankel Alternative View of Koopman Operator for Lorenz System15.Hankel DMD with control for Van der Pol Oscillator16.Neural Network DMD on Slow Manifold17.EDMD and NNDMD for a simple linear system18.Sparisfying a minimal Koopman invariant subspace from EDMD for a simple linear
systemInstallationLanguagePython == 3.10Installing with pipIf you are using Linux or macOS you can install PyKoopman with pip:pipinstallpykoopmanInstalling from sourceFirst clone this repository:gitclonehttps://github.com/dynamicslab/pykoopmanSecond, it is highly recommended to usevenvto get a local python environmentpython-mvenvvenvsource./venv/bin/activateIn windows, you activate virtual environment in a different way.\venv\Scripts\activate.ps1Then, to install the package, runpython-mpipinstall-e.If you do not have root access, you should add the--useroption to the above lines.Installing with GPU supportAfter you download the Github package, go to the directory, typepython-mpipinstall-rrequirements-dev.txtDocumentationThe documentation for PyKoopman is hosted onRead the Docs.Community guidelinesContributing codeWe welcome contributions to PyKoopman. To contribute a new feature please submit a
pull request. To get started we recommend installing the packages in “developer mode”
viapython-mpipinstall-e.[dev]This will allow you to run unit tests and automatically format your code. To be accepted your code should conform to PEP8 and pass all unit tests. Code can be tested by invokingpytestWe recommed usingpre-committo format your code. Once you have staged changes to commitgitaddpath/to/changed/file.pyyou can run the following to automatically reformat your staged codepre-commit-a-vNote that you will then need to re-stage any changespre-commitmade to your code.Reporting issues or bugsIf you find a bug in the code or want to request a new feature, please open an issue.Known issues:Python 3.12 might cause unexpected problems.Citing PyKoopman@misc{pan2023pykoopman,
      title={PyKoopman: A Python Package for Data-Driven Approximation of the Koopman Operator},
      author={Shaowu Pan and Eurika Kaiser and Brian M. de Silva and J. Nathan Kutz and Steven L. Brunton},
      year={2023},
      eprint={2306.12962},
      archivePrefix={arXiv},
      primaryClass={eess.SY}
}Related packagesPySINDy- A Python libray for the Sparse Identification of Nonlinear Dynamical
systems (SINDy) method introduced in Brunton et al. (2016a).Deeptime- A Python library for the analysis of time series data with methods for dimension reduction, clustering, and Markov model estimation.PyDMD- A Python package using the Dynamic Mode Decomposition (DMD) for a data-driven model simplification based on spatiotemporal coherent structures. DMD is a great alternative to SINDy.pykoop- a Koopman operator identification library written in PythonDLKoopman- a deep learning library for
Koopman operator