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.9

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.9
File Size Uploaded Provenance
optcutfreq-0.0.9.tar.gz 7.8 kB With provenance Details

Built distribution (wheel)

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

Total release size: 15.1 kB

Release files / optcutfreq-0.0.9.tar.gz

Download URL optcutfreq-0.0.9.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a979b63abe83458b322b54a62926be56affc9b5c13f2ee742d2d61f243891eff
BLAKE2b-256 checksum
How to use checksums
a0b47ea0fa927df6e904ec1044139c2ba11ae8111a9b32c3a983209fd6508bd3
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.9-py3-none-any.whl

Download URL optcutfreq-0.0.9-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac901cd2de0d231f5ac67c51ef3311c55be593cfe074e07037350903813c4c02
BLAKE2b-256 checksum
How to use checksums
32803d3067d45dc1f4474273f4d87b02e99ad316fa4142b979b5f29d0b7c6285
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.9

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.9.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