A Python implementation of the Circulant singular spectrum analysis (CiSSA) algorithm (https://github.com/jbogalo/CiSSA)
Project description
pyCiSSA
A Python package implementing Circulant Singular Spectrum Analysis (CiSSA) for time series decomposition, reconstruction, and significance testing. Please check out the original Matlab verion written by the creator of the CiSSA method - https://github.com/jbogalo/CiSSA
Table of Contents
Features
- Gap Filling: Robust handling of missing values before analysis .
- CiSSA Core: Circulant Singular Spectrum Analysis for extracting oscillatory components, trend, noise.
- Time-Frequency Analysis: Compute and visualize the instantaneous frequency and amplitude of reconstructed components.
- Trend Extraction: Automated extraction of the trend component using CiSSA.
- Noise Removal: Automated noise removal using CiSSA.
- Monte Carlo Significance Testing: Evaluate component significance with surrogate data tests.
Installation
# Clone the repository and switch to the pycissa_v2 branch
git clone -b pycissa_v2 https://github.com/LukeAFullard/pyCiSSA.git
cd pyCiSSA
# Install dependencies via Poetry
poetry install
Note: Python 3.8+ is required. All dependencies are managed via
pyproject.toml.
Quick Start
import numpy as np
from pycissa import Cissa
# 1. Prepare equally spaced time array `t` and data array `x`
N = 500
t = np.linspace(0, 1, N)
x = np.sin(2 * np.pi * t) + 0.1 * np.random.randn(N)
# 2. Initialize Cissa
# The window length L critically influences frequency resolution and trend separation.
cissa = Cissa(t, x)
# 3. Run the full automated pipeline
# auto_cissa: fixes censoring/nan, plots original, fits CiSSA, Monte Carlo test, grouping, frequency-time, trend, autocorrelation, periodogram citeturn1file3
cissa.auto_cissa(L=50, alpha=0.05, K_surrogates=5, surrogates='random_permutation')
# 4. Retrieve results and figures
# - Numerical outputs in `cissa.results['cissa']`
# - Matplotlib figures in `cissa.figures['cissa']`
print(cissa.figures['cissa'].keys())
# 5. Use standalone auto-functions if required
# • auto_fix_censoring_nan: clean outliers & NaNs citeturn1file4
# • auto_denoise: denoise signal and plot citeturn1file0
# • auto_detrend: detrend signal and plot citeturn1file1
cissa.auto_fix_censoring_nan(L=50)
cissa.auto_denoise(L=50, plot_denoised=True)
cissa.auto_detrend(L=50, plot_result=True)
Note: Always choose
L(window length) between ~N/3 to N/2 as a starting point, then inspect the eigenvalue spectrum to fine-tune. The default behavior of auto-functions usesL = floor(N/2)ifLis omitted. citeturn1file3
Module Overview
This package exposes a single class, Cissa, which encapsulates the full CiSSA workflow:
-
Initialization
Cissa(t, x): Create an instance with time arrayt(1D, equally spaced) and data arrayx(same length).
-
Automated Pipelines
auto_fix_censoring_nan(L): Impute missing or censored values before analysis.auto_cissa(L, alpha, K_surrogates, surrogates): Run the complete pipeline—cleaning, decomposition, Monte Carlo testing, grouping, time-frequency analysis, trend analysis, and diagnostic plots.auto_denoise(L, plot_denoised): Perform denoising and plot the denoised series.auto_detrend(L, plot_result): Perform detrending and plot the trend vs. detrended signal.
-
Postprocessing Helpers These methods are available on the
Cissainstance afterfitorauto_cissa:post_run_monte_carlo_analysis(alpha, K_surrogates, surrogates): Monte Carlo significance testing.post_group_components(grouping_type): Automatic grouping of oscillatory components.post_run_frequency_time_analysis(): Instantaneous frequency and amplitude calculation.post_analyse_trend(): Trend extraction and smoothing.plot_autocorrelation(): Autocorrelation of residuals.post_periodogram_analysis(): Periodogram of the original and reconstructed signals.
API Reference
Since Cissa encapsulates all functionality, the public API comprises:
from pycissa import Cissa, __version__
-
Cissa Full-featured class for CiSSA analysis. See docstrings in
pycissa/processing/cissa/cissa.pyfor complete parameter listings and return values. -
version Package version string.
Explore the examples/ directory for Jupyter notebooks.
API Reference
Detailed API documentation is available in the docs/ folder (coming soon) or via the docstrings in each module.
Testing
Run unit tests with pytest:
pytest tests/
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository and create a new branch.
- Follow the existing code style (PEP8) and add tests.
- Submit a pull request describing your changes.
License
Distributed under the MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycissa-0.1.0.tar.gz.
File metadata
- Download URL: pycissa-0.1.0.tar.gz
- Upload date:
- Size: 108.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.6 Linux/4.15.0-142-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
103ff551b9c712cb49d3804f1111b8fb6e2ccb64da911babdc618b576de6d662
|
|
| MD5 |
5145ae12d365b29f1f6d1b75ae8174fb
|
|
| BLAKE2b-256 |
a618a5babe7b8522119218506bd2962b81a5fa311e86c8c10c7264b8e124d861
|
File details
Details for the file pycissa-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pycissa-0.1.0-py3-none-any.whl
- Upload date:
- Size: 121.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.6 Linux/4.15.0-142-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df0c6a86c18ecea4d985b102a6b96e21fedd9333a418fd68eecff553f6bce0c7
|
|
| MD5 |
8a7d8d06c5ac91c04d8805c36517f64c
|
|
| BLAKE2b-256 |
6367f5a20797c43a472dea169777fdc4b3db3fb28c2f96b839a332a4d1c20d73
|