Skip to main content

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

Project description

OpenModalPy

CI PyPI License

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

This project is licensed under Apache-2.0. Originally developed by Ricardo A S Frantz. See LICENSE and NOTICE for license terms and attribution notices.

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.3.0.tar.gz (149.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.3.0-py3-none-any.whl (123.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openmodalpy-0.3.0.tar.gz
  • Upload date:
  • Size: 149.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.3.0.tar.gz
Algorithm Hash digest
SHA256 d7ddcb94d6a2ea4d95f0ff7bfc1876138895ef05e463fb9773c7e488c8b4de1a
MD5 318476f0d6c6c7ccec0ad2350e0b5cdc
BLAKE2b-256 d2f88005ffc98004eb92a8e357493e69058b903c89c82f2af295c1b57c056f01

See more details on using hashes here.

Provenance

The following attestation bundles were made for openmodalpy-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: openmodalpy-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 123.7 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2091c07c8cf271281e5cb4bf9ef0b4d245e3951872eb607f452638d5b068504d
MD5 eb8b6943ff37f9d72088e89cc933db7d
BLAKE2b-256 608788eea0d561ba3c50e1aeba9092b6f564d8330fdf5f92c29cfe979cd59a82

See more details on using hashes here.

Provenance

The following attestation bundles were made for openmodalpy-0.3.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