Skip to main content

PyPI version Downloads Documentation Status tests codecov DOI

ewstools

A Python package for early warning signals (EWS) of bifurcations in time series data.

Overview

Many systems in nature and society can undergo critical transitions—sudden, often irreversible shifts in dynamics. Examples include the outbreak of disease, ecosystem collapse, and cardiac arrhythmias. Mathematically, such transitions often correspond to bifurcations (tipping points) in an underlying dynamical system.

Scheffer et al. (2009) proposed early warning signals (EWS) for bifurcations based on noisy fluctuations in time series data, sparking a surge of related ways to predict bifurcations (see Dakos et al. (2024) for a recent review). More recently, deep learning has shown great potential for predicting bifurcations and their type (Bury et al. 2021).

ewstools is a Python package for computing and visualizing EWS in time series. It complements the R package by (Dakos et al. 2012) and meets growing demand for Python-based tools (PYPL, 2022).

Features include:

  • An intuitive, object-oriented framework for computing EWS
  • Detrending methods:
    • Gaussian kernel smoothing
    • LOWESS (Locally Weighted Scatterplot Smoothing)
  • Computation of critical slowing down (CSD) indicators:
    • Variance, standard deviation, coefficient of variation
    • Autocorrelation (at specified lags)
    • Skewness, kurtosis
    • Power spectra metrics
    • Entropy measures
    • Detrended Fluctuation Analysis (DFA)
  • Kendall tau statistics to quantify trends
  • Deep learning classifiers for bifurcation prediction (Bury et al. 2021)
  • Visualization tools
  • Built-in dynamical system models for testing EWS

ewstools uses pandas for dataframe handling, numpy for fast numerical computing, plotly for visualisation, lmfit for least-squares minimisation, arch for bootstrapping methods, EntropyHub for entropy computations, statsmodels and scipy for detrending methods, and TensorFlow for deep learning.

Install

Requires Python 3.9–3.12. Install via:

pip install --upgrade pip
pip install ewstools

For tutorials, install Jupyter notebook:

pip install jupyter notebook

To enable deep learning features, install TensorFlow:

pip install ewstools[tf]

Note: TensorFlow for ewstools is currently supported on Linux and macOS only.

To install the latest development version:

pip install git+https://github.com/thomasmbury/ewstools.git#egg=ewstools

(Development versions may be unstable.)

Tutorials

  1. Introduction to ewstools
  2. Spectral EWS
  3. Deep learning classifiers for bifurcation prediction

Quick demo

Code available in ./quick_demo.ipynb. Import ewstools and simulate a time series (e.g., the Ricker model):

import ewstools
from ewstools.models import simulate_ricker
series = simulate_ricker(tmax=500, F=[0,2.7])
series.plot();

Create a TimeSeries object:

ts = ewstools.TimeSeries(data=series, transition=440)

Detrend, compute EWS, and calculate trends:

ts.detrend(method='Lowess', span=0.2)
ts.compute_var(rolling_window=0.5)
ts.compute_auto(lag=1, rolling_window=0.5)
ts.compute_auto(lag=2, rolling_window=0.5)
ts.compute_ktau()

Get predictions from deep learning classifiers

for idx, classifier in enumerate(list_classifiers):
    ts.apply_classifier_inc(classifier, inc=10, verbose=0, name=str(idx))

Make an interactive visualization in Plotly:

ts.make_plotly()

For detailed demonstrations, see the tutorials.

Documentation

Full documentation available on ReadTheDocs.

Issues

Found a bug or have a suggestion? Please post it on the issue tracker.

Contributions are welcome! Feel free to reach out or submit a pull request.

Acknowledgements

This work is supported by an FRQNT postdoctoral research scholarship awarded to Dr. Thomas Bury. Previous support was provided by NSERC Discovery Grants awarded to Dr. Chris Bauch and Dr. Madhur Anand.

Citation info

If you find ewstools useful, please consider starring the repository ⭐ and citing:

Bury, Thomas M. "ewstools: A Python package for early warning signals of bifurcations in time series data." Journal of Open Source Software 8.82 (2023): 5038.

Release files for ewstools 2.1.3

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

Source distribution (sdist)

Source distribution for ewstools 2.1.3
File Size Uploaded
ewstools-2.1.3.tar.gz 37.6 kB Details

Built distribution (wheel)

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

Total release size:75.6 kB

Release files / ewstools-2.1.3.tar.gz

Download URL ewstools-2.1.3.tar.gz
Size 37.6 kB
Tags Source
SHA-256 checksum
How to use checksums
174a4aa7a7af0210fe168fd09bedea6f1a3a9f04990205ae5c9fac35e26d8f56
BLAKE2b-256 checksum
How to use checksums
d34eb4c85cc646e7e92449e81f5434b29434917c2f72466a831b0b54972f9a67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release files / ewstools-2.1.3-py3-none-any.whl

Download URL ewstools-2.1.3-py3-none-any.whl
Size 38.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aabbb46a53ed1c558d988923bcfc884c731e171cb73ba0cb60c0ec40dabbf933
BLAKE2b-256 checksum
How to use checksums
7e2e17b87573932bdbb8c804c09e65bb8f61a81355eb525e1397135798888acf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.1.3 This release

2 release files

2.1.2

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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