feat: add interactive exploration of Shannon's capacity formula with Plotly graphs
All checks were successful
Build & Deploy Shannon / 🏗️ Build & Deploy Shannon (push) Successful in 3m1s
All checks were successful
Build & Deploy Shannon / 🏗️ Build & Deploy Shannon (push) Successful in 3m1s
- Implemented bandwidth sensitivity and power sensitivity plots. - Created a contour map for bit rate multiplying factors. - Added input parameters for C/N and bandwidth with validation. - Displayed computed results and sensitivity analysis metrics. - Integrated interactive graphs for user exploration. - Included background information section for user guidance.
This commit is contained in:
159
app.py
Normal file
159
app.py
Normal file
@@ -0,0 +1,159 @@
|
||||
"""
|
||||
Shannon Equation for Dummies — Streamlit Application
|
||||
|
||||
Main entry point with sidebar navigation.
|
||||
Designed for containerized deployment (Docker), multi-user, 24/7 operation.
|
||||
|
||||
Run with:
|
||||
streamlit run app.py --server.port 8080 --server.address 0.0.0.0
|
||||
"""
|
||||
|
||||
import streamlit as st
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# Page Configuration (must be first Streamlit call)
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
st.set_page_config(
|
||||
page_title="Shannon's Equation for Dummies",
|
||||
page_icon="📡",
|
||||
layout="wide",
|
||||
initial_sidebar_state="expanded",
|
||||
)
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# Custom CSS for a modern, clean look
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
st.markdown("""
|
||||
<style>
|
||||
/* Main container */
|
||||
.block-container {
|
||||
padding-top: 2rem;
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* Metric styling */
|
||||
[data-testid="stMetric"] {
|
||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
||||
border: 1px solid #0f3460;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
[data-testid="stMetricLabel"] {
|
||||
font-size: 0.85rem !important;
|
||||
color: #a0aec0 !important;
|
||||
}
|
||||
|
||||
[data-testid="stMetricValue"] {
|
||||
font-size: 1.1rem !important;
|
||||
color: #e2e8f0 !important;
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
[data-testid="stSidebar"] {
|
||||
background: linear-gradient(180deg, #0d1b2a 0%, #1b2838 100%);
|
||||
}
|
||||
|
||||
/* Tab styling */
|
||||
.stTabs [data-baseweb="tab-list"] {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.stTabs [data-baseweb="tab"] {
|
||||
border-radius: 8px;
|
||||
padding: 8px 16px;
|
||||
}
|
||||
|
||||
/* Dividers */
|
||||
hr {
|
||||
border-color: #1e3a5f !important;
|
||||
}
|
||||
|
||||
/* Expanders */
|
||||
.streamlit-expanderHeader {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Links */
|
||||
a {
|
||||
color: #4FC3F7 !important;
|
||||
}
|
||||
|
||||
/* Info boxes */
|
||||
.stAlert {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
/* Hide Deploy button and hamburger menu */
|
||||
[data-testid="stMainMenu"],
|
||||
[data-testid="stToolbar"] {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
""", unsafe_allow_html=True)
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# Sidebar Navigation
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
with st.sidebar:
|
||||
st.markdown("## 📡 Shannon for Dummies")
|
||||
st.caption("Educational Application — AP Feb 2021")
|
||||
st.divider()
|
||||
|
||||
page = st.radio(
|
||||
"Navigation",
|
||||
options=["animation", "orbits", "sat_types", "theory", "real_world", "contributions"],
|
||||
format_func=lambda x: {
|
||||
"animation": "📡 Satellite Link Animation",
|
||||
"orbits": "🌍 GEO / MEO / LEO Orbits",
|
||||
"sat_types": "🛰️ Satellite Missions & Types",
|
||||
"theory": "🧮 Theoretical Exploration",
|
||||
"real_world": "🛰️ Real World Link Budget",
|
||||
"contributions": "💬 Community Contributions",
|
||||
}[x],
|
||||
label_visibility="collapsed",
|
||||
)
|
||||
|
||||
st.divider()
|
||||
|
||||
st.markdown(
|
||||
"**About**\n\n"
|
||||
"Exploration from Claude Shannon's initial theory "
|
||||
"to its practical application to satellite communications.\n\n"
|
||||
"Built with [Streamlit](https://streamlit.io) · "
|
||||
"[Plotly](https://plotly.com)"
|
||||
)
|
||||
|
||||
st.caption("© 2021-2026 · Shannon Equation for Dummies")
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# Page Routing
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
if page == "animation":
|
||||
from views.satellite_animation import render
|
||||
render()
|
||||
elif page == "orbits":
|
||||
from views.orbits_animation import render
|
||||
render()
|
||||
elif page == "sat_types":
|
||||
from views.satellite_types import render
|
||||
render()
|
||||
elif page == "theory":
|
||||
from views.theory import render
|
||||
render()
|
||||
elif page == "real_world":
|
||||
from views.real_world import render
|
||||
render()
|
||||
elif page == "contributions":
|
||||
from views.contributions import render
|
||||
render()
|
||||
Reference in New Issue
Block a user