SigFit is a package to help you fit a sine wave to noisy sine data
Project description
SigFit - Sine Wave Fitting for Python
I work with Analog To Digital Converters (ADCs) for my research project and I need to fit sine waves frequently to evaluate their performance.
I wrote the SigFit sine fitting library in C language but later I needed to use Python so wrappd my code with Python; In other words extended Python with C/C++
Features:
This code has two modes:
- Three Parameter Fitting
- Four Parameter Fitting
Three Parameter Fitting
Three Paramter Fitting requires the Frequency of input signal, Sampling Frequency and Data array and will return co-efficients of a sine wave.
returned object: (A, B, C)
Acos(wt) + Bsin(wt) + C
Four Parameter Fitting
Four Parameter Fitting accepts the arguments of Three Paramter Fitting as well as an initial guessed frequency. The output is co-efficients of the a sine wave plus the best fitted frequency. I have tested it, it's very accurate.
Four Parameter Fitting is implemented in C, but it's not wrapped in Python yet.
returned object: (A, B, C, Frequency)
Performance:
I haven't done any benchmark tests but it's fast! The overhead comes from converting Python list to C array. If you know how to speed-up the conversion, please go ahead and fix it. I'll accept your pull request.
Installation:
It's on PyPi. Just do:
$ pip install SigFit
Usage:
The usage is extremely easy:
import SigFit
#data_samples = your noisy data samples
#freq = the frequency of the data
#fs = the sampling frequency
A, B, C = SigFit.FitThreeParam(data_samples, freq, fs)
Acknowledge:
This algorithm was written based on the following paper written by Peter Händel
Properties of the IEEE-STD-1057 four-parameter sine wave fit algorithm
Unfortunately, Dr. Peter Händel, at KTH in Sweden passed away in 2019 after a long period of illness.
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
File details
Details for the file SigFit-1.1.1.tar.gz.
File metadata
- Download URL: SigFit-1.1.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5ea314c23e3bbce3067d9d3673fa03510e2de5ab7c14fd1da2a08ada40dfb5b
|
|
| MD5 |
a3b72406a49dd94d55140f9eb5868da6
|
|
| BLAKE2b-256 |
907a0930637ac6fee79a48a563f97d457fdd1598f3710972c36be9ba5c53b2b9
|