-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename and refactor demo pages for clarity; add new Pulse shaping page
- Loading branch information
Showing
7 changed files
with
224 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,18 @@ | ||
import streamlit as st | ||
|
||
# Local import | ||
# local import | ||
from utils import show_about | ||
|
||
st.set_page_config(page_title="Komm Demo", layout="wide") | ||
|
||
|
||
st.title("Komm Demo") | ||
|
||
st.markdown( | ||
""" | ||
This interactive demo showcases various features of the Komm library, a toolkit for analysis and simulation of analog and digital communication systems. | ||
This interactive demo showcases various features of the [Komm library](https://komm.dev). | ||
Please select a page from the sidebar to get started. | ||
""" | ||
) | ||
|
||
st.header("Available demos") | ||
|
||
col1, col2 = st.columns(2) | ||
|
||
with col1: | ||
st.subheader("1. Binary sequences") | ||
st.markdown( | ||
""" | ||
Explore different types of binary sequences commonly used in communications: | ||
- Barker sequencesfrom st_pages import Page, add_page_title, show_pages | ||
- Walsh-Hadamard sequences | ||
- Linear-feedback shift register (LFSR) sequences | ||
""" | ||
) | ||
|
||
st.subheader("2. Constellations") | ||
st.markdown( | ||
""" | ||
Interactive visualization of digital modulation constellations: | ||
- Phase-shift keying (PSK) | ||
- Quadrature amplitude modulation (QAM) | ||
""" | ||
) | ||
|
||
with col2: | ||
st.subheader("3. Pulse formatting") | ||
st.markdown( | ||
""" | ||
Visualize various pulse shaping techniques: | ||
- Sinc pulse | ||
- Raised cosine pulse | ||
- Gaussian pulse | ||
""" | ||
) | ||
|
||
|
||
show_about() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import numpy.fft as fft | ||
import streamlit as st | ||
|
||
import komm | ||
|
||
st.set_page_config(page_title="Raised Cosine Pulse", layout="wide") | ||
|
||
st.title("Pulse shaping") | ||
st.header("Raised cosine pulse") | ||
|
||
cols = st.columns(3) | ||
with cols[0]: | ||
rolloff = st.slider( | ||
"Roll-off factor", | ||
min_value=0.0, | ||
max_value=1.0, | ||
value=0.25, | ||
step=0.01, | ||
) | ||
with cols[1]: | ||
samples_per_symbol = st.slider( | ||
"Samples per symbol", | ||
min_value=2, | ||
max_value=32, | ||
value=16, | ||
step=2, | ||
) | ||
with cols[2]: | ||
truncation = st.slider( | ||
"Truncation", | ||
min_value=2, | ||
max_value=16, | ||
value=8, | ||
step=2, | ||
) | ||
|
||
seq = [1, -1, 1, 1, -1, -1, 1] | ||
|
||
pulse = komm.RaisedCosinePulse(rolloff=rolloff) | ||
tx_filter = komm.TransmitFilter( | ||
pulse, | ||
samples_per_symbol=samples_per_symbol, | ||
truncation=truncation, | ||
) | ||
t = tx_filter.time(seq) | ||
waveform = tx_filter(seq) | ||
spectrum = fft.fftshift(fft.fft(waveform, 1024)) / samples_per_symbol | ||
|
||
fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(12, 5)) | ||
ax0.stem(seq, linefmt="r", markerfmt="ro") | ||
ax0.plot(t, waveform, "o-", markersize=2) | ||
ax0.axis((-3, 9, -2, 2)) | ||
ax0.set_xlabel("$t$") | ||
ax0.set_ylabel("$y(t)$") | ||
ax0.grid() | ||
|
||
f = np.linspace(-0.5, 0.5, 1024, endpoint=False) | ||
ax1.plot(f, np.abs(spectrum)) | ||
ax1.axis((-0.5, 0.5, -0.5, 4.5)) | ||
ax1.set_xlabel("$f$") | ||
ax1.set_ylabel("$|\\hat{y}(f)|$") | ||
ax1.grid() | ||
|
||
|
||
st.pyplot(fig) |
Oops, something went wrong.