{"id":37072582,"url":"https://github.com/haozhg/odmd","last_synced_at":"2026-01-14T08:31:28.192Z","repository":{"id":54387204,"uuid":"88785731","full_name":"haozhg/odmd","owner":"haozhg","description":"AI4Science: Python/Matlab implementation of online and window dynamic mode decomposition (Online DMD and Window DMD)","archived":false,"fork":false,"pushed_at":"2022-10-23T21:05:06.000Z","size":961,"stargazers_count":44,"open_issues_count":1,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-04T20:13:25.120Z","etag":null,"topics":["ai","ai4science","applied-math","control-theory","data-driven-model","dynamical-systems","fluid-dynamics","inverse-problems","machine-learning-algorithms","model-learning","model-reduction","nonlinear-dynamics","online-learning","online-optimization","reduced-order-modeling","system-identification"],"latest_commit_sha":null,"homepage":"https://github.com/haozhg/osysid","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haozhg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-19T20:02:42.000Z","updated_at":"2025-09-21T21:07:05.000Z","dependencies_parsed_at":"2022-08-13T14:10:27.922Z","dependency_job_id":null,"html_url":"https://github.com/haozhg/odmd","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/haozhg/odmd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haozhg%2Fodmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haozhg%2Fodmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haozhg%2Fodmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haozhg%2Fodmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haozhg","download_url":"https://codeload.github.com/haozhg/odmd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haozhg%2Fodmd/sbom","scorecard":{"id":455102,"data":{"date":"2025-08-11","repo":{"name":"github.com/haozhg/odmd","commit":"e541e762f1509234d10cf331411439b4353f5a0c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/19 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"10 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-34 / GHSA-2fc2-6r4j-p65h","Warn: Project is vulnerable to: PYSEC-2021-856 / GHSA-5545-2q6w-2gh6","Warn: Project is vulnerable to: PYSEC-2019-108 / GHSA-9fq2-x9r6-wfmf","Warn: Project is vulnerable to: PYSEC-2018-33 / GHSA-cw6w-4rcx-xphc","Warn: Project is vulnerable to: PYSEC-2021-857 / GHSA-f7c7-j99h-c22f","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: PYSEC-2017-1 / GHSA-frgw-fgh6-9g52","Warn: Project is vulnerable to: PYSEC-2019-156 / GHSA-xp76-357g-9wqq","Warn: Project is vulnerable to: PYSEC-2023-102","Warn: Project is vulnerable to: PYSEC-2023-114"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 17 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T09:21:26.074Z","repository_id":54387204,"created_at":"2025-08-19T09:21:26.074Z","updated_at":"2025-08-19T09:21:26.074Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:16:59.381Z","status":"ssl_error","status_checked_at":"2026-01-14T08:13:45.490Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai4science","applied-math","control-theory","data-driven-model","dynamical-systems","fluid-dynamics","inverse-problems","machine-learning-algorithms","model-learning","model-reduction","nonlinear-dynamics","online-learning","online-optimization","reduced-order-modeling","system-identification"],"created_at":"2026-01-14T08:31:27.577Z","updated_at":"2026-01-14T08:31:28.169Z","avatar_url":"https://github.com/haozhg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# odmd\nA python package for online dynamic mode decomposition (Online DMD) and window dynamic mode decomposition (Window DMD) algorithms proposed in this [paper](https://epubs.siam.org/doi/pdf/10.1137/18M1192329). For matlab implementation, see [this repo](https://github.com/haozhg/odmd-matlab).\n\nTo get started,\n```\npip install odmd --upgrade\n```\n\nA variant of this algorithm for efficient data-driven online model learning (system identification) and control is implemented in [ai4sci.oml](https://github.com/haozhg/oml) (try `pip install ai4sci.oml --upgrade`). This algorithm has been show to be effective for flow separation control, see this [paper](https://doi.org/10.1017/jfm.2020.546) for more details.\n\n## Showcase: 2D linear time-varying system\nWe take a 2D time-varying system given by \n- dx/dt = A(t)x\n\nwhere x = [x1,x2]', A(t) = [0, w(t); -w(t), 0], w(t)=1+epsilon*t, epsilon=0.1. The slowly time-varying eigenvlaues of A(t) are pure imaginary, +(1+0.1t)j and -(1+0.1t)j, where j is the imaginary unit.\n\nHere we show how the proposed algorithm can be used to learn a model of the system. For more detail, see [demo](https://github.com/haozhg/odmd/tree/master/demo).\n\n### Time-varying state evolution\nThe system is oscillating with increasing frequency (frequency increased from 1 to 2 in 10 secs).\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/haozhg/odmd/blob/master/assets/state.png\" width=\"400\" /\u003e\n\u003c/p\u003e\n\n### Tracking eigenvalues with online/window DMD\nIf we apply online/window DMD, the learned model can track the time-varying eigenvalues very well. \n- Online DMD with weighting factor makes the learned model much more adaptive and tracks the true eigenvalues closely.\n- Window DMD is designed to better track time-varying dynamics, even if no weighting is used.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/haozhg/odmd/blob/master/assets/online_eval.png\" width=\"400\" /\u003e\n  \u003cimg src=\"https://github.com/haozhg/odmd/blob/master/assets/window_eval.png\" width=\"400\" /\u003e \n\u003c/p\u003e\n\n## Hightlights\nHere are some hightlights about this algorithm, and for more detail please refer to this [paper](https://epubs.siam.org/doi/pdf/10.1137/18M1192329)\n\n- Efficient data-driven online linear/nonlinear model learning (system identification). Any nonlinear and/or time-varying system is locally linear, as long as the model is updated in real-time wrt to new measurements.\n- It finds the exact optimal solution (in the sense of least square error), without any approximation (unlike stochastic gradient descent). \n- It achieves theoretical optimal time and space complexity. \n- The time complexity (flops for one iteration) is O(n^2), where n is state dimension. This is much faster than standard algorithm O(n^2 * t), where t is the current time step (number of measurements). In online applications, t \u003e\u003e n and essentially will go to infinity.\n- The space complexity is O(n^2), which is far more efficient than standard algorithm O(n * t) (t \u003e\u003e n).\n- A weighting factor (in (0, 1]) can be used to place more weight on recent data, thus making the model more adaptive.\n- It has been successfully applied to flow separation control problem, and achived real-time closed loop control. See this [paper](https://doi.org/10.1017/jfm.2020.546) for details.\n\n## Install\n### Use pip\n```\npip install odmd --upgrade\n```\n\n### Manual install\nCreate virtual env if needed\n```\npython3 -m venv .venv\nsource .venv/bin/activate\n```\n\nClone from github and install\n```\ngit clone https://github.com/haozhg/odmd.git\ncd odmd/\npython3 -m pip install -e .\n```\n\n### Test\nTo run tests\n```\ncd tests/\npip install r requirements.txt\npython -m pytest .\n```\n\n## Algorithm Description\nThis is a brief introduction to the algorithm. For full technical details, see this [paper](https://epubs.siam.org/doi/pdf/10.1137/18M1192329), and chapter 3 and chapter 7 of this [PhD thesis](http://arks.princeton.edu/ark:/88435/dsp0108612r49q).\n\n### Unknown dynamical system\nSuppose we have a (discrete) nonlinear and/or time-varying [dynamical system](https://en.wikipedia.org/wiki/State-space_representation), and the state space representation is\n- z(t) = f(t, z(t-1))\n\nwhere t is (discrete) time, z(t) is state vector.\n\nIn general, a variant of this algorithm (try `pip install ai4sci.oml --upgrade`, see [here](https://github.com/haozhg/oml)) also works if we have a nonlinear and/or time-varying map\n- y(t) = f(t, x(t))\n\nwhere x(t) is the input and y(t) is the output. Notice that dynamical system is a special case of nonlinear maps, by taking y(t) = z(t) and x(t) = z(t-1).\n\n- It is assumed that we have measurements z(t) for t = 0,1,...T. \n- However, we do not know function f. \n- We aim to learn a linear model for the unknown dynamical system from measurement data up to time T.\n- We want to the model to be updated efficiently in real-time as new measurement data becomes available.\n\nFrom now on, we will denote y(t) = z(t) and x(t) = z(t-1), so that the dynamical system can be written in this form\n- y(t) = f(t, x(t))\n\n### Online DMD algorithm description\nThe algorithm is implemented in class [OnlineDMD](./odmd/_online.py).\n\nAt time step t, define two matrix \n- X(t) = [x(1),x(2),...,x(t)],\n- Y(t) = [y(1),y(2),...,y(t)], \n\nthat contain all the past snapshot pairs, where x(t), y(t) are the n dimensional state vector, y(t) = f(t, x(t)) is the image of x(t), f() is the dynamics.  Here, if the (discrete-time) dynamics are given by z(t) = f(t, z(t-1)), then x(t), y(t) should be measurements corresponding to consecutive states z(t-1) and z(t).  \n\nWe would like to learn an adaptive online linear model M (a matrix) st \n- y(t) = M * x(t)\n\nThe matrix M is updated in real-time when new measurement becomes available. We aim to find the best M that leads to least-squre errors.\n\nAn exponential weighting factor rho=sigma^2 (0\u003crho\u003c=1) that places more weight on recent data can be incorporated into the definition of X(t) and Y(t) such that \n- X(t) = [sigma^(t-1)*x(1),sigma^(t-2)*x(2),…,sigma^(1)*x(t-1),x(t)], \n- Y(t) = [sigma^(t-1)*y(1),sigma^(t-2)*y(2),...,sigma^(1)*y(t-1),y(t)].  \n\nAt time t+1, the matrices become \n- X(t+1) = [x(1),x(2),…,x(t),x(t+1)], \n- Y(t+1) = [y(1),y(2),…,y(t),y(t+1)]. \n\nWe need to incorporate a new snapshot pair x(t+1), y(t+1) into the least-square objective function. We can update the DMD matrix A(t) online by efficient rank-1 updating online DMD algorithm.  \n\n- The time complexity (multiply–add operation for one iteration) is O(n^2), \n- and space complexity is O(n^2), where n is the state dimension.  \n\n### Window DMD algorithm description\nThe algorithm is implemented in class [WindowDMD](./odmd/_window.py).\n\nAt time step t, define two matrix \n- X(t) = [x(t-w+1),x(t-w+2),...,x(t)], \n- Y(t) = [y(t-w+1),y(t-w+2),...,y(t)] \n\nthat contain the recent w snapshot pairs from a finite time window, where x(t), y(t) are the n dimensional state vector, y(t) = f(t, x(t)) is the image of x(t), f() is the dynamics. Here, if the (discrete-time) dynamics are given by z(t) = f(t, z(t-1)), then x(t), y(t) should be measurements corresponding to consecutive states z(t-1) and z(t).\n\nSimilarly, we formulate this as a least-square optimization problem.\n\nAn exponential weighting factor rho=sigma^2 (0\u003crho\u003c=1) that places more weight on recent data can be incorporated into the definition of X(t) and Y(t) such that \n- X(t) = [sigma^(w-1)*x(t-w+1),sigma^(w-2)*x(t-w+2),…,sigma^(1)*x(t-1),x(t)], \n- Y(t) = [sigma^(w-1)*y(t-w+1),sigma^(w-2)*y(t-w+2),…,sigma^(1)*y(t-1),y(t)].\n\nAt time t+1, the data matrices become \n- X(t+1) = [x(t-w+2),x(t-w+3),…,x(t+1)], \n- Y(t+1) = [y(t-w+2),y(t-w+3),…,y(t+1)]. \n\nThe models needs to forget the oldest snapshot pair x(t-w+1),y(t-w+1), and remember the newest snapshot pair x(t+1),y(t+1). We can update the DMD matrix A(t) online by efficient rank-2 updating window DMD algroithm.  \n\n- The time complexity (multiply–add operation for one iteration) is O(n^2), \n- and space complexity is O(wn+2n^2), where n is the state dimension, and w is the window size. Typically w is taken to be O(n), e.g, w = 2n, or 10n.\n\n## Demo\nSee [demo](./demo) for python notebooks.\n- `demo_online.ipynb` shows how to use online DMD to learn adaptive online model for 2D time varying system.\n- `demo_window.ipynb` shows how to use online DMD to learn adaptive online model for 2D time varying system.\n\n## Authors:\nHao Zhang \n\n## Reference\nIf you you used these algorithms or this python package in your work, please consider citing\n\n```\nZhang, Hao, Clarence W. Rowley, Eric A. Deem, and Louis N. Cattafesta. \n\"Online dynamic mode decomposition for time-varying systems.\" \nSIAM Journal on Applied Dynamical Systems 18, no. 3 (2019): 1586-1609.\n```\n\nBibTeX\n```\n@article{zhang2019online,\n  title={Online dynamic mode decomposition for time-varying systems},\n  author={Zhang, Hao and Rowley, Clarence W and Deem, Eric A and Cattafesta, Louis N},\n  journal={SIAM Journal on Applied Dynamical Systems},\n  volume={18},\n  number={3},\n  pages={1586--1609},\n  year={2019},\n  publisher={SIAM}\n}\n```\n\n## Date created\nApril 2017\n\n## License\nMIT\n\nIf you want to use this package, but find license permission an issue, pls contact me at `haozhang at alumni dot princeton dot edu`.\n\n## Issues\nIf there is any comment/suggestion, or if you find any bug, feel free to \n- create an issue [here](https://github.com/haozhg/oml/issues), or\n- fork this repo, make changes, and create a pull request (merge from your fork to this repo)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaozhg%2Fodmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaozhg%2Fodmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaozhg%2Fodmd/lists"}