Skip to main content

KEWS: Koopman Early Warning Signals

KEWS (pronounced “cues,” as in cues to potential tipping) is a JAX package for Koopman-based early warning signals of bifurcation- and rate-induced tipping.

Python JAX License: MIT PyPI version PyPI downloads arXiv

Abstract

Abrupt transitions in complex systems are often preceded by early warning signals. However, most indicators rely on the notion of critical slowing down and do not generally extend to rate-induced tipping where transitions can occur without local loss of stability. This is problematic in stochastic, nonautonomous systems where internal variability and time-varying variables interact to shape tipping onset.

We use Koopman operator theory to develop a unified early warning framework for both bifurcation and rate-induced tipping in stochastic systems. Our approach builds on residual Koopman mode decomposition that measures discrepancies between dynamics and their finite-dimensional approximation, and extends it to the control setting by augmenting the observable space with time-varying control variables.

In idealized examples, the resulting indicators recover expected signatures near bifurcation points and improve detection in rate-induced regimes where classical indicators fail. We further show that learned embeddings through deep learning outperform prescribed dictionaries, especially in a high-dimensional setting.

Applied to simulations of the Atlantic Meridional Overturning Circulation, our Koopman-based indicators distinguish tipping from non-tipping trajectories and reveal interpretable spectral signatures prior to critical transition.

Installation

Python 3.11 or newer is required. Install the library from PyPI:

pip install kews

To reproduce the paper or develop the code:

git clone https://github.com/juannat7/kews.git
cd kews
pip install -e ".[paper,dev]"

Reproduction instructions are in examples for the model systems and experiments for the coupled AMOC and empirical cases.

Quickstart

Compute rolling ResKMD residuals from a scalar time series:

import jax.numpy as jnp
from jax import random

import kews
from kews.observables import time_delay

time = jnp.linspace(0, 10 * jnp.pi, 100)
state = jnp.sin(time) + 0.01 * random.normal(random.key(7), time.shape)

signal = kews.resdmd(
    state,
    window=50,                           # Window length in samples (or a fraction, e.g. 0.5)
    observable=time_delay(n_delay=10),   # Time-delay dictionary with 10 coordinates
    rank=0.9,                            # Retain 90% of the SVD energy
)

# One residual per time step; the first 49 entries are NaN.
print(signal.shape)  # (100,)

Control-aware residuals

Pass a control time series aligned with the state:

control = jnp.linspace(-1, 1, state.size)
controlled_signal = kews.resdmd(
    state,
    window=50,
    observable=time_delay(10),
    control=control,
)

Observable choices

Use fixed random Fourier features instead of delay coordinates:

from kews.observables import rff

random_signal = kews.resdmd(
    state,
    window=50,
    observable=rff(n_features=100, scale=0.2, seed=7),
)

The random basis stays fixed across windows. An autoencoder can learn the features:

from kews.observables import mlp

learned_signal = kews.resdmd(
    state,
    window=50,
    observable=mlp(hidden_layers=(16, 8), bottleneck_dim=3, seed=7),
    fit_kwargs={"epochs": 200, "batch_size": 32, "lr": 1e-3},
)

Training uses only the first window; the encoder is then frozen. Create a new observable for each independent fit. Paper notebooks specify their full training settings.

Spectral diagnostics

from kews import diagnostics

fit = diagnostics.fit_operator(state, observable=time_delay(10), rank=0.9)
generator = diagnostics.generator_eigenvalues(fit["eigvals"], dt=1.0)
dominant = diagnostics.dominant_mode(generator, dt=1.0)

dt is the sampling interval in the units of the input data. The mode summary includes decay rate, oscillation period, and e-folding time.

Citation

@article{nathaniel2026koopman,
  title={Koopman early warning signals for bifurcation and rate-induced tipping},
  author={Nathaniel, Juan and Roesch, Carla and DeSantis, Derek and Kooloth, Parvathi and Fan, Hang and Lucarini, Valerio and Romanou, Anastasia and Gentine, Pierre},
  journal={arXiv preprint arXiv:2608.14716},
  year={2026}
}

Code uses the MIT license. External datasets retain their original terms.

Metadata

Release files for kews 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kews 0.1.0
File Size Uploaded Provenance Actions
kews-0.1.0.tar.gz 243.1 kB Without provenance Details for kews-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kews 0.1.0
File Interpreter ABI Platform Actions
kews-0.1.0-py3-none-any.whl Python 3 none any Details for kews-0.1.0-py3-none-any.whl

Total release size: 258.0 kB

Release files / kews-0.1.0.tar.gz

Download URL kews-0.1.0.tar.gz
Size 243.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b6018605d10cbe35ba04744baf7a76dbcab0a55e98e7e0e29b9cbbfc673e97cb
BLAKE2b-256 checksum
How to use checksums
8c326e7f2a0e7cb2a6f411befe33a872e55d533802a534ee4bbe0aaeec0bbaf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / kews-0.1.0-py3-none-any.whl

Download URL kews-0.1.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53e55817af313d20e8fc685282387b9a251c7c619c7529373e061f82ec3df9ba
BLAKE2b-256 checksum
How to use checksums
a24e8fb21092206ded3570e641c432a1d79988a7e25753174aa8f09910c5f3cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Security for kews 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page