Python for RF and SDR prototyping.
Project description
rfproto
Python library for RF and SDR prototyping. Provides reusable methods for RF measurements, communication systems, radar, antenna arrays, and related signal processing tasks. The library supports both floating-point and fixed-point arithmetic for modeling hardware implementations (FPGA/ASIC).
Features & Modules
The library is organized into focused modules for different aspects of RF/SDR signal processing:
Core Signal Processing
nco.py: Numerically Controlled Oscillator (NCO) with both floating-point and fixed-point support, including frequency-to-FCW conversion and Taylor series approximations for sine/cosine generationfilter.py: Filter design including Raised Cosine, Root Raised Cosine, and polyphase filteringmultirate.py: Multirate signal processing (interpolation, decimation, rational resampling with polyphase filters)sig_gen.py: Signal generation utilities for test waveforms and modulated signalsmodulation.py: Modulation/demodulation schemes for digital communications
Measurements & Analysis
measurements.py: Signal quality metrics (EVM, PSD, SFDR, SNR, and spectral analysis)plot.py: Visualization utilities (time-domain, frequency-domain, constellation diagrams, eye diagrams)impairments.py: Channel impairment modeling (noise, phase offset, timing errors)
Fixed-Point Arithmetic
fxp_int.py: Fixed-point integer class modeling hardware bit-width constraints with overflow/wrapping behaviorutils.py: Fixed-point/floating-point conversion, binary representation, rounding methods, and dB/magnitude conversions
Control & Processing
agc_magest.py: Automatic Gain Control (AGC) using magnitude estimationpi_filter.py: Proportional-Integral filter implementationssignal.py: Basic signal operations and transformationsfrequency.py: Frequency-related utilities and conversions
Architecture
Fixed-Point Arithmetic Support
A key feature of rfproto is dual floating-point and fixed-point implementations for hardware prototyping:
fxp_intclass: Models fixed bit-width integers with 2's complement overflow/wrapping behavior- Conversion utilities:
dbl_to_fxp()/fxp_to_dbl()for converting between representations - Rounding operations:
fxp_round_halfup()/fxp_truncate()for proper fixed-point arithmetic - Q-format notation: Uses standard Q-format (e.g., Q0.15 for 16-bit signed with 15 fractional bits)
- Switchable implementations: Some modules like
nco.pyhaveuse_fxpflags to toggle between floating-point and fixed-point
Design Patterns
- Normalized filters: Filter functions return normalized coefficients (sum to 1.0 for unity passband gain)
- Rational resampling: Use
multirate.get_rational_resampling_factors()for optimal interpolation/decimation ratios - Type hints: All functions include type hints for parameters and return values
- Doctests: Inline documentation examples that serve as both docs and tests
Developing
Building & CI
- Install editable local version (preferably within a venv) with all optional packages for testing with
$ pip install --upgrade -e .[docs,test](add--userif not invenv). - Install pre-commit checks with
$ ln -sf ../../scripts/pre-commit ./.git/hooks/pre-commit - Trigger GitHub action to publish to PyPI with a tagged commit (e.x.
git tag -am "test auto versioning" 0.0.2) onmainbranch. Note versioning is also inferred from the git tag value, and this will only run on push on tag.
Testing
Run test suite with $ ./scripts/run-tests.sh
Additional testing options:
# Run tests with plots displayed (default suppresses plots)
./scripts/run-tests.sh --show_plots
# Run specific test file
pytest tests/test_filter.py
# Run with coverage report
pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=rfproto/ tests/
# Run mypy static type checking
mypy rfproto/
The test suite includes:
- pytest with doctest support for inline documentation examples
- Tests in both
tests/directory and doctests embedded in module docstrings - Coverage reporting via pytest-cov
- Full mypy type checking (enforced in CI)
- Pre-commit hook that runs full test suite and auto-generates TODO.md
Documentation
Documentation uses mkdocs-material, preview with $ mkdocs serve -a localhost:8888. Publishes with GitHub action as well.
Code Formatting
The project uses black for code formatting. The pre-commit hook automatically runs the full test suite (including formatting checks) before commits are allowed.
TODO
See auto-generated TODO.md.
- Look at https://github.com/veeresht/CommPy since its unmaintained
- Filtering/convolution kernels like https://joht.github.io/johtizen/algorithm/2022/10/22/a-different-approach-to-convolution.html and https://dsp.stackexchange.com/questions/15412/fir-filters-direct-form-transposed-fir
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rfproto-0.0.20.tar.gz.
File metadata
- Download URL: rfproto-0.0.20.tar.gz
- Upload date:
- Size: 33.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a536e34e241b604b8274d3dd28b9ac036f511edc32ed1e369d9f26b4cde92866
|
|
| MD5 |
02f8cfa535fc5e19365f3267d583961d
|
|
| BLAKE2b-256 |
251070bc750f0c5dfd8807ee2fc3a3e07efd9d596672e9013fc8c3cf2ad464bb
|
Provenance
The following attestation bundles were made for rfproto-0.0.20.tar.gz:
Publisher:
publish-to-pypi.yml on JohnnyGOX17/rfproto
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rfproto-0.0.20.tar.gz -
Subject digest:
a536e34e241b604b8274d3dd28b9ac036f511edc32ed1e369d9f26b4cde92866 - Sigstore transparency entry: 1436869568
- Sigstore integration time:
-
Permalink:
JohnnyGOX17/rfproto@fe5f8211fb4698b2b7432543c8115e5403eed132 -
Branch / Tag:
refs/tags/0.0.20 - Owner: https://github.com/JohnnyGOX17
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@fe5f8211fb4698b2b7432543c8115e5403eed132 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rfproto-0.0.20-py3-none-any.whl.
File metadata
- Download URL: rfproto-0.0.20-py3-none-any.whl
- Upload date:
- Size: 33.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fe11f3044b7b6a8dc38cebfb37b74f343f0cc106cc756c6751d99aa7a6e872a
|
|
| MD5 |
15bde6727b8aec59387e77921e9e3e21
|
|
| BLAKE2b-256 |
99f4b25d3df1e4a9a0a0779a12ec6e0fe5e604d577449e68768e302cb6ae4467
|
Provenance
The following attestation bundles were made for rfproto-0.0.20-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on JohnnyGOX17/rfproto
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rfproto-0.0.20-py3-none-any.whl -
Subject digest:
5fe11f3044b7b6a8dc38cebfb37b74f343f0cc106cc756c6751d99aa7a6e872a - Sigstore transparency entry: 1436869571
- Sigstore integration time:
-
Permalink:
JohnnyGOX17/rfproto@fe5f8211fb4698b2b7432543c8115e5403eed132 -
Branch / Tag:
refs/tags/0.0.20 - Owner: https://github.com/JohnnyGOX17
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@fe5f8211fb4698b2b7432543c8115e5403eed132 -
Trigger Event:
push
-
Statement type: