Coder Social home page Coder Social logo

mhostetter / sdr Goto Github PK

View Code? Open in Web Editor NEW
33.0 3.0 4.0 770.73 MB

A Python package for software-defined radio

Home Page: https://mhostetter.github.io/sdr/

License: MIT License

Python 100.00%
demodulation digital-communications digital-signal-processing dsp forward-error-correction modem modulation numpy sdr software-defined-radio wireless-communications

sdr's Introduction

sdr

The sdr library is a Python 3 package for software-defined radio (SDR).

The goal of sdr is to provide tools to design, analyze, build, and test digital communication systems in Python. The library relies on and is designed to be interoperable with NumPy, SciPy, and Matplotlib. Performance is also very important. So, where possible, Numba is used to accelerate computationally intensive functions.

Additionally, the library aims to replicate relevant functionality from MATLAB's Communications and DSP Toolboxes.

We are progressively adding functionality to the library. If there is something you'd like to see included in sdr, please open an issue on GitHub.

Enjoying the library? Give us a ⭐ on GitHub!

Documentation

The documentation for sdr is located at https://mhostetter.github.io/sdr/latest/.

Installation

The latest version of sdr can be installed from PyPI using pip.

python3 -m pip install sdr

Features

View all available classes and functions in the API Reference.

  • Digital signal processing: Finite impulse response (FIR) filters, FIR filter design, infinite impulse response (IIR) filters, polyphase interpolators, polyphase decimators, polyphase resamplers, polyphase channelizers, Farrow arbitrary resamplers, fractional delay FIR filters, FIR moving averagers, FIR differentiators, IIR integrators, IIR leaky integrators, complex mixing, real/complex conversion.
  • Sequences: Binary, Gray, Barker, Hadamard, Walsh, Gold, Kasami, Zadoff-Chu, $m$-sequences, preferred pairs, Fibonacci LFSRs, Galois LFSRs, LFSR synthesis.
  • Coding: Block interleavers, additive scramblers.
  • Modulation: Phase-shift keying (PSK), $\pi/M$ PSK, offset QPSK, continuous-phase modulation (CPM), minimum-shift keying (MSK), rectangular pulse shapes, half-sine pulse shapes, Gaussian pulse shapes, raised cosine pulse shapes, root raised cosine pulse shapes, differential encoding.
  • Estimation: TOA, TDOA, FOA, FDOA Cramér-Rao lower bounds.
  • Detection: Detector probability density functions (PDFs). Theoretical probability of detection, probability of false alarm, and thresholds. Detection performance approximations. Coherent gain, coherent gain loss (CGL), and non-coherent gain. Maximum-allowable integration time and frequency offset.
  • Synchronization: Numerically controlled oscillators (NCO), loop filters, closed-loop phase-locked loop (PLL) analysis, phase error detectors (PEDs), automatic gain control (AGC).
  • Measurement: Energy, power, voltage, Euclidean distance, Hamming distance, bit/symbol error rate, error vector magnitude (EVM), RMS integration time, and RMS bandwidth.
  • Conversions: Between linear units and decibels. Between $E_b/N_0$, $E_s/N_0$, and $S/N$.
  • Simulation: Binary symmetric channels (BSC), binary erasure channels (BEC), discrete memoryless channels (DMC). Apply additive white Gaussian noise (AWGN), frequency offset, sample rate offset, IQ imbalance.
  • Link budgets: BSC, BEC, AWGN, and BI-AWGN channel capacity, Shannon's limit on $E_b/N_0$ and $S/N$, free-space path loss, antenna gain.
  • Miscellaneous: Numerical calculation of PDF of sum and product of random variables. Packing and unpacking binary data, hexdump of binary data.
  • Plotting: Time-domain, raster, correlation, stem, discrete Fourier transform (DFT), discrete-time Fourier transform (DTFT), periodogram, spectrogram, constellation, symbol map, eye diagram, phase tree, bit error rate (BER), symbol error rate (SER), probability of detection, receiver operating characteristic (ROC), detection PDFs, impulse response, step response, zeros/poles, magnitude response, phase response, phase delay, and group delay.

Examples

There are detailed examples published at https://mhostetter.github.io/sdr/latest/examples/fir-filters/. The Jupyter notebooks behind the examples are available for experimentation in docs/examples/.

Citation

If this library was useful to you in your research, please cite us. Following the GitHub citation standards, here is the recommended citation.

BibTeX

@software{Hostetter_SDR_2023,
    title = {{sdr: A software-defined radio package for Python}},
    author = {Hostetter, Matt},
    month = {7},
    year = {2023},
    url = {https://github.com/mhostetter/sdr},
}

APA

Hostetter, M. (2023). sdr: A software-defined radio package for Python [Computer software]. https://github.com/mhostetter/sdr

sdr's People

Contributors

mhostetter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sdr's Issues

Add `sdr.cross_correlate()`

API sdr.cross_correlate(x: npt.ArrayLike, y: npt.ArrayLike, cyclic: bool = False) -> tuple[np.ndarray, np.ndarray]

Suppress log(0) warnings

In [1]: import sdr

In [2]: import numpy as np

In [3]: p = np.linspace(0, 1, 10)

In [4]: sdr.bsc_capacity(p)
/mnt/c/Users/matth/repos/sdr/src/sdr/_link_budget/_capacity.py:17: RuntimeWarning: divide by zero encountered in log2
  H = -x * np.log2(x) - (1 - x) * np.log2(1 - x)
/mnt/c/Users/matth/repos/sdr/src/sdr/_link_budget/_capacity.py:17: RuntimeWarning: invalid value encountered in multiply
  H = -x * np.log2(x) - (1 - x) * np.log2(1 - x)
Out[4]: 
array([1.        , 0.49674167, 0.23579549, 0.08170417, 0.00892394,
       0.00892394, 0.08170417, 0.23579549, 0.49674167, 1.        ])

Enumerate default kwargs for plotting

Add a bulleted list under here describing which default kwargs are passed to plot functions.

        **kwargs: Additional keyword arguments to pass to :func:`matplotlib.pyplot.plot()`.

Multiple plot calls and axis resizing

When calling a scatter plot (e.g. sdr.constellation()) multiple times and the last time has a smaller axis limits, then the plot will resize and potentially cut off parts of earlier plots.

There should be a way to determine if an active figure is open (ie another plot call has already been made on this figure), and if the previous axis limits are larger than the new ones, don't resize.

Add `sdr.satellite_offset()`

This function adds sample rate offset and frequency offset (varying with time) across a given satellite's pass.

We'll need to think how to implement this. It is most useful for LEO, and maybe useless for GEO? I'm considering adding skyfield as a dependency and having users pass an earth satellite and location object into the function. We may also want to allow for "generic" satellites where only the orbit altitude is specified.

https://rhodesmill.org/skyfield/earth-satellites.html

Use `__call__()`?

If we implemented __call__(), then a filter instance h_srrc could be used like h_srrc(x) instead of h_srrc.filter(x). There are other use cases, like .step() or .process().

If this change is done, it should be systemic. I'm not sure which API is more clear.

Add baseband/passband functions

Maybe sdr.baseband() that takes a real passband signal and mixes it complex baseband and sdr.passband() that takes a complex baseband signal and mixes it to passband and combines the I and Q signals into one real signal.

Add mixer function

Maybe sdr.mix(x, npt.ArrayLike, frequency: float, phase: float = 0, sample_rate: float = 1) -> np.ndarray

Review typing

Especially returning scalars vs arrays. Maybe run mypy. Maybe add mypy to the CI.

Add `SampleSeries` class

This is a np.ndarray subclass that stores the sample rate (default 1) and sample offset (default 0) of a sample series. When slices are performed, the sample offset is updated. When rate changes happen, the sample rate is updated.

We can also add a time slice feature. Maybe if the slice values are floats x[1e-3 : 5e-3] they are interpreted as time in seconds. Or maybe x(1e-3 : 5e-3).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.