Skip to main content

Python package for the whole process of signal loading management, preprocessing, in-depth analysis and visualization of one-dimensional time series oscillation data/面向一维时序振荡数据的信号加载管理、预处理、深入分析与可视化全流程的Python包

Project description

signaltour

一个用于一维时间序列振荡数据分析的 Python 信号处理库。

概述

signaltour 为信号加载、预处理、分析和可视化提供了面向对象的工作流程。它通过模块化、可扩展的架构,为处理一维时域信号提供了全面的工具集。

特性

  • 信号管理:加载、生成和操作时间序列数据,自动处理元数据(采样频率、持续时间、单位)
  • 频谱分析:基于 FFT 的频域分析,支持可配置的窗函数和缩放方式
  • 模态分解:实现 EMD(经验模态分解)和 VMD(变分模态分解)算法
  • 时频分析:STFT、小波变换等时频表示方法
  • 数字滤波:FIR、IIR 和中值滤波,支持常用滤波器设计(Butterworth、Chebyshev 等)
  • 灵活可视化:基于任务队列的绘图系统,支持多子图布局和可扩展插件
  • 数据导入导出:支持常见文件格式,提供文件夹和数据集管理功能

安装

从 PyPI 安装

pip install signaltour

从源码安装

git clone https://github.com/xcw1129/signaltour.git
cd signaltour
pip install -e .

依赖要求

  • Python ≥ 3.11
  • numpy ≥ 2.0.0
  • scipy ≥ 1.14.0
  • matplotlib ≥ 3.9.0
  • pandas ≥ 2.2.2
  • anytree ≥ 2.13.0
  • pyarrow ≥ 22.0.0

快速入门

from signaltour import Signal, Analysis, Plot

# 生成仿真信号
sig = Signal.periodic(
    fs=1000,
    T=1.0,
    CosParams=((10, 1.0, 0), (50, 0.5, 0)),  # (频率, 幅值, 相位)
    noise=0.1
)

# 执行频谱分析
analyzer = Analysis.SpectrumAnalysis(sig, isPlot=True)
spectrum = analyzer.ft()  # 傅里叶变换

# 创建自定义可视化
plot = Plot.LinePlot()
plot.waveform(sig)
plot.show()

架构设计

signaltour 采用三层模块化设计:

Signal 模块(信号模块)

提供信号表示、文件读写、仿真生成、采样处理和滤波的核心数据结构。

from signaltour import Signal

# 生成周期信号
sig = Signal.periodic(
    fs=1000,
    T=2.0,
    CosParams=((50, 1.0, 0),),  # (频率, 幅值, 相位)
    noise=0.1
)

# 生成冲击信号
sig_impulse = Signal.impulse(
    fs=4000,
    T=1.0,
    ImpParams=(1400, 20, 0.05, 20, 0.01),  # (中心频率, 出现频率, 滑移百分比, 幅值, 衰减时间)
)

# 应用滤波
filtered = Signal.filtIIR(sig, cutoff=100, order=4, btype='low', ftype='butter')

# 重采样
resampled = Signal.resample(sig, new_fs=500)

Analysis 模块(分析模块)

为信号分析算法提供标准化框架,支持可选的可视化输出。

from signaltour import Signal, Analysis

sig = Signal.periodic(fs=1000, T=1.0, CosParams=((50, 1.0, 0),))

# 频域分析
analyzer = Analysis.SpectrumAnalysis(sig, isPlot=False)
spectrum = analyzer.ft(window='汉宁窗')  # 傅里叶变换
psd = analyzer.psd(window='汉宁窗')  # 功率谱密度

# 模态分解
emd_analysis = Analysis.EMDAnalysis(sig, isPlot=True)
imfs = emd_analysis.emd(decNum=5)  # 经验模态分解

vmd_analysis = Analysis.VMDAnalysis(sig, isPlot=True)
modes = vmd_analysis.vmd(K=3)  # 变分模态分解

# 时频分析
stft_analysis = Analysis.STFTAnalysis(sig, isPlot=True)
t_axis, f_axis, tfr = stft_analysis.stft(segNum=256)  # 短时傅里叶变换

Plot 模块(绘图模块)

基于任务队列的绘图引擎,提供链式 API 和插件支持。

from signaltour import Signal, Analysis, Plot

sig1 = Signal.periodic(fs=1000, T=1.0, CosParams=((50, 1.0, 0),))
sig2 = Signal.periodic(fs=1000, T=1.0, CosParams=((100, 0.5, 0),))

# 多信号波形图
plot = Plot.LinePlot(ncols=2, title="信号对比")
plot.waveform(sig1)  # 第一个子图
plot.waveform(sig2)  # 第二个子图
plot.show()

# 频谱可视化
analyzer = Analysis.SpectrumAnalysis(sig1)
spectrum = analyzer.ft()

plot = Plot.LinePlot()
plot.spectrum(spectrum)
plot.show()

# 二维时频谱图
stft_analysis = Analysis.STFTAnalysis(sig1)
t_axis, f_axis, tfr = stft_analysis.stft(segNum=256)

plot = Plot.ImagePlot()
plot.spectrogram(time=t_axis, freq=f_axis, matrix=tfr)
plot.show()

# 使用插件
plot = Plot.LinePlot()
plot.spectrum(spectrum)
plot.add_plugin_to_task(Plot.PeakfinderPlugin(threshold=0.8))  # 峰值查找插件
plot.show()

许可证

Apache License 2.0

详见 LICENSE 文件。

联系方式

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

signaltour-1.2.0.tar.gz (5.7 MB view details)

Uploaded Source

Built Distribution

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

signaltour-1.2.0-py3-none-any.whl (5.7 MB view details)

Uploaded Python 3

File details

Details for the file signaltour-1.2.0.tar.gz.

File metadata

  • Download URL: signaltour-1.2.0.tar.gz
  • Upload date:
  • Size: 5.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for signaltour-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e1e4a9fb4deaabee98ee2787f8f749570f23433bc64aa79dc9cc80795fd156d8
MD5 a90e3edb010c1400e14e1d2efc0d0e7c
BLAKE2b-256 09a4584c9a980e4225445cba78354131c654401e6ddaad057934537908d559ce

See more details on using hashes here.

File details

Details for the file signaltour-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: signaltour-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for signaltour-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fba186843077e1bacc75451269991ba0582cf2529d9acfe9b706260412b0779
MD5 7d35e1ca017d0b8636ea08b8be7b35f1
BLAKE2b-256 81628a79b2c7b5e80cfcf7e7c48bcdcaeb662c84a5af0c46ef90372dc89212f9

See more details on using hashes here.

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