pymodeflow 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. pymodeflow-0.1.2/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
  2. pymodeflow-0.1.2/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
  3. pymodeflow-0.1.2/.github/PULL_REQUEST_TEMPLATE.md +7 -0
  4. pymodeflow-0.1.2/.github/dependabot.yml +6 -0
  5. pymodeflow-0.1.2/.github/workflows/ci.yml +42 -0
  6. pymodeflow-0.1.2/.github/workflows/release.yml +62 -0
  7. pymodeflow-0.1.2/.gitignore +21 -0
  8. pymodeflow-0.1.2/CHANGELOG.md +78 -0
  9. pymodeflow-0.1.2/CITATION.cff +114 -0
  10. pymodeflow-0.1.2/CONTRIBUTING.md +38 -0
  11. pymodeflow-0.1.2/LICENSE +21 -0
  12. pymodeflow-0.1.2/MANIFEST.in +4 -0
  13. pymodeflow-0.1.2/PKG-INFO +228 -0
  14. pymodeflow-0.1.2/README.md +164 -0
  15. pymodeflow-0.1.2/docs/api.md +52 -0
  16. pymodeflow-0.1.2/docs/citing.md +20 -0
  17. pymodeflow-0.1.2/docs/data-format.md +53 -0
  18. pymodeflow-0.1.2/docs/index.md +19 -0
  19. pymodeflow-0.1.2/docs/releasing.md +59 -0
  20. pymodeflow-0.1.2/docs/roadmap.md +20 -0
  21. pymodeflow-0.1.2/docs/snap-pod.md +34 -0
  22. pymodeflow-0.1.2/docs/spod.md +50 -0
  23. pymodeflow-0.1.2/examples/quickstart.py +39 -0
  24. pymodeflow-0.1.2/mkdocs.yml +15 -0
  25. pymodeflow-0.1.2/pyproject.toml +80 -0
  26. pymodeflow-0.1.2/setup.cfg +4 -0
  27. pymodeflow-0.1.2/src/modeflow/__init__.py +36 -0
  28. pymodeflow-0.1.2/src/modeflow/__main__.py +11 -0
  29. pymodeflow-0.1.2/src/modeflow/_common.py +157 -0
  30. pymodeflow-0.1.2/src/modeflow/_version.py +24 -0
  31. pymodeflow-0.1.2/src/modeflow/dmd.py +681 -0
  32. pymodeflow-0.1.2/src/modeflow/py.typed +0 -0
  33. pymodeflow-0.1.2/src/modeflow/snap_pod.py +631 -0
  34. pymodeflow-0.1.2/src/modeflow/spod.py +766 -0
  35. pymodeflow-0.1.2/src/modeflow/synthetic.py +88 -0
  36. pymodeflow-0.1.2/src/pymodeflow.egg-info/PKG-INFO +228 -0
  37. pymodeflow-0.1.2/src/pymodeflow.egg-info/SOURCES.txt +48 -0
  38. pymodeflow-0.1.2/src/pymodeflow.egg-info/dependency_links.txt +1 -0
  39. pymodeflow-0.1.2/src/pymodeflow.egg-info/entry_points.txt +4 -0
  40. pymodeflow-0.1.2/src/pymodeflow.egg-info/requires.txt +17 -0
  41. pymodeflow-0.1.2/src/pymodeflow.egg-info/scm_file_list.json +43 -0
  42. pymodeflow-0.1.2/src/pymodeflow.egg-info/scm_version.json +8 -0
  43. pymodeflow-0.1.2/src/pymodeflow.egg-info/top_level.txt +1 -0
  44. pymodeflow-0.1.2/tests/__init__.py +1 -0
  45. pymodeflow-0.1.2/tests/conftest.py +59 -0
  46. pymodeflow-0.1.2/tests/test_common.py +67 -0
  47. pymodeflow-0.1.2/tests/test_metadata.py +35 -0
  48. pymodeflow-0.1.2/tests/test_package.py +27 -0
  49. pymodeflow-0.1.2/tests/test_snap_pod.py +150 -0
  50. pymodeflow-0.1.2/tests/test_spod.py +185 -0
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: Bug report
3
+ about: Something does not work as documented
4
+ labels: bug
5
+ ---
6
+
7
+ **Command or code**
8
+ ```
9
+ snap-pod save -i ...
10
+ ```
11
+
12
+ **What happened / what did you expect?**
13
+
14
+ **Data**: shape of the array (`[N, Nt]`), `dim`, flatten order (C or F), file type (.npz / .mat)
15
+
16
+ **Environment**: output of `python3 -c "import modeflow, sys; print(modeflow.__version__, sys.version)"` and your OS
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an improvement
4
+ labels: enhancement
5
+ ---
6
+
7
+ **What would you like to do that is not possible now?**
8
+
9
+ **Proposed behaviour** (options, outputs)
10
+
11
+ **References** (paper, algorithm)
@@ -0,0 +1,7 @@
1
+ ## What does this change?
2
+
3
+ ## Checklist
4
+ - [ ] Tests added or updated (`pytest`)
5
+ - [ ] `ruff check .` passes
6
+ - [ ] `CHANGELOG.md` updated under *Unreleased*
7
+ - [ ] Documentation / docstrings updated
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: "/"
5
+ schedule:
6
+ interval: monthly
@@ -0,0 +1,42 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with: { python-version: "3.12" }
15
+ - run: pip install ruff
16
+ - run: ruff check .
17
+
18
+ test:
19
+ runs-on: ${{ matrix.os }}
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ os: [ubuntu-latest, macos-latest, windows-latest]
24
+ python-version: ["3.12", "3.13", "3.14"]
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ with: { fetch-depth: 0 }
28
+ - uses: actions/setup-python@v5
29
+ with: { python-version: "${{ matrix.python-version }}" }
30
+ - run: pip install -e ".[dev,mat73]"
31
+ - run: pytest --cov --cov-report=term-missing
32
+
33
+ build:
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - uses: actions/checkout@v4
37
+ with: { fetch-depth: 0 }
38
+ - uses: actions/setup-python@v5
39
+ with: { python-version: "3.12" }
40
+ - run: pip install build twine
41
+ - run: python -m build
42
+ - run: twine check --strict dist/*
@@ -0,0 +1,62 @@
1
+ name: Release
2
+
3
+ # Push a tag such as v0.2.0 (or v0.2.0rc1 for a pre-release) to publish:
4
+ # stable tags -> PyPI + GitHub release
5
+ # pre-release tags -> TestPyPI + GitHub pre-release
6
+ on:
7
+ push:
8
+ tags: ["v*"]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ outputs:
14
+ stable: ${{ steps.kind.outputs.stable }}
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ with: { fetch-depth: 0 }
18
+ - uses: actions/setup-python@v5
19
+ with: { python-version: "3.12" }
20
+ - id: kind
21
+ run: |
22
+ if [[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "stable=true" >> "$GITHUB_OUTPUT"; else echo "stable=false" >> "$GITHUB_OUTPUT"; fi
23
+ - run: pip install build twine pytest && pip install -e ".[dev]" && pytest
24
+ - run: python -m build && twine check --strict dist/*
25
+ - uses: actions/upload-artifact@v4
26
+ with: { name: dist, path: dist/ }
27
+
28
+ publish-pypi:
29
+ needs: build
30
+ if: needs.build.outputs.stable == 'true'
31
+ runs-on: ubuntu-latest
32
+ environment: { name: pypi, url: "https://pypi.org/project/pyModeFlow/" }
33
+ permissions: { id-token: write }
34
+ steps:
35
+ - uses: actions/download-artifact@v4
36
+ with: { name: dist, path: dist/ }
37
+ - uses: pypa/gh-action-pypi-publish@release/v1
38
+
39
+ publish-testpypi:
40
+ needs: build
41
+ if: needs.build.outputs.stable != 'true'
42
+ runs-on: ubuntu-latest
43
+ environment: { name: testpypi, url: "https://test.pypi.org/project/pyModeFlow/" }
44
+ permissions: { id-token: write }
45
+ steps:
46
+ - uses: actions/download-artifact@v4
47
+ with: { name: dist, path: dist/ }
48
+ - uses: pypa/gh-action-pypi-publish@release/v1
49
+ with: { repository-url: "https://test.pypi.org/legacy/" }
50
+
51
+ github-release:
52
+ needs: build
53
+ runs-on: ubuntu-latest
54
+ permissions: { contents: write }
55
+ steps:
56
+ - uses: actions/download-artifact@v4
57
+ with: { name: dist, path: dist/ }
58
+ - uses: softprops/action-gh-release@v2
59
+ with:
60
+ files: dist/*
61
+ generate_release_notes: true
62
+ prerelease: ${{ needs.build.outputs.stable != 'true' }}
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ build/
5
+ dist/
6
+ .eggs/
7
+ .venv/
8
+ venv/
9
+ .pytest_cache/
10
+ .ruff_cache/
11
+ .ipynb_checkpoints/
12
+ .coverage
13
+ htmlcov/
14
+ site/
15
+ src/modeflow/_version.py
16
+ # analysis output
17
+ results/
18
+ *_20??????/
19
+ *.npy
20
+ !tests/**/*.npy
21
+ __pycache__/
@@ -0,0 +1,78 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/). Versions are derived from git tags (`vX.Y.Z`).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Planned
10
+ - See [docs/roadmap.md](docs/roadmap.md).
11
+
12
+ ## [0.1.0] - 2026-12-03
13
+
14
+ First packaged release. It combines two standalone scripts into one installable package.
15
+
16
+ # pyModeFlow v0.1.1 – First Official Release
17
+
18
+ ## Overview
19
+
20
+ pyModeFlow is a Python package for modal decomposition and flow-field analysis, providing tools for extracting dominant spatial and temporal structures from flow data.
21
+
22
+ ## Features
23
+
24
+ - Spectral Proper Orthogonal Decomposition (SPOD).
25
+ - Snapshot Proper Orthogonal Decomposition (Snapshot POD).
26
+ - Dynamic Mode Decomposition (DMD).
27
+ - Command-line interfaces for supported decomposition methods.
28
+ - Flow-field visualization and data export.
29
+ - Support for reproducible computational workflows.
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install modeflow
35
+ ```
36
+
37
+ ## Release
38
+
39
+ Version: 0.1.1
40
+
41
+ This is the first official stable release of pyModeFlow.
42
+
43
+ ### Improved
44
+ - Input validation and error handling.
45
+ - SPOD mode saving and replotting functionality.
46
+ - Snapshot POD parameter validation.
47
+
48
+ ### Testing
49
+ - Automated pytest test suite.
50
+ - Verification of SPOD and Snapshot POD workflows.
51
+ - CLI save and replot testing.
52
+
53
+ ### Added
54
+ - `snap-pod` / `modeflow.SnapshotPOD`: snapshot POD by the method of snapshots (modes,
55
+ time coefficients, energy ratio, PSD of the coefficients, reconstruction from saved files).
56
+ - `spod` / `modeflow.SpectralPOD`: spectral POD with Welch's method following Schmidt & Colonius
57
+ (2020): Hamming/Hann/rectangular windows, window correction, overlap, chi-squared confidence
58
+ bounds, weighted norm, disk-backed Fourier realizations for large data, `replot` of saved modes.
59
+ - `dmd` / `modeflow.DMD`: Dynamic Mode Decomposition (DMD) of Experimental velocity-field and Image
60
+ (Qualitative) data. (DMD modes, time dynamics, DMD spectra, growth/decay rate and reconstructed data).
61
+ A steady (background / mean-flow) component appears as a mode with omega ~ 0.
62
+ Algorithm (exact DMD; the hand-written notes, Tu et al. 2014, Brunton & Kutz, PyDMD).
63
+ - Shared data convention: `[N, Nt]` matrices (`N = nx*ny`) in `.npz`/`.mat` files, flatten order
64
+ `C` or `F`, case-insensitive variable names, MATLAB v7.3 files through the optional `mat73` extra.
65
+ - `modeflow.synthetic`: synthetic PIV-like data with a known answer, used by the tests and examples.
66
+ - Test suite, GitHub Actions (CI and PyPI release), documentation, `CITATION.cff`.
67
+
68
+ ### Notes
69
+ - The class of the `snap_pod.py` script was named `SnapshotPOD` so that it cannot be confused with
70
+ *spectral* POD, which is `SpectralPOD` (alias `SPOD`).
71
+ - `snap-pod`, `spod` and `dmd` keeps `--order C` as its default flatten order.
72
+
73
+
74
+ ## Quality Assurance
75
+
76
+ - Project cleaned and rebuilt.
77
+ - Automated test suite executed.
78
+ - Core functionality and command-line workflows tested.
@@ -0,0 +1,114 @@
1
+ cff-version: 1.2.0
2
+ message: >-
3
+ If you use pyModeFlow in your work, please cite the software with the metadata below
4
+ and also cite the papers listed under "references", which describe the methods it implements.
5
+ title: "pyModeFlow: Snapshot Proper Orthogonal Decomposition (snapshot POD), Spectral Proper Orthogonal Decomposition (SPOD) and Dynamic Mode Decomposition (DMD) of time-resolved experimental and schlieren image data"
6
+ type: software
7
+ authors:
8
+ - family-names: Ekwonu
9
+ given-names: Michael Chukwuemeka
10
+ version: 0.1.0
11
+ date-released: 2026-12-03
12
+ license: MIT
13
+ repository-code: "https://github.com/mcekwonu/pyModeFlow"
14
+ url: "https://github.com/mcekwonu/pyModeFlow"
15
+ doi: 10.5281/zenodo.24769536
16
+ keywords:
17
+ - Experimental Fluid dynamics
18
+ - PIV
19
+ - snapshot proper orthogonal decomposition
20
+ - spectral proper orthogonal decomposition
21
+ - dynamic mode decomposition
22
+ - fluid mechanics
23
+
24
+ references:
25
+ - type: article
26
+ authors:
27
+ - family-names: Schmidt
28
+ given-names: Oliver T.
29
+ - family-names: Colonius
30
+ given-names: Tim
31
+ title: "Guide to Spectral Proper Orthogonal Decomposition"
32
+ journal: "AIAA Journal"
33
+ volume: 58
34
+ issue: 3
35
+ start: 1023
36
+ end: 1033
37
+ year: 2020
38
+ doi: 10.2514/1.J058809
39
+ notes: "SPOD-Welch algorithm implemented in modeflow.spod"
40
+
41
+ - type: article
42
+ authors:
43
+ - family-names: Towne
44
+ given-names: Aaron
45
+ - family-names: Schmidt
46
+ given-names: Oliver T.
47
+ - family-names: Colonius
48
+ given-names: Tim
49
+ title: "Spectral proper orthogonal decomposition and its relationship to dynamic mode decomposition and resolvent analysis"
50
+ journal: "Journal of Fluid Mechanics"
51
+ volume: 847
52
+ start: 821
53
+ end: 867
54
+ year: 2018
55
+ doi: 10.1017/jfm.2018.283
56
+
57
+ - type: article
58
+ authors:
59
+ - family-names: Welch
60
+ given-names: Peter
61
+ title: "The use of fast Fourier transform for the estimation of power spectra: a method based on time averaging over short, modified periodograms"
62
+ journal: "IEEE Transactions on Audio and Electroacoustics"
63
+ volume: 15
64
+ issue: 2
65
+ start: 70
66
+ end: 73
67
+ year: 1967
68
+ doi: 10.1109/TAU.1967.1161901
69
+
70
+ - type: article
71
+ authors:
72
+ - family-names: Sirovich
73
+ given-names: Lawrence
74
+ title: "Turbulence and the dynamics of coherent structures. Part I: Coherent structures"
75
+ journal: "Quarterly of Applied Mathematics"
76
+ volume: 45
77
+ issue: 3
78
+ start: 561
79
+ end: 571
80
+ year: 1987
81
+ notes: "method of snapshots used by modeflow.snap_pod"
82
+
83
+ - type: article
84
+ authors:
85
+ - family-names: Schmid
86
+ given-names: P. J.
87
+ title: "Dynamic mode decomposition of numerical and experimental data"
88
+ journal: "Journal of Fluid Mechanics"
89
+ volume: 656
90
+ start: 5
91
+ end: 28
92
+ year: 2010
93
+ doi: 10.1017/S0022112010001217
94
+
95
+ - type: book chapter
96
+ authors:
97
+ - family-names: Kutz
98
+ given-names: J. Nathan
99
+ - family-names: Brunton
100
+ given-names: Steven L.
101
+ - family-names: Brunton
102
+ given-names: Bingni W.
103
+ - family-names: Proctor
104
+ given-names: Joshua L.
105
+ title = Chapter 1: Dynamic Mode Decomposition: An Introduction
106
+ booktitle = Dynamic Mode Decomposition
107
+ start: 1
108
+ end: 24
109
+ year:
110
+ doi: 10.1137/1.9781611974508.ch1
111
+ url: https://epubs.siam.org/doi/abs/10.1137/1.9781611974508.ch1
112
+ doi: 10.1137/1.9781611974508.ch1
113
+ notes: "DMD used implemented by modeflow:dmd"
114
+
@@ -0,0 +1,38 @@
1
+ # Contributing
2
+
3
+ Thank you for helping to improve `pyModeFlow`! Bug reports, questions, documentation fixes and new
4
+ features are all welcome.
5
+
6
+ ## Development setup
7
+
8
+ ```bash
9
+ git clone https://github.com/drmcekwonu/pyModeFlow.git
10
+ cd modeflow
11
+ python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
12
+ pip install -e ".[dev,mat73]"
13
+ pytest # about 15 s
14
+ ruff check . # style and imports
15
+ ```
16
+
17
+ ## Workflow
18
+
19
+ 1. Open an issue first for larger changes.
20
+ 2. Branch from `main`: `git switch -c feature/short-name`.
21
+ 3. Add or update tests. Numerical code should be checked against an independent reference
22
+ (SciPy, an explicit formula, or the synthetic data of `modeflow.synthetic`, whose answer is known).
23
+ 4. Add a line to the `[Unreleased]` section of `CHANGELOG.md`.
24
+ 5. Open a pull request. CI runs the tests on Linux, macOS and Windows for Python 3.9-3.13.
25
+
26
+ ## Conventions
27
+
28
+ - One data convention: velocity components are `[N, Nt]` with `N = nx*ny`; document any new option
29
+ that touches it.
30
+ - Command line tools and Python classes must stay in step: every option has a class argument.
31
+ - User-facing errors are `ValueError` / `FileNotFoundError` with a clear message; the CLI turns
32
+ them into `error: ...` and creates no output folder on failure.
33
+ - Commit messages: short imperative summary, for example `Add Hann window option to spod`.
34
+
35
+ ## Releases
36
+
37
+ Maintainers: see [docs/releasing.md](docs/releasing.md). Versions follow Semantic Versioning and
38
+ come from git tags, so there is no version number to edit in the code.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ekwonu Michael Chukwuemeka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include README.md LICENSE CITATION.cff CHANGELOG.md CONTRIBUTING.md mkdocs.yml
2
+ recursive-include docs *.md
3
+ recursive-include examples *.py
4
+ recursive-include tests *.py
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: pymodeflow
3
+ Version: 0.1.2
4
+ Summary: Python framework for Snapshot POD, spectral POD (SPOD, Welch's method) and Dynamic Mode Decomposition (DMD) of time-resolved experimental and schlieren imaging data
5
+ Author: Ekwonu Michael Chukwuemeka
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Ekwonu Michael Chukwuemeka
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/drmcekwonu/pyModeFlow
29
+ Project-URL: Documentation, https://drmcekwonu.github.io/pyModeFlow
30
+ Project-URL: Repository, https://github.com/drmcekwonu/pyModeFlow
31
+ Project-URL: Issues, https://github.com/drmcekwonu/pyModeFlow/issues
32
+ Project-URL: Changelog, https://github.com/drmcekwonu/pyModeFlow/blob/main/CHANGELOG.md
33
+ Keywords: DMD,PIV,POD,SPOD,spectral POD,modal decomposition,fluid mechanics,turbulence,coherent structures,Schlieren Imaging
34
+ Classifier: Development Status :: 3 - Alpha
35
+ Classifier: Intended Audience :: Science/Research
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: OS Independent
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Programming Language :: Python :: 3.13
44
+ Classifier: Topic :: Scientific/Engineering :: Physics
45
+ Classifier: Topic :: Scientific/Engineering :: Visualization
46
+ Requires-Python: >=3.9
47
+ Description-Content-Type: text/markdown
48
+ License-File: LICENSE
49
+ Requires-Dist: numpy>=1.22
50
+ Requires-Dist: scipy>=1.8
51
+ Requires-Dist: matplotlib>=3.5
52
+ Requires-Dist: tqdm>=4.60
53
+ Provides-Extra: mat73
54
+ Requires-Dist: h5py>=3.0; extra == "mat73"
55
+ Provides-Extra: dev
56
+ Requires-Dist: pytest>=7; extra == "dev"
57
+ Requires-Dist: pytest-cov; extra == "dev"
58
+ Requires-Dist: ruff; extra == "dev"
59
+ Requires-Dist: build; extra == "dev"
60
+ Requires-Dist: twine; extra == "dev"
61
+ Provides-Extra: docs
62
+ Requires-Dist: mkdocs-material; extra == "docs"
63
+ Dynamic: license-file
64
+
65
+ # pyModeFlow
66
+
67
+ [![CI](https://github.com/drmcekwonu/pyModeFlow/actions/workflows/ci.yml/badge.svg)](https://github.com/mcekwonu/pyModeFlow/actions/workflows/ci.yml)
68
+ [![PyPI](https://img.shields.io/pypi/v/pyModeFlow.svg)](https://pypi.org/project/pyModeFlow/)
69
+ [![Python](https://img.shields.io/pypi/pyversions/pyModeFlow.svg)](https://pypi.org/project/pyModeFlow/)
70
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
71
+ <!-- [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24769536.svg)](https://doi.org/10.5281/zenodo.24769536) -->
72
+
73
+ Framework for Modal decompositions of **time-resolved experimental and schlieren data** (u, v or w snapshots), as a Python package
74
+ with command line tools:
75
+
76
+ | Tool | Class | What it does |
77
+ | --- | --- | --- |
78
+ | `snap-pod` | `modeflow.SnapshotPOD` | Snapshot POD by the method of snapshots: spatial modes, time coefficients, energy ratio, PSD of the coefficients, reconstruction |
79
+ | `spod` | `modeflow.SpectralPOD` | Spectral POD with Welch's method after [Schmidt & Colonius (2020)](https://doi.org/10.2514/1.J058809): SPOD energy spectrum with confidence bounds, modes at every frequency |
80
+ | `dmd` | `modeflow.DMD` | Dynamic Mode Decomposition (DMD) of Experimental velocity-field and Image (Qualitative) data: DMD modes, time dynamics, DMD spectra, growth/decay rate and reconstructed data | Algorithm (exact DMD; the hand-written notes, Tu et al. 2014, Brunton & Kutz, PyDMD): A steady (background/mean-flow) component appears as a mode with omega ~ 0. [Brunton & Kutz (2020)](https://doi.org/10.2514/1.J058809):
81
+
82
+ Both tools read the same files, write 2D modes as `(nx, ny)` images and arrays, show `tqdm`
83
+ progress bars, and are tested against independent references (SciPy's Welch estimator, an explicit
84
+ cross-spectral-density eigendecomposition, data with a known answer).
85
+
86
+ ## Installation
87
+
88
+ ```bash
89
+ pip install pymodeflow # from PyPI
90
+ pip install "pymodeflow[mat73]" # + MATLAB v7.3 (.mat, HDF5) support
91
+ pip install git+https://github.com/drmcekwonu/pyModeFlow.git # latest development version
92
+ ```
93
+
94
+ Python >= 3.9; depends on NumPy, SciPy, Matplotlib and tqdm.
95
+
96
+ ## Input data
97
+
98
+ A `.npz` or `.mat` file with the velocity components `U`, `V`, `W` (and/or `Vmag`; names are
99
+ case-insensitive) and, optionally, `dim = [nx, ny]`. Each component is a matrix
100
+
101
+ ```
102
+ X with shape [N, Nt] N = nx * ny flattened grid points (rows)
103
+ Nt time snapshots, dt apart (columns)
104
+ ```
105
+
106
+ so `X[:, k]` is the field at snapshot `k` flattened in **C order** (row-major, NumPy
107
+ `field.reshape(-1)`) or **F order** (column-major, MATLAB `U(:)`, `--order F`). `dim` and the order
108
+ are only used to fold modes back into 2D images. Details: [docs/data-format.md](docs/data-format.md).
109
+
110
+ ```python
111
+ import numpy as np
112
+ np.savez("piv_data.npz", U=U.reshape(nx * ny, nt), dim=[nx, ny]) # U has shape (nx, ny, nt)
113
+ ```
114
+
115
+ > **Note on defaults.** `--order` defaults to `C` in `snap-pod`, `dmd` and `spod`; you can pass it
116
+ > explicitly as `F` when you data is saved using MATLAB's .mat.
117
+
118
+ ## Quick start
119
+
120
+ No data yet? Generate a synthetic set with known tones (5 Hz and 12 Hz):
121
+
122
+ ```bash
123
+ python -m modeflow.synthetic synthetic_data.npz # U: [2400, 5001], dt = 0.002 s
124
+
125
+ python3 -m snap-pod save -i synthetic_data.npz -c U -t 0.002 -o results --order C
126
+ python3 -m spod save -i synthetic_data.npz -c U -t 0.002 -o results --nfft 256
127
+ python3 -m dmd save -i synthetic_data.npz -c U -t 0.002 -o results --order F
128
+ ```
129
+
130
+ Results go to `<output-dir>/<input-file-stem>_<YYYYMMDD>/<component>`, for example
131
+ `results/synthetic_data_20261202/U/`, so runs for different components never overwrite each other.
132
+
133
+ ### snap-pod
134
+
135
+ ```bash
136
+ python3 -m snap-pod save -i piv_data.npz -c U -t 0.001 -o results -m 6 # compute and write everything
137
+ python3 -m snap-pod preview -i piv_data.npz -c V -t 0.001 # show figures, write nothing
138
+ python3 -m snap-pod replot -p results/piv_data_20261202/U/POD_modes.npy -m 4 -o figure
139
+ python3 -m snap-pod reconstruct -p results/piv_data_20261202/U/POD_modes.npy -r 10 # rebuild the data with 10 modes
140
+ ```
141
+
142
+ Writes `POD_modes.npy` `[N, K]`, `POD_coefficients.npy` `[K, Nt]`, `POD_mean.npy`, `eigs_result.csv`,
143
+ `psd_result_mode_<i>.csv`, one image per mode, the energy and PSD figures.
144
+
145
+ ### spod
146
+
147
+ ```bash
148
+ python3 -m spod save -i piv_data.npz -c U -t 0.001 -o results --nfft 512 # 50 % overlap, Hamming window
149
+ python3 -m spod preview -i piv_data.npz -c U -t 0.001 --nfft 256 --window hann
150
+ python3 -m spod replot -p results/piv_data_20261202/U --freqs 1.59 0.238 -m 2 -o modes_selected
151
+ ```
152
+
153
+ Writes `SPOD_spectrum.png` (energy of every mode, PSD, 99 % confidence bounds), `SPOD_low_rank.png`
154
+ (`lambda_1 / sum(lambda)` with the peak frequencies, `f_max` and `f_s`), one `SPOD_mode<k>_f<f>Hz.png`
155
+ per mode, `SPOD_modes.npy` `[n_freq, N, n_modes]`, `SPOD_spectrum.csv/.npz`. Choose `--nfft`, `--novlp`
156
+ and the window with the trade-offs of the paper in mind: [docs/spod.md](docs/spod.md).
157
+
158
+ ### dmd
159
+
160
+ ```bash
161
+ python3 dmd.py save -i piv_data.npz -c U -o ./results -t 0.002 -r 20
162
+ python3 dmd.py save -i piv_data.mat -c W -o ./results -t 0.002 --order F --predict 100
163
+ python3 dmd.py preview -i piv_data.npz -c V -t 0.002 -r 10 --dim 120 80
164
+ python3 dmd.py reconstruct -p ./results/piv_data_20261128/U -r 4
165
+ python3 dmd.py reconstruct -p ./results/piv_data_20261128/U --fmin 4.5 --fmax 5.5 --predict 50
166
+ python3 dmd.py reconstruct -p ./results/piv_data_20261128/U --part background
167
+ ```
168
+
169
+ Writes DMD modes in `DMD_modes.npy` `[N, r]` and saves `DMD_mode_<i>.png` `(2D, shape (nx, ny))`,
170
+ Dynamics `DMD_dynamics.npy` `(b * exp(omega * t)` and saves `DMD_dynamics.png`,
171
+ DMD spectra `DMD_eigenvalues.png` `(lambda plane)` and `DMD_omega.png` `(omega plane)` and `DMD_spectrum.png` (amplitude vs frequency)`
172
+ Growth/decay rate `Re(omega) [1/s] and frequency Im(omega)/(2 pi) [Hz]` in `DMD_eigenvalues.csv` and `DMD_spectrum.npz`
173
+ Reconstructed data in `DMD_reconstructed.npy [N, Nt (+ predicted)]`: [docs/dmd.md](docs/dmd.md).
174
+
175
+
176
+ ### Python API
177
+
178
+ ```python
179
+ from modeflow import SnapshotPOD, SpectralPOD, DMD
180
+
181
+ pod = SnapshotPOD("piv_data.npz", dt=1e-3, component="U", num_modes=6, order="C")
182
+ pod.compute() # pod.modes, pod.coeffs, pod.s, pod.r (optimal rank)
183
+
184
+ spod = SpectralPOD("piv_data.npz", dt=1e-3, nfft=512, num_modes=4, order="C")
185
+ spod.compute() # spod.freq, spod.lam (n_freq, N_blk), spod.modes (n_freq, N, n_modes)
186
+
187
+ dmd = DMD("piv_data.npz", dt=1e-3, component="U", rank=6, order="C")
188
+ dmd.compute() # dmd.modes, dmd.dynamics, dmd.growth-rate
189
+ ```
190
+
191
+ See [docs/api.md](docs/api.md) and `examples/quickstart.py`.
192
+
193
+ ## Citing
194
+
195
+ If `pyModeFlow` contributes to a publication, please cite the software (GitHub shows a *Cite this
196
+ repository* button from [`CITATION.cff`](CITATION.cff); a Zenodo DOI is minted for every release) **and**
197
+ the papers that describe the methods:
198
+
199
+ ```bibtex
200
+ @software{pyModeFlow,
201
+ author = {Ekwonu, Michael Chukwuemeka},
202
+ title = {pyModeFlow: pyModeFlow: Snapshot Proper Orthogonal Decompostion (snapPOD), Spectral Proper Orthogonal Decomposition (SPOD) and Dynamic Mode Decomposition (DMD) of time-resolved experimental and schlieren image data},
203
+ year = {2026},
204
+ version = {0.1.0},
205
+ url = {https://github.com/drmcekwonu/pyModeFlow}
206
+ }
207
+
208
+ @article{SchmidtColonius2020,
209
+ author = {Schmidt, Oliver T. and Colonius, Tim},
210
+ title = {Guide to Spectral Proper Orthogonal Decomposition},
211
+ journal = {AIAA Journal},
212
+ volume = {58}, number = {3}, pages = {1023--1033}, year = {2020},
213
+ doi = {10.2514/1.J058809}
214
+ }
215
+ ```
216
+
217
+ Related references (Welch 1967, Towne et al. 2018, Sirovich 1987) are listed in
218
+ [docs/citing.md](docs/citing.md).
219
+
220
+ ## Development, releases and roadmap
221
+
222
+ - Contributing and tests: [CONTRIBUTING.md](CONTRIBUTING.md) (`pip install -e ".[dev]"`, `pytest`)
223
+ - Versions come from git tags (`v0.2.0`); how to release: [docs/releasing.md](docs/releasing.md)
224
+ - Changes: [CHANGELOG.md](CHANGELOG.md); ideas for future development: [docs/roadmap.md](docs/roadmap.md)
225
+
226
+ ## License
227
+
228
+ MIT, see [LICENSE](LICENSE).