A compatible 'pytfd' port to Python3, with improvements in window handling, documentation, and testing. Pytfd provides a useful short-time-Fourier-transform (STFT) function suitable for biosonar analysis.
Go to file
welsberr c5c5eb38c4 Initial commit of port to Python3 2026-03-18 07:28:28 -04:00
examples Initial commit of port to Python3 2026-03-18 07:28:28 -04:00
src Initial commit of port to Python3 2026-03-18 07:28:28 -04:00
tests Initial commit of port to Python3 2026-03-18 07:28:28 -04:00
validation Initial commit of port to Python3 2026-03-18 07:28:28 -04:00
.gitignore Initial commit 2026-03-18 07:20:07 -04:00
LICENSE Initial commit of port to Python3 2026-03-18 07:28:28 -04:00
README.md Initial commit of port to Python3 2026-03-18 07:28:28 -04:00
pyproject.toml Initial commit of port to Python3 2026-03-18 07:28:28 -04:00

README.md

pytfd-compat

pytfd-compat is a Python 3 compatibility layer for the small pytfd API surface in this repository. It keeps the original centered-window STFT behavior available while fixing the weak points in the older ports:

  • explicit padding behavior
  • consistent window construction
  • tests for the core transforms
  • example programs that exercise the API

Replacement assessment

Modern libraries already cover parts of the old pytfd feature set:

  • SciPy provides production-quality STFT and ISTFT support.
  • librosa provides a higher-level STFT API for audio workflows.
  • tftb provides a larger collection of time-frequency distributions.

Those are useful building blocks, but none is a clean drop-in replacement for the legacy pytfd module layout and its dense centered-window STFT semantics. This package therefore implements the original transforms directly and uses modern SciPy window generation where it helps.

Licensing and provenance

The original upstream codebase was located at code.google.com/archive/p/pytfd/ and is MIT licensed. This compatibility package preserves that lineage while modernizing the implementation for Python 3.

What is included

  • pytfd_compat.stft.stft
  • pytfd_compat.stft.spec
  • pytfd_compat.wd.wd
  • pytfd_compat.pwd.pwd
  • pytfd_compat.sm.sm
  • pytfd_compat.windows.get_window
  • validation scripts comparing against SciPy and, when installed, tftb

Install

python -m pip install -e ./pytfd_compat

Test

cd pytfd_compat
pytest

Validation

cd pytfd_compat
PYTHONPATH=src python validation/run_validation.py

This runs reproducible comparisons against SciPy's ShortTimeFFT and reports alignment, numerical differences, and timing. If tftb is installed, the same script can extend the comparison set.

Examples

python examples/basic_stft.py
python examples/distributions_demo.py

If matplotlib is installed, the examples can also render images.