CAFest
Test bench and reference implementations of 13 estimators of the frequency shift (Doppler) between a reference and a received signal, computed from their cross-ambiguity function (CAF). One call, the same data, accuracy against the Cramér–Rao bound, and speed.
Installing
pip install cafest
Python 3.11 or newer.
Example
import cafest
from cafest import GridSpec
from cafest.signals import SignalSpec, generate
pair = generate(SignalSpec(shift=2345.6, snr_db=10.0), seed=1) # test signals: pair.ref, pair.rx; the true shift is 2345.6 Hz
grid = GridSpec(fs=600e3, f_min=0.0, f_max=10e3, df=1.0) # frequencies to search, Hz
for method in ("fft-unpadded", "czt", "hierarchical"):
print(method, cafest.estimate(method, pair.ref, pair.rx, grid).f_hat)
# fft-unpadded 2340.0 the nearest bin of the FFT, 60 Hz wide
# czt 2346.0 the nearest node of the 1 Hz grid
# hierarchical 2345.54 refined between the nodes
The figure shows the CAF of this pair near its peak (blue) and what fft-unpadded sees of it: the FFT without zero padding gives the CAF only at bins fs/N = 60 Hz apart (orange), so its maximum is found to within a bin. czt evaluates the CAF on the 1 Hz grid you give it, and hierarchical refines the maximum between the nodes.
Your own signals
ref and rx can be any 1-D complex arrays, not only those made by cafest.signals; GridSpec(fs=...) must be their real sampling rate, otherwise the result is in wrong Hz.
grid = GridSpec(fs=250e3, f_min=0.0, f_max=3000.0, df=1.0) # signals sampled at 250 kHz, search 0..3000 Hz
print(cafest.estimate("fft-zeropad", ref, rx, grid).f_hat) # ref, rx: your arrays of equal length
Who it is for
- Researchers and students in passive radar, GNSS and sonar who need to choose or compare CAF-based frequency-shift estimators.
- Authors of a new method: put it behind the same call and compare it with the others.
What it does and does not do
It covers the estimation stage: given a reference and a received signal (and, for an unknown delay, a window of lags) it returns the frequency shift in Hz. Pre-processing (clutter and direct-signal suppression), detection (CFAR) and tracking are outside the package. CPU only.
The model is one constant frequency shift (narrowband Doppler) of one target; scaling of the time axis (the wideband ambiguity function), a drifting shift and several shifts in one pair are not modelled.
The input is one pair of 1-D signals. Several channels, batches of pairs or 2-D signals are not supported (estimate raises ValueError for an array that is not 1-D); to process many pairs, call estimate in a loop.
Methods
13 methods in three groups:
| group | methods |
|---|---|
| CAF on a frequency grid | fft-zeropad, czt, filterbank-overlap-save, filterbank-scipy, block-decim |
coarse spectrum (bins fs/N wide, no zero padding) |
fft-unpadded |
| refinement of the peak | parabolic-interp, three-bin-interp, hierarchical, dtft-newton, capon-burg, capon-sample, music |
Two ways to call it: with a known delay (the signals are aligned), or with lags=(lo, hi) to search a window of lags for the delay.
Which method to choose
| if you need | start with |
|---|---|
| the CAF on a grid of any step and band | czt (no grid restrictions); fft-zeropad when fs/df is an integer |
| an estimate finer than the grid step | hierarchical (coarse grid, then a fine search around the peak); dtft-newton (no grid: Newton's method on the peak of the FFT) |
| a cheap refinement of an FFT peak | parabolic-interp on a fine grid; three-bin-interp for a tone that fills the whole frame |
an unknown delay (lags=(lo, hi)) |
any grid method over a window of lags; the refiners first find the lag with a coarse fft-unpadded stage |
| all lags at once | block-decim (block sums; d = 1 is exact, a larger d is approximate and suits small shifts) |
| high-resolution spectral estimates | capon-sample, music: expensive, mostly for comparison |
Status and limitations
Early version (0.1.0, alpha). Results come from simulation on synthetic signals with white noise; do not transfer conclusions about which method is better to real data without checking. See "Known limitations" in docs/OVERVIEW.md.
Building
The package is pure Python. Build it from the repository root with uv; the build backend is hatchling and uv fetches it itself:
uv build --wheel
The wheel appears in dist/. Install it with pip install dist/*.whl.
More information
- docs/OVERVIEW.md: how the package works, where each method comes from (the methods are implementations of published algorithms), the signal model and input data, what is checked, known limitations, references.
- docs/API.md: full description of
estimate,Resultand the method parameters. - tests/sanity/: quick acceptance tests with known answers (
pytest -m sanity); each test file starts with a docstring that says what it checks.
Metadata
Release files for cafest 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cafest-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cafest-0.1.0-py3-none-any.whl |
Release files / cafest-0.1.0-py3-none-any.whl
| Download URL | cafest-0.1.0-py3-none-any.whl |
|---|---|
| Size | 43.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d54e6e5c9e3bd0bf99004bec5e6f000bd360c3758989ec8cfb08c903ddc2b167
|
|
BLAKE2b-256 checksum How to use checksums |
715014274b589a1637087bd9f8b173de978f7f76370d07eac500d7cf07481a03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for cafest 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.