Skip to content

Commit

Permalink
Rename and refactor demo pages for clarity; add new Pulse shaping page
Browse files Browse the repository at this point in the history
  • Loading branch information
rwnobrega committed Nov 8, 2024
1 parent f97c4e8 commit 8279764
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 264 deletions.
43 changes: 4 additions & 39 deletions demo/index.py
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()
137 changes: 0 additions & 137 deletions demo/pages/3_Pulse_formatting.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import streamlit as st

# Local import
# local import
from utils import show_about, show_code, show_documentation

import komm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import streamlit as st

# Local import
# local import
from utils import show_about, show_code, show_documentation

import komm
Expand Down
67 changes: 67 additions & 0 deletions demo/pages/Pulse_shaping.py
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)
Loading

0 comments on commit 8279764

Please sign in to comment.