Skip to main content

OpenModalPy: Python tools for POD, MPOD, DMD, SPOD, PSD-POD, BSMD, and ST-POD on spatiotemporal data

Project description

OpenModalPy

Modal decomposition of spatiotemporal data in Python. Pure NumPy/SciPy — no external solver dependencies.

Methods: POD · mPOD · PSD-POD · SPOD · ST-POD · DMD (LS/TLS) · HODMD (LS/TLS) · BSMD

Installation

uv add openmodalpy

The installed package is imported as openmodalpy.

Or as a standalone CLI:

uv tool install openmodalpy

For modern 3D slice/isosurface plotting:

uv add "openmodalpy[viz3d]"

FFT Backend

FFT dispatch is handled by fftkit, installed automatically. It probes the available backends and picks the fastest one, falling back to SciPy when nothing else is present — so no configuration is needed.

To pin a backend explicitly:

export FFTKIT_BACKEND=mkl      # or scipy, numpy, cupy, accelerate
from openmodalpy.core.config import FFT_BACKEND
print(FFT_BACKEND)   # the backend actually in use

Accelerator support comes from the corresponding extra:

uv add "openmodalpy[mkl]"   # Intel MKL
uv add "openmodalpy[gpu]"   # CuPy / PyTorch

The legacy PYMODAL_FFT_BACKEND variable is still honoured as a fallback, but FFTKIT_BACKEND is the supported name.

Quick Start

from openmodalpy import PODAnalyzer, DMDAnalyzer, SPODAnalyzer

pod = PODAnalyzer(file_path="data.mat", n_modes_save=10)
pod.run_analysis()

dmd = DMDAnalyzer(file_path="data.mat", n_modes_save=10)
dmd.load_and_preprocess()
dmd.perform_dmd(method="ls")

spod = SPODAnalyzer(file_path="data.mat", nfft=256, overlap=0.5)
spod.run_analysis()

Configuration-Driven Workflow

A single JSONC file runs multiple methods on one dataset:

{
  "case": {
    "name": "my_case",
    "data": { "kind": "file", "path": "data.mat" },
    "n_modes_save": 10, "nfft": 128, "overlap": 0.5
  },
  "runs": [
    { "id": "pod",  "method": "pod" },
    { "id": "spod", "method": "spod" },
    { "id": "dmd",  "method": "dmd", "params": { "method": "ls" } },
    { "id": "hodmd","method": "hodmd", "params": { "delays": 4 } },
    { "id": "bsmd", "method": "bsmd" }
  ]
}
openmodalpy run --config analysis.jsonc

CLI

openmodalpy analyze pod --config case.jsonc         # one method
openmodalpy run --config suite.jsonc                # full suite
openmodalpy run --config suite.jsonc --dry-run      # preview
openmodalpy methods list                            # supported methods
openmodalpy examples list                           # bundled examples
openmodalpy results inspect output.hdf5             # inspect result

Bundled Example Configs

The public package ships only self-contained generator-backed example configs:

  • double_gyre.jsonc
  • cylinder_wake.jsonc
  • taylor_green.jsonc
  • run_benchmarks.jsonc

These configs do not depend on repository-local benchmark datasets.

Supported Methods

Method Class What it extracts
POD variance-optimal energy-ranked spatial modes
mPOD variance-optimal scale-separated modes
PSD-POD variance-optimal broadband spectral modes
SPOD variance-optimal frequency-local modes
ST-POD variance-optimal space-time structures (delay embedding)
DMD (LS) evolution-fit modes with frequency and growth rate
DMD (TLS) evolution-fit de-biased DMD for noisy data
HODMD evolution-fit delay-embedded DMD
TLS-HODMD evolution-fit de-biased delay-embedded DMD
BSMD triadic interaction nonlinear triad structures

The BSMD implementation follows Schmidt (2020) and was inspired by the reference MATLAB implementation.

Data Format

OpenModalPy auto-detects .mat and .npz files:

{
    "q": np.ndarray,   # (Ns, Nspace) — snapshots × spatial points
    "dt": float,       # time step
    "Nx": int,         # grid points in x
    "Ny": int,         # grid points in y
    "x": np.ndarray,   # x-coordinates
    "y": np.ndarray,   # y-coordinates
}

Custom loaders:

def my_loader(path):
    return {"q": data, "dt": 0.01, "Nx": 100, "Ny": 50, "x": x, "y": y}

pod = PODAnalyzer(file_path="ignored", data_loader=my_loader)

References

Method Key reference
POD Lumley (1967); Sirovich (1987)
mPOD Mendez et al. (2019)
SPOD Towne, Schmidt & Colonius (2018)
DMD Schmid (2010); Tu et al. (2014)
TLS-DMD Hemati et al. (2017)
HODMD Le Clainche & Vega (2017)
BSMD Schmidt (2020)

License

MIT — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openmodalpy-0.2.0.tar.gz (130.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openmodalpy-0.2.0-py3-none-any.whl (116.8 kB view details)

Uploaded Python 3

File details

Details for the file openmodalpy-0.2.0.tar.gz.

File metadata

  • Download URL: openmodalpy-0.2.0.tar.gz
  • Upload date:
  • Size: 130.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for openmodalpy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9b9f056f53f2f13ae9e675d9e8e9374887d1da6233c667e2e334bfeb74d45c03
MD5 3cda4adcf6b778c6e2381e3043b7f109
BLAKE2b-256 0f44bdab5f3803e3e4d4f006c84665baa5fc5d10ab66901b3f7437e6c65f9a0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for openmodalpy-0.2.0.tar.gz:

Publisher: release.yml on openfluids/openmodalpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openmodalpy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: openmodalpy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 116.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for openmodalpy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8f1e759b3f96b43d3ba43fc37dcee90db3e8c417056d624e438cec51e946759
MD5 3091f634bfeeb53a90eec9485074cd74
BLAKE2b-256 479268955daf82a62181a00b8f3f74b9f7da3ec26d44d9339c2ee9b651c519df

See more details on using hashes here.

Provenance

The following attestation bundles were made for openmodalpy-0.2.0-py3-none-any.whl:

Publisher: release.yml on openfluids/openmodalpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page