Skip to main content

Scale Dependent Correlation in Python

Project description

sdcpy

DOI

Scale Dependent Correlation (SDC) analysis1, 2, 3 in Python.

Installation

Install from PyPI:

pip install sdcpy

Or using uv:

uv pip install sdcpy

Usage

import numpy as np
import pandas as pd
from sdcpy import SDCAnalysis

# Synthetic signal with transient pattern between indices 63-169
def tc_signal(i):
    error = np.random.normal()
    if 63 <= i <= 169:
        return np.sin(2 * np.pi * (1 / 37) * i) + 0.6 * error
    return error

np.random.seed(42)
ts1 = pd.Series([tc_signal(i) for i in range(250)])
ts2 = pd.Series([tc_signal(i) for i in range(250)])

# Run SDC analysis
sdc = SDCAnalysis(ts1, ts2, fragment_size=50, n_permutations=99)

# Generate 2-way SDC combi plot
fig = sdc.combi_plot(xlabel="TS1", ylabel="TS2")
fig.savefig("sdc_plot.png", dpi=150, bbox_inches="tight")

See examples/basic_usage.py for a complete example with synthetic data showing transient correlations.

Development

To set up a local development environment:

# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone and install
git clone https://github.com/AlFontal/sdcpy.git
cd sdcpy
uv sync --all-groups

# Run tests
uv run pytest

See CONTRIBUTING.md for more details.

References

  1. Rodó, X. (2001). Reversal of three global atmospheric fields linking changes in SST anomalies in the Pacific, Atlantic and Indian oceans at tropical latitudes and midlatitudes. Climate Dynamics, 18:203-217. DOI: 10.1007/s003820100171.

  2. Rodríguez, M.A. & Rodó, X. (2004). A primer on the study of transitory dynamics in ecological series using the scale-dependent correlation analysis. Oecologia, 138,485-504. DOI: 10.1007/s00442-003-1464-4.

  3. Rodó, X. & M.A. Rodriguez-Arias. (2006). A new method to detect transitory signatures and local time/space variability structures in the climate system: the scale-dependent correlation analysis. Climate Dynamics, 27:441-458. DOI: 10.1007/s00382-005-0106-4.

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

sdcpy-0.5.2.tar.gz (433.1 kB view details)

Uploaded Source

Built Distribution

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

sdcpy-0.5.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file sdcpy-0.5.2.tar.gz.

File metadata

  • Download URL: sdcpy-0.5.2.tar.gz
  • Upload date:
  • Size: 433.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sdcpy-0.5.2.tar.gz
Algorithm Hash digest
SHA256 3a8af41931d91a96028be02575477485399c69765d4e3a4d77860eecc9b9dd25
MD5 34158e91aa03558cc8715241e816eb20
BLAKE2b-256 11e0a0bffaac5fb39837e3d4a74da565d762b90497ae9325f7f56eae484860fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdcpy-0.5.2.tar.gz:

Publisher: build_and_publish.yml on AlFontal/sdcpy

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

File details

Details for the file sdcpy-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: sdcpy-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sdcpy-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b18afb149e8bcb441de81377e82b532b4c861938e0234440d276bc202d0ba2a
MD5 d65a9ed1f4f9961639fd173374e6c220
BLAKE2b-256 bdf38cefd591ab0d220db3f9326a39863127dede0b82f2785608ab491c2fe6f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdcpy-0.5.2-py3-none-any.whl:

Publisher: build_and_publish.yml on AlFontal/sdcpy

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