CZT
Chirp Z-Transform
Install / Use
/learn @garrettj403/CZTREADME
Chirp Z-Transform (CZT)
From Wikipedia:
The chirp Z-transform (CZT) is a generalization of the discrete Fourier transform (DFT). While the DFT samples the Z plane at uniformly-spaced points along the unit circle, the chirp Z-transform samples along spiral arcs in the Z-plane, corresponding to straight lines in the S plane. The DFT, real DFT, and zoom DFT can be calculated as special cases of the CZT.
Getting Started
You can install the CZT package using pip:
# to install the latest release (from PyPI)
pip install czt
# to install the latest commit (from GitHub)
git clone https://github.com/garrettj403/CZT.git
cd CZT
pip install -e .
# to install dependencies for examples
pip install -e .[examples]
# to install dependencies for testing
pip install -e .[testing]
Example
Consider the following time-domain signal:
<p align="center"> <img src="https://raw.githubusercontent.com/garrettj403/CZT/main/examples/results/signal.png" width="500"> </p>This is an exponentially decaying sine wave with some distortion from higher-order frequencies. We can convert this signal to the frequency-domain to investigate the frequency content using the Chirp Z-Transform (CZT):
<p align="center"> <img src="https://raw.githubusercontent.com/garrettj403/CZT/main/examples/results/freq-domain.png" width="500"> </p>Note that the CZT also allows us to calculate the frequency response over an arbitrary frequency range:
<p align="center"> <img src="https://raw.githubusercontent.com/garrettj403/CZT/main/examples/results/zoom-czt.png" width="500"> </p>We can see that the signal has frequency components at 1 kHz, 2.5 kHz and 3.5 kHz. To remove the distortion and isolate the 1 kHz signal, we can apply a simple window in the frequency-domain:
<p align="center"> <img src="https://raw.githubusercontent.com/garrettj403/CZT/main/examples/results/windowed-freq-domain.png" width="500"> </p>Finally, we can use the Inverse Chirp Z-Transform (ICZT) to transform back to the time domain:
<p align="center"> <img src="https://raw.githubusercontent.com/garrettj403/CZT/main/examples/results/windowed-time-domain.png" width="500"> </p>As we can see, we were able to remove the higher-order frequencies that were distorting our 1 kHz signal.
You can find this example and others in the examples/ directory.
References
Related Skills
node-connect
334.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
334.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.1kCommit, push, and open a PR
