Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify modulation property names #401

Open
wants to merge 15 commits into
base: release/0.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
<a href="https://pypi.org/project/sdr"><img src="https://img.shields.io/pypi/wheel/sdr"></a>
<a href="https://pypistats.org/packages/sdr"><img src="https://img.shields.io/pypi/dm/sdr"></a>
<a href="https://pypi.org/project/sdr"><img src="https://img.shields.io/pypi/l/sdr"></a>
<a href="https://twitter.com/sdr_py"><img src="https://img.shields.io/static/v1?label=follow&message=@sdr_py&color=blue&logo=twitter"></a>
</div>

<div align=center>
<a href="https://github.com/mhostetter/sdr/actions/workflows/docs.yaml"><img src="https://github.com/mhostetter/sdr/actions/workflows/docs.yaml/badge.svg"></a>
<a href="https://github.com/mhostetter/sdr/actions/workflows/lint.yaml"><img src="https://github.com/mhostetter/sdr/actions/workflows/lint.yaml/badge.svg"></a>
<a href="https://github.com/mhostetter/sdr/actions/workflows/build.yaml"><img src="https://github.com/mhostetter/sdr/actions/workflows/build.yaml/badge.svg"></a>
<a href="https://github.com/mhostetter/sdr/actions/workflows/test.yaml"><img src="https://github.com/mhostetter/sdr/actions/workflows/test.yaml/badge.svg"></a>
<a href="https://github.com/mhostetter/sdr/actions/workflows/lint.yaml"><img src="https://github.com/mhostetter/sdr/actions/workflows/lint.yaml/badge.svg?branch=main"></a>
<a href="https://github.com/mhostetter/sdr/actions/workflows/build.yaml"><img src="https://github.com/mhostetter/sdr/actions/workflows/build.yaml/badge.svg?branch=main"></a>
<a href="https://github.com/mhostetter/sdr/actions/workflows/test.yaml"><img src="https://github.com/mhostetter/sdr/actions/workflows/test.yaml/badge.svg?branch=main"></a>
<a href="https://codecov.io/gh/mhostetter/sdr"><img src="https://codecov.io/gh/mhostetter/sdr/branch/main/graph/badge.svg?token=3FJML79ZUK"></a>
<a href="https://twitter.com/sdr_py"><img src="https://img.shields.io/static/v1?label=follow&message=@sdr_py&color=blue&logo=twitter"></a>
</div>

The `sdr` library is a Python 3 package for software-defined radio (SDR).
Expand Down
33 changes: 32 additions & 1 deletion docs/_static/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

/* Override announcement banner colors */
.md-banner {
background-color: var(--md-typeset-mark-color);
background-color: var(--md-default-bg-color--lighter);
color: var(--md-default-fg-color);
}

Expand All @@ -72,3 +72,34 @@ div.cell_output.docutils.container>div {
border: transparent;
background: transparent;
}

/* Change the object info colors. */
[data-md-color-scheme="default"] {
/* --objinfo-icon-fg-default: var(--md-code-hl-keyword-color); */
/* Properties */
--objinfo-icon-fg-alias: var(--md-code-hl-constant-color);
/* Classes */
--objinfo-icon-fg-data: var(--md-code-hl-string-color);
/* Functions, methods */
--objinfo-icon-fg-procedure: var(--md-code-hl-keyword-color);
/* Parameters (function/method arguments) */
--objinfo-icon-fg-sub-data: var(--md-code-hl-function-color);
}

[data-md-color-scheme="slate"] {
/* --objinfo-icon-fg-default: var(--md-code-hl-keyword-color); */
/* Properties */
--objinfo-icon-fg-alias: var(--md-code-hl-constant-color);
/* Classes */
--objinfo-icon-fg-data: var(--md-code-hl-string-color);
/* Functions, methods */
--objinfo-icon-fg-procedure: var(--md-code-hl-keyword-color);
/* Parameters (function/method arguments) */
--objinfo-icon-fg-sub-data: var(--md-code-hl-function-color);
}

/* Change the "class" and "property" label colors. */
.md-typeset dl.objdesc>dt .property {
color: var(--md-code-hl-constant-color);
font-style: italic;
}
2 changes: 1 addition & 1 deletion docs/_templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block announce %}
<p>
Enjoying the library? Give us a
<span class="md-icon si-icon-inline octicons_star-16"></span>
<span class="md-icon si-icon-inline fontawesome_regular_star"></span>
on
<a class="reference external" href="https://github.com/mhostetter/sdr">GitHub</a>.
</p>
Expand Down
66 changes: 64 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,81 @@
]

sphinx_immaterial_custom_admonitions = [
{
"name": "note",
"title": "Note",
"classes": ["collapsible"],
"icon": "fontawesome/solid/pencil",
"override": True,
},
{
"name": "warning",
"title": "Warning",
"classes": ["collapsible"],
"icon": "fontawesome/solid/triangle-exclamation",
"override": True,
},
{
"name": "info",
"icon": "fontawesome/solid/circle-info",
"override": True,
},
{
"name": "tip",
"icon": "fontawesome/regular/lightbulb",
"override": True,
},
{
"name": "abstract",
"icon": "fontawesome/regular/file-lines",
"override": True,
},
{
"name": "important",
"icon": "fontawesome/solid/bolt",
"override": True,
},
{
"name": "example",
"icon": "fontawesome/solid/terminal",
"override": True,
},
{
"name": "quote",
"icon": "fontawesome/solid/quote-left",
"override": True,
},
{
"name": "seealso",
"title": "See also",
"classes": ["collapsible"],
"icon": "fontawesome/regular/eye",
"icon": "fontawesome/solid/magnifying-glass",
"color": (108, 117, 125), # --sd-color-secondary
"override": True,
},
{
"name": "versionadded",
"icon": "fontawesome/solid/code-commit",
"override": True,
},
{
"name": "versionchanged",
"icon": "fontawesome/solid/code-branch",
"override": True,
},
{
# This needs to be defined here so the icon is available when referenced in _templates/base.html
"name": "star",
"icon": "octicons/star-16",
"icon": "fontawesome/regular/star",
"color": (255, 233, 3), # Gold
},
{
"name": "nomenclature",
"title": "Variable nomenclature",
"classes": ["collapsible"],
"icon": "fontawesome/solid/arrow-down-a-z",
"color": (108, 117, 125), # --sd-color-secondary
},
# {
# "name": "fast-performance",
# "title": "Faster performance",
Expand Down
21 changes: 12 additions & 9 deletions docs/examples/peak-to-average-power.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"outputs": [],
"source": [
"span = 10 # Length of the pulse shape in symbols\n",
"sps = 200 # Samples per symbol"
"samples_per_symbol = 200 # Samples per symbol"
]
},
{
Expand All @@ -64,11 +64,14 @@
"source": [
"def pulse_shape(alpha):\n",
" if alpha is None:\n",
" h = np.zeros(span * sps + 1)\n",
" h[span * sps // 2 - sps // 2 : span * sps // 2 + sps // 2] = 1 / np.sqrt(sps)\n",
" h = np.zeros(span * samples_per_symbol + 1)\n",
" h[\n",
" span * samples_per_symbol // 2 - samples_per_symbol // 2 : span * samples_per_symbol // 2\n",
" + samples_per_symbol // 2\n",
" ] = 1 / np.sqrt(samples_per_symbol)\n",
" else:\n",
" h = sdr.root_raised_cosine(alpha, span, sps)\n",
" fir = sdr.Interpolator(sps, h)\n",
" h = sdr.root_raised_cosine(alpha, span, samples_per_symbol)\n",
" fir = sdr.Interpolator(samples_per_symbol, h)\n",
"\n",
" bb = fir(x)\n",
" pb = sdr.mix(bb, 0.02)\n",
Expand Down Expand Up @@ -118,7 +121,7 @@
"sdr.plot.time_domain(x_bb_0p9, label=rf\"$\\alpha = 0.9$, PAPR = {papr_bb_0p9:.2f} dB\", diff=\"line\")\n",
"sdr.plot.time_domain(x_bb_0p5, label=rf\"$\\alpha = 0.5$, PAPR = {papr_bb_0p5:.2f} dB\", diff=\"line\")\n",
"sdr.plot.time_domain(x_bb_0p1, label=rf\"$\\alpha = 0.1$, PAPR = {papr_bb_0p1:.2f} dB\", diff=\"line\")\n",
"plt.xlim(25 * sps, 50 * sps)\n",
"plt.xlim(25 * samples_per_symbol, 50 * samples_per_symbol)\n",
"plt.title(\"Baseband QPSK with SRRC pulse shaping\")\n",
"plt.show()"
]
Expand All @@ -145,7 +148,7 @@
"sdr.plot.time_domain(x_pb_0p9, label=rf\"$\\alpha = 0.9$, PAPR = {papr_pb_0p9:.2f} dB\")\n",
"sdr.plot.time_domain(x_pb_0p5, label=rf\"$\\alpha = 0.5$, PAPR = {papr_pb_0p5:.2f} dB\")\n",
"sdr.plot.time_domain(x_pb_0p1, label=rf\"$\\alpha = 0.1$, PAPR = {papr_pb_0p1:.2f} dB\")\n",
"plt.xlim(25 * sps, 50 * sps)\n",
"plt.xlim(25 * samples_per_symbol, 50 * samples_per_symbol)\n",
"plt.title(\"Passband QPSK with SRRC pulse shaping\")\n",
"plt.show()"
]
Expand Down Expand Up @@ -257,8 +260,8 @@
" pb_papr = []\n",
"\n",
" for alpha in alphas:\n",
" h = sdr.root_raised_cosine(alpha, span, sps)\n",
" fir = sdr.Interpolator(sps, h)\n",
" h = sdr.root_raised_cosine(alpha, span, samples_per_symbol)\n",
" fir = sdr.Interpolator(samples_per_symbol, h)\n",
"\n",
" bb = fir(x)\n",
" pb = sdr.mix(bb, 0.02)\n",
Expand Down
20 changes: 10 additions & 10 deletions docs/examples/psk.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
" x = psk.map_symbols(s)\n",
"\n",
" # Add AWGN to complex symbols to achieve desired Es/N0\n",
" snr = sdr.esn0_to_snr(esn0, sps=1)\n",
" snr = sdr.esn0_to_snr(esn0, samples_per_symbol=1)\n",
" x_hat = sdr.awgn(x, snr)\n",
"\n",
" plt.figure()\n",
Expand All @@ -61,8 +61,8 @@
" plt.show()\n",
"\n",
" y = psk.modulate(s)\n",
" # h_srrc = sdr.root_raised_cosine(0.1, 6, sps)\n",
" # tx_mf = sdr.Interpolator(sps, h_srrc)\n",
" # h_srrc = sdr.root_raised_cosine(0.1, 6, samples_per_symbol)\n",
" # tx_mf = sdr.Interpolator(samples_per_symbol, h_srrc)\n",
" # y = tx_mf(x)\n",
"\n",
" plt.figure()\n",
Expand Down Expand Up @@ -111,7 +111,7 @@
}
],
"source": [
"bpsk = sdr.PSK(2, sps=10, pulse_shape=\"srrc\")\n",
"bpsk = sdr.PSK(2, samples_per_symbol=10, pulse_shape=\"srrc\")\n",
"analyze_psk(bpsk, 6)"
]
},
Expand Down Expand Up @@ -149,7 +149,7 @@
}
],
"source": [
"qpsk = sdr.PSK(4, phase_offset=45, sps=10, pulse_shape=\"srrc\")\n",
"qpsk = sdr.PSK(4, phase_offset=45, samples_per_symbol=10, pulse_shape=\"srrc\")\n",
"analyze_psk(qpsk, 9)"
]
},
Expand Down Expand Up @@ -187,7 +187,7 @@
}
],
"source": [
"psk8 = sdr.PSK(8, sps=10, pulse_shape=\"srrc\")\n",
"psk8 = sdr.PSK(8, samples_per_symbol=10, pulse_shape=\"srrc\")\n",
"analyze_psk(psk8, 12)"
]
},
Expand Down Expand Up @@ -225,7 +225,7 @@
}
],
"source": [
"psk16 = sdr.PSK(16, sps=10, pulse_shape=\"srrc\")\n",
"psk16 = sdr.PSK(16, samples_per_symbol=10, pulse_shape=\"srrc\")\n",
"analyze_psk(psk16, 18)"
]
},
Expand All @@ -243,7 +243,7 @@
"outputs": [],
"source": [
"def error_rates(psk, ebn0):\n",
" esn0 = sdr.ebn0_to_esn0(ebn0, psk.bps)\n",
" esn0 = sdr.ebn0_to_esn0(ebn0, psk.bits_per_symbol)\n",
" snr = sdr.esn0_to_snr(esn0)\n",
"\n",
" ber = sdr.ErrorRate()\n",
Expand All @@ -255,7 +255,7 @@
" a_tilde = sdr.awgn(a, snr[i])\n",
" s_hat, a_hat = psk.decide_symbols(a_tilde)\n",
"\n",
" ber.add(ebn0[i], sdr.unpack(s, psk.bps), sdr.unpack(s_hat, psk.bps))\n",
" ber.add(ebn0[i], sdr.unpack(s, psk.bits_per_symbol), sdr.unpack(s_hat, psk.bits_per_symbol))\n",
" ser.add(esn0[i], s, s_hat)\n",
"\n",
" return ber, ser"
Expand Down Expand Up @@ -457,7 +457,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.-1"
},
"orig_nbformat": 4
},
Expand Down
Loading
Loading