Create visuals.py
Browse files- modules/visuals.py +48 -0
modules/visuals.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import seaborn as sns
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
import numpy as np
|
5 |
+
import time
|
6 |
+
|
7 |
+
# Display the dashboard with metrics and visualizations
|
8 |
+
def display_dashboard(df):
|
9 |
+
st.subheader("π System Summary")
|
10 |
+
|
11 |
+
col1, col2, col3 = st.columns(3)
|
12 |
+
|
13 |
+
col1.metric("Total Poles", df.shape[0])
|
14 |
+
col2.metric("π¨ Red Alerts", df[df['Alert Level'] == "Red"].shape[0])
|
15 |
+
col3.metric("β‘ Power Issues", df[df['Power Sufficient'] == "No"].shape[0])
|
16 |
+
|
17 |
+
# Heatmap with Faults Visualization
|
18 |
+
st.subheader("π Pole Signal Heatmap with Fault Zones")
|
19 |
+
|
20 |
+
# Create random data for the heatmap (replace with your simulation data)
|
21 |
+
data = np.random.rand(10, 10)
|
22 |
+
fault_x, fault_y = np.random.randint(0, 10), np.random.randint(0, 10)
|
23 |
+
|
24 |
+
# Show initial heatmap
|
25 |
+
fig, ax = plt.subplots(figsize=(8, 6))
|
26 |
+
sns.heatmap(data, annot=True, cmap="coolwarm", ax=ax)
|
27 |
+
|
28 |
+
# Show a red dot if there's a fault
|
29 |
+
ax.plot(fault_y, fault_x, 'ro', markersize=10) # Red dot for fault location
|
30 |
+
|
31 |
+
st.pyplot(fig)
|
32 |
+
|
33 |
+
# Function to simulate blinking red dot and alert
|
34 |
+
def display_fault_alert(fault_x, fault_y):
|
35 |
+
st.error(f"Fault detected at Zone ({fault_x}, {fault_y}). Red alert triggered!")
|
36 |
+
|
37 |
+
# Simulate blinking red dot effect
|
38 |
+
for _ in range(5):
|
39 |
+
fig, ax = plt.subplots(figsize=(8, 6))
|
40 |
+
sns.heatmap(np.random.rand(10, 10), annot=True, cmap="coolwarm", ax=ax) # Draw heatmap
|
41 |
+
|
42 |
+
# Plot blinking red dot at fault location
|
43 |
+
ax.plot(fault_y, fault_x, 'ro', markersize=10)
|
44 |
+
|
45 |
+
# Display updated plot
|
46 |
+
st.pyplot(fig)
|
47 |
+
time.sleep(0.5) # Wait for 0.5 seconds to simulate blinking
|
48 |
+
ax.clear() # Clear previous plot
|