Skip to main content

optcutfreq

PyPI version DOI

Automatic search of optimal filter cutoff frequency based on residual analysis

The 'optimal' cutoff frequency (in the sense that a filter with such cutoff frequency removes as much noise as possible without considerably affecting the signal) is found by performing a residual analysis of the difference between filtered and unfiltered signals over a range of cutoff frequencies.
The optimal cutoff frequency is the one where the residual starts to change very little because it is considered that from this point, it's being filtered mostly noise and minimally signal, ideally.

Installation

pip install optcutfreq

The plots (parameter show=True) require matplotlib, which can be installed together with:

pip install "optcutfreq[plot]"

Or

conda install -c duartexyz optcutfreq

Examples

>>> import numpy as np
>>> from optcutfreq import optcutfreq
>>> y = np.cumsum(np.random.randn(1000))
>>> # optimal cutoff frequency based on residual analysis and plot:
>>> fc_opt = optcutfreq(y, freq=1000, show=True)

>>> # sane analysis but specifying the frequency limits and plot:
>>> optcutfreq(y, freq=1000, fclim=[200,400], show=True)

>>> # It's not always possible to find an optimal cutoff frequency
>>> # or the one found can be wrong (run this example many times):
>>> y = np.random.randn(100)
>>> optcutfreq(y, freq=100, show=True)

More examples, with Winter's benchmark data, are in a marimo notebook in the docs directory. Run it in your browser, no installation needed:

Notebook molab marimo.app
optcutfreq Open in molab Open with marimo

The notebook name links to a static preview with the outputs; the badges run the notebook in your browser with WebAssembly.

Or run it locally:

uvx marimo edit --sandbox docs/optcutfreq_notebook.py

How to cite this work

Here is a suggestion to cite this GitHub repository:

Marcos Duarte. (2021). optcutfreq: A Python module for automatic search of optimal filter cutoff frequency based on residual analysis (Version v0.0.8). Zenodo. http://doi.org/10.5281/zenodo.4599114

And a possible BibTeX entry:

@software{marcos_duarte_2021_4599114,
  author       = {Marcos Duarte},
  title        = {{optcutfreq: A Python module for automatic search of optimal filter cutoff frequency based on residual analysis}},
  month        = mar,
  year         = 2021,
  publisher    = {Zenodo},
  version      = {v0.0.8},
  doi          = {10.5281/zenodo.4599114},
  url          = {https://doi.org/10.5281/zenodo.4599114}
}

License

The non-software content of this project is licensed under a Creative Commons Attribution 4.0 International License, and the software code is licensed under the MIT license.

Metadata

Release files for optcutfreq 0.0.10

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

Source distribution (sdist)

Source distribution for optcutfreq 0.0.10
File Size Uploaded Provenance
optcutfreq-0.0.10.tar.gz 10.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for optcutfreq 0.0.10
File Interpreter ABI Platform
optcutfreq-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 18.0 kB

Release files / optcutfreq-0.0.10.tar.gz

Download URL optcutfreq-0.0.10.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e9a867f973b17c1e5817f1a40c9f66d6f6a11d9aedfe19b12a96ccaba7716999
BLAKE2b-256 checksum
How to use checksums
c693b0d1fef7ccfbbee6ba75c047eb9e6a18aaf40b970397d114846851f1d4b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Release files / optcutfreq-0.0.10-py3-none-any.whl

Download URL optcutfreq-0.0.10-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6df95f72872ab4fdc02caea60928896713f7b7155172a8e869739f5bbd51921
BLAKE2b-256 checksum
How to use checksums
e1cb8cb6aaaee28b8097c6ef057efec2cf25bf214b92113e511d008cd27a8c56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Security for optcutfreq 0.0.10

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for optcutfreq-0.0.10.tar.gz

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 Oct 21, 2026.

Transparency log

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.

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