Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

matchedfilter

A fast single-threaded matched filter for x86. You give it a batch of data segments and a batch of templates; it correlates every pair and hands back only the peaks.

Not returning the full correlation is the point. Most searches threshold the output and throw the rest away, and once you say so up front the filter can skip work that could not have produced a peak anyway.

Status: work in progress. The API still moves, and there is a known calibration weakness in the hierarchical filter. See Caveats.

import matchedfilter as mf

filt = mf.MatchedFilter(16384, ndata=16, ntemplates=64)
filt.set_data(data_spectra)          # (16, 16384) complex64, already FFT'd
filt.set_templates(template_spectra) # (64, 16384) complex64

peaks = filt.run(binsize=1024, threshold=5.5)
peaks["index"], peaks["value"], peaks["magnitude"]

import matchedfilter as mf is the convention used throughout these docs.

Install

pip install --pre matchedfilter

--pre because this is an alpha release. Wheels are built for CPython 3.9 to 3.13 on manylinux x86-64; anywhere else pip falls back to the source distribution, which needs numpy and a C compiler.

x86-64 only for now. The kernels are AVX2 and AVX-512 intrinsics with no portable fallback, so a build on any other architecture stops with an error rather than producing a slow one. AVX-512 is used when the CPU has it and AVX2 otherwise, decided at runtime.

How it works

Inputs are frequency domain: the unnormalised forward transform of each segment, in natural order. Produce them with whatever you already use (numpy, MKL, FFTW); matchedfilter does not need to own that step.

The filter is built once and reused. Ingest conjugates the templates and stores both sides in the layout the correlation loop walks, which costs a few percent of a run and less as the batch grows.

run returns a structured array of shape (ndata, ntemplates, nbins) with fields index, value and magnitude. Bins whose peak fell below the threshold carry index == -1.

Supported lengths are 1024 and the powers of two from 4096 to 1048576.

Performance

Per (data, template) pair, 8x32 batch, one core of a Zen 5 desktop:

n matchedfilter numpy
1024 0.61 µs 18.98 µs 31x
4096 2.08 µs 37.81 µs 18x
16384 9.98 µs 127.04 µs 13x
65536 48.87 µs 568.56 µs 12x

numpy is a floor, not a rival. It is there so the comparison runs anywhere. Against MKL or FFTW the margin is much smaller, and part of what is left comes from computing peaks instead of a full correlation. Measure on your own box:

python -m matchedfilter.benchmark

Hierarchical filtering

HierarchicalFilter adds a cheap pre-pass: correlate against a low-frequency slice of the template, and only run the full-length filter where that slice leaves a peak plausible.

This helps only under an assumption about your templates: that enough of the matched-filter output power sits in the low band that a narrow slice gives a usable bound on the full result. For chirp-like templates whose power is concentrated at low frequency that tends to hold. For templates whose power is spread flat across the band, or concentrated high, the slice bounds nothing useful, and the pre-pass is pure added cost. It is worth checking against your own templates before relying on it.

hf = mf.HierarchicalFilter(16384, ndata=16, ntemplates=64,
                           snr=6.0,   # threshold you intend to use
                           fd=1e-3,   # false-dismissal budget
                           band=2048) # width of the cheap slice

hf.set_reference(expected_output_power)      # real frequency series, the OUTPUT
hf.set_templates(template_spectra)
hf.set_data(data_spectra)
peaks = hf.run(binsize=16384, threshold=6.0)

set_reference takes a real frequency series of length n holding the expected power of the filter output in each bin. Only its shape is used; the overall normalisation is divided out.

This is the output, not the template. The two differ whenever the data is coloured, and passing the template's own power will mis-set the gate: a broadband template reconstructing a narrowband signal is the case where it goes wrong by the largest factor.

The gate is one-sided by construction: peaks it reports are bit-identical to the flat filter's. It can only omit, never invent. fd is the budget for how often it is allowed to omit one.

On pure noise at n=4096 the gate runs about 7x faster than the flat filter. The saving scales with how little survives, so it grows with your threshold and falls toward 1x on data where most pairs trigger.

Caveats

  • The false-dismissal budget is not currently met at low thresholds. fd is honoured well at snr 6 and above. At snr 5.0 to 5.5 with a coarse band the gate omits more than it should: 1.4% against a 0.1% budget in a 418-template search. The cause is that the gate's recovery factors are measured from a mean frequency series, which is not a bound on any individual realisation. Tracked by an xfail test in tests/test_api.py and written up in docs/hierarchical.md.
  • Single-threaded by design. Parallelism is the caller's to arrange.
  • x86-64 Linux only, as above. Other architectures are not implemented rather than merely untested.

Development

pip install -e .[test]
pytest              # includes a C test that builds itself from source
python -m matchedfilter.benchmark

docs/ holds the design notes: how the hierarchical gate is calibrated, and measurements of the approaches that were tried and rejected.

License

MIT

Metadata

Release files for matchedfilter 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matchedfilter 0.1.0a1
File Size Uploaded
matchedfilter-0.1.0a1.tar.gz 223.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for matchedfilter 0.1.0a1
File
matchedfilter-0.1.0a1-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
matchedfilter-0.1.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
matchedfilter-0.1.0a1-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
matchedfilter-0.1.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
matchedfilter-0.1.0a1-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
matchedfilter-0.1.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
matchedfilter-0.1.0a1-cp310-cp310-musllinux_1_2_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.2+ x86-64 Details
matchedfilter-0.1.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
matchedfilter-0.1.0a1-cp39-cp39-musllinux_1_2_x86_64.whl CPython 3.9 CPython 3.9 Linux musl 1.2+ x86-64 Details
matchedfilter-0.1.0a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details

Total release size: 13.7 MB

Release files / matchedfilter-0.1.0a1.tar.gz

Download URL matchedfilter-0.1.0a1.tar.gz
Size 223.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cc1b327d9c2341b6b55834c2cb827ac23b6d71b78473034c25da38f5bfd4c0b6
BLAKE2b-256 checksum
How to use checksums
8f05bd2a2757e6bed6e4d72d5ce9adbebdf6f7aa2f771f914f601b0c1a9ce1c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp313-cp313-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
017b55d674a640beadbdc5624cc1d22c437e0d4fb370400930113e37d158ca54
BLAKE2b-256 checksum
How to use checksums
7ab2a3ff6bf99b4482c99e290bf8d139b821ddb81d21eced00f1d14f22091fe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a53eff6a76a2a394e0a2d23b20076e6251aaf5f1f6d717e7c881b6d30a816a99
BLAKE2b-256 checksum
How to use checksums
43cb8b1301c411eb1c693eaea4d361a2667708d107b14a188df71bc37e3f90b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp312-cp312-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
e757c8bc3094e69b514257bca23af54a4c621d68a4c35130781455c2234cc454
BLAKE2b-256 checksum
How to use checksums
f0886ac857b558d0ed014c57031520dc8d5377fa1174f71e1994b5b4e76e391c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
536cf9358dcf75008d914953ee7196bbfa071c7a47f9e73b7dea35c311ba78ec
BLAKE2b-256 checksum
How to use checksums
c6c2aefe9d40d80d3c902c6f3ceeb9a10b7e77f95196d35284906cd44c1a986a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp311-cp311-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
f337c741be1e2411bd95273270fef416308bb341aaa72135d23f34a922265867
BLAKE2b-256 checksum
How to use checksums
1b80dd84b9b6b70927f4d1c35bb222d88db78b84f199f31e9a25b29fa0e1bf7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e2bd8e27b7ec5101b5b5e476c913aa6e91652ddf185a1f6611849f44a084aea5
BLAKE2b-256 checksum
How to use checksums
09fafa058d554463dbbe8dd49f04ae4b00691568f04a0e876cfaf9ea4e2cc05d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp310-cp310-musllinux_1_2_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp310-cp310-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
585282a5887db4b25f13a4d5ee6104f7246986f2e2f1828b8d6f22df5cc8598f
BLAKE2b-256 checksum
How to use checksums
9d284eaad2dd877d49987466a537b5264c45f0dbb36d3613200bd1144e009c8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
714590edac065803ac2cd1c5fb1d005e5f710b285633c55ea90cb7097a0964ce
BLAKE2b-256 checksum
How to use checksums
5bfd311036bb9ecc7f9614aae13b9abbd12940a7a3b208728e032b41e98f6533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp39-cp39-musllinux_1_2_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp39-cp39-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
aa8d034c89b110592760c6cd1aa6061527912ea80951dc2fdc2c0d2a4d325b91
BLAKE2b-256 checksum
How to use checksums
ee19b10f2658e905d3cb61ac72b001ed23d300e79e7da28fdc99f07cd46998df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / matchedfilter-0.1.0a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL matchedfilter-0.1.0a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0ff0b2bb4cd94d3555ba74443bcf3d6464bf9bd9f1a2abf2553cda27a4ce0802
BLAKE2b-256 checksum
How to use checksums
6364c0287cf2a3907cb08ed22c3a872956f4ccc0a3873af7ce918ebf0f497cdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page