Implementation of Goertzel algorithm written in Rust
Project description
fastgoertzel
A Python implementation of the Goertzel algorithm built using Rust
for improved run time and efficiency on large datasets and loops.
To-Do:
-
Improved speed.(Significantly increased speed by using numpy arrays). - Implement benchmarking for speed comparison. (fastgoertzel is ~75 times faster than native python)
- Add IIR and k-th FTT implementation of Goertzel.
- Add support for sampling rate.
Installation
You can install using two methods:
Using pip install
:
$ pip install fastgoertzel
Using maturin
after cloning repository:
$ git clone git://github.com/0zean/fastgoertzel.git
$ cd fastgoertzel
$ maturin develop
Usage
import numpy as np
import pandas as pd
import fastgoertzel as G
def wave(amp, freq, phase, x):
return amp * np.sin(2*np.pi * freq * x + phase)
x = np.arange(0, 512)
y = wave(1, 1/128, 0, x)
amp, phase = G.goertzel(y, 1/128)
print(f'Goertzel Amp: {amp:.4f}, phase: {phase:.4f}')
# Compared to max amplitude FFT output
ft = np.fft.fft(y)
FFT = pd.DataFrame()
FFT['amp'] = np.sqrt(ft.real**2 + ft.imag**2) / (len(y) / 2)
FFT['freq'] = np.fft.fftfreq(ft.size, d=1)
FFT['phase'] = np.arctan2(ft.imag, ft.real)
max_ = FFT.iloc[FFT['amp'].idxmax()]
print(f'FFT amp: {max_["amp"]:.4f}, '
f'phase: {max_["phase"]:.4f}, '
f'freq: {max_["freq"]:.4f}')
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
fastgoertzel-0.2.1.tar.gz
(35.2 kB
view details)
Built Distribution
File details
Details for the file fastgoertzel-0.2.1.tar.gz
.
File metadata
- Download URL: fastgoertzel-0.2.1.tar.gz
- Upload date:
- Size: 35.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42828e09a5f21e0f1a0f9e3450705e470aa3e76fa0e5c9f12ffebef2b5c06ea8 |
|
MD5 | 1f8abe4084731adf5a1c9331f239d9c3 |
|
BLAKE2b-256 | fe920b3ed65f8185641d24208f30750ca7b08957aa1bdac9f12c518f9550f337 |
File details
Details for the file fastgoertzel-0.2.1-cp37-abi3-win_amd64.whl
.
File metadata
- Download URL: fastgoertzel-0.2.1-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 110.2 kB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31886adbeca431fb6ad9e26905d4bc5b366a8437f86f838155d13571b7953d2a |
|
MD5 | e9ddade664a44f9f49a1cd01c6f6a5dc |
|
BLAKE2b-256 | 24ed3d573a1837f908efd0dac5a6eb6adbe353c92ce2b09136372b62bc22959b |