Skip to main content

PIWavelet

A modern Python library for continuous wavelet analysis, cross-wavelet transforms, and wavelet coherence.

PIWavelet provides a modular and scientifically robust implementation of:

  • Continuous Wavelet Transform (CWT)
  • Cross-Wavelet Transform (XWT)
  • Wavelet Coherence (WTC)
  • Torrence & Webster smoothing operators
  • Cone of Influence (COI)
  • Multiple mother wavelets
  • Publication-quality visualization tools

The library is designed for scientific computing, signal analysis, geophysics, astrophysics, climatology, and time-frequency analysis applications.


Features

Continuous Wavelet Transform

  • Complex and real wavelets
  • FFT-based implementation
  • Scale-frequency conversion
  • Cone of Influence estimation
  • Multi-scale time-frequency analysis

Cross-Wavelet Transform

  • Cross-wavelet power
  • Relative phase analysis
  • Shared spectral energy detection

Wavelet Coherence

  • Magnitude-squared wavelet coherence
  • Torrence-Webster smoothing operators
  • Scale-aware temporal smoothing
  • Localized time-frequency coherence analysis
  • Phase relationship visualization

Supported Wavelets

  • Morlet
  • Paul
  • DOG (Derivative of Gaussian)
  • Mexican Hat

Visualization

  • Wavelet power spectrum plots
  • Cross-wavelet plots
  • Wavelet coherence plots
  • Cone of Influence overlay
  • Phase arrows
  • Log-period axis formatting
  • Publication-ready figures

Installation

pip install piwavelet

Development installation:

git clone <repository-url>
cd piwavelet
pip install -e .

Quick Start

Continuous Wavelet Transform

import numpy as np

from piwavelet.transforms import cwt
from piwavelet.wavelets import Morlet

# synthetic signal

dt = 0.25

time = np.arange(0, 512) * dt

signal = (
    np.sin(2 * np.pi * time / 32)
    + 0.5 * np.sin(2 * np.pi * time / 8)
)

result = cwt(
    signal=signal,
    dt=dt,
    wavelet=Morlet(),
)

Wavelet Coherence

import numpy as np

from piwavelet.transforms import wavelet_coherence
from piwavelet.wavelets import Morlet

np.random.seed(42)

# ------------------------------------------------------------------
# synthetic signal
# ------------------------------------------------------------------

dt = 0.25

time = np.arange(0, 512) * dt

# localized coherent structure
period = 16

shared = np.sin(
    2 * np.pi * time / period
)

x = shared.copy()

x += 0.4 * np.sin(
    2 * np.pi * time / 6
)

x += 0.5 * np.random.randn(len(time))

window = np.exp(
    -0.5 * ((time - 64) / 5) ** 2
)

y = (
    window * shared
    + 0.8 * np.random.randn(len(time))
)

# ------------------------------------------------------------------
# wavelet coherence
# ------------------------------------------------------------------

result = wavelet_coherence(
    x,
    y,
    dt=dt,
    wavelet=Morlet(),
)

This example produces a localized coherence region centered approximately at:

  • time ≈ 64
  • period ≈ 16

which demonstrates proper time-frequency localization.


Plotting

Wavelet Coherence Plot

from piwavelet.plotting import plot_wavelet_coherence

fig = plot_wavelet_coherence(
    result,
    title="Wavelet Coherence",
    show_phase=True,
)

Scientific Background

PIWavelet follows the classical formulations presented in:

  • Torrence, C. & Compo, G. P. (1998) "A Practical Guide to Wavelet Analysis"

  • Torrence, C. & Webster, P. J. (1999) "Interdecadal Changes in the ENSO-Monsoon System"

  • Grinsted, A., Moore, J. C., & Jevrejeva, S. (2004) "Application of the cross wavelet transform and wavelet coherence to geophysical time series"

Implemented features include:

  • scale-normalized coherence
  • Torrence-Webster smoothing
  • scale-dependent temporal smoothing
  • cone of influence estimation
  • phase relationship analysis

Architecture

The project is organized into modular components:

piwavelet/
├── transforms/
├── wavelets/
├── smoothing/
├── plotting/
├── significance/
└── utils/

Development Goals

Planned and ongoing features:

  • Significance testing
  • Monte Carlo coherence significance
  • Partial wavelet coherence
  • Multivariate coherence
  • GPU acceleration
  • Streaming transforms
  • Better statistical diagnostics
  • Xarray integration
  • Interactive plotting

License

MIT License


Contributing

Contributions, issues, and suggestions are welcome.

Please open an issue or submit a pull request.

Metadata

Release files for piwavelet 2.0.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 piwavelet 2.0.0
File Size Uploaded Provenance
piwavelet-2.0.0.tar.gz 2.0 MB Without provenance Details

Built distribution (wheel)

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

Total release size: 2.1 MB

Release files / piwavelet-2.0.0.tar.gz

Download URL piwavelet-2.0.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
e5033c431efaad63a6b3b70bec58fa6b114018c68795b574b6545374c56cb895
BLAKE2b-256 checksum
How to use checksums
b221b1aa45859accebe29b43a6eea6f7362d40b88b3132c3fd48082e6416d98b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / piwavelet-2.0.0-py3-none-any.whl

Download URL piwavelet-2.0.0-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba48a0066b757ecf9f5df12e9869f32224c113f1ec28567bdf197fa399948fb8
BLAKE2b-256 checksum
How to use checksums
1560cb2bdf466d3a76c06b951382070d137999fd0b20aeb6b94de4bf1d1c4c1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for piwavelet 2.0.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.

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