TroglodyteDerivations's picture
Create app.py
157a87e verified
import streamlit as st
import plotly.graph_objects as go
import numpy as np
# Set page configuration
st.set_page_config(page_title="Pesadillas episodio ocho Broma de ingeniería eléctrica", layout="wide")
# Title of the app
st.title("Pesadillas episodio ocho Broma de ingeniería eléctrica")
# Display images
st.image('pesadillas.png', caption='Pesadillas')
st.image('pesadillas_electrical_engineering_joke.png', caption='Pesadillas broma de ingeniería eléctrica')
# Load and display the concatenated video
st.subheader("Video de Análisis")
# Define the filename of the concatenated video
video_filename = 'final_analisis_video.mp4'
# Display the video
st.video(video_filename)
# Plotly visualization
st.subheader("Visualización de Voltajes Primarios y Secundarios")
# Time array
t = np.linspace(0, 2 * np.pi, 1000)
# Define primary and secondary voltages for each example
examples = [
{"ep": 30, "es": 60},
{"ep": 35, "es": 70},
{"ep": 40, "es": 80},
{"ep": 45, "es": 90},
{"ep": 50, "es": 100},
{"ep": 60, "es": 120}
]
# Create a figure
fig = go.Figure()
# Add traces for each example
for i, example in enumerate(examples):
ep = example["ep"] * np.sin(t)
es = example["es"] * np.sin(t)
fig.add_trace(go.Scatter(x=t, y=ep, mode='lines', name=f'Ejemplo {i+1} - e_p'))
fig.add_trace(go.Scatter(x=t, y=es, mode='lines', name=f'Ejemplo {i+1} - e_s'))
# Update layout for better visualization
fig.update_layout(
title="Voltajes Primarios (e_p) y Secundarios (e_s) en el Tiempo",
xaxis_title="Tiempo",
yaxis_title="Voltaje (V)",
legend_title="Leyenda",
template="plotly_white"
)
# Display the Plotly figure in the Streamlit app
st.plotly_chart(fig, use_container_width=True)