dschandra commited on
Commit
1d4aabd
·
verified ·
1 Parent(s): 5b831b2

Create visuals.py

Browse files
Files changed (1) hide show
  1. modules/visuals.py +49 -0
modules/visuals.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import plotly.express as px
3
+ import pandas as pd
4
+
5
+ def display_dashboard(df):
6
+ st.subheader("📊 System Summary")
7
+ col1, col2, col3, col4 = st.columns(4)
8
+ col1.metric("Total Poles", df.shape[0])
9
+ col2.metric("🚨 Red Alerts", df[df['AlertLevel'] == "Red"].shape[0])
10
+ col3.metric("⚡ Power Issues", df[df['PowerSufficient'] == "No"].shape[0])
11
+ col4.metric("📍 Sites", len(df['Site'].unique()))
12
+
13
+ def display_charts(df):
14
+ st.subheader("⚙️ Energy Generation Trends")
15
+ st.bar_chart(df.groupby("Site")[["SolarGen(kWh)", "WindGen(kWh)"]].mean())
16
+ st.subheader("📉 Tilt vs Vibration")
17
+ st.scatter_chart(df.rename(columns={"Tilt(°)": "Tilt", "Vibration(g)": "Vibration"}).set_index("PoleID")[["Tilt", "Vibration"]])
18
+
19
+ def display_heatmap(df):
20
+ st.subheader("🌡️ Alert Heatmap by Site")
21
+ # Map AlertLevel to numeric values for heatmap intensity
22
+ alert_map = {"Green": 1, "Yellow": 2, "Red": 3}
23
+ df["AlertValue"] = df["AlertLevel"].map(alert_map)
24
+
25
+ # Create heatmap using Plotly
26
+ fig = px.density_heatmap(
27
+ df,
28
+ x="XCoord",
29
+ y="YCoord",
30
+ z="AlertValue",
31
+ color_continuous_scale=["green", "yellow", "red"],
32
+ title="Alert Intensity Heatmap Across Sites",
33
+ labels={"XCoord": "Site Zone X", "YCoord": "Site Zone Y", "AlertValue": "Alert Intensity"},
34
+ nbinsx=20,
35
+ nbinsy=20
36
+ )
37
+
38
+ # Add site boundaries for zoning
39
+ site_boundaries = {
40
+ "Hyderabad": (0, 10),
41
+ "Ballari": (10, 20),
42
+ "Kurnool": (20, 30),
43
+ "Gadwal": (30, 40)
44
+ }
45
+ for site, (x_min, x_max) in site_boundaries.items():
46
+ fig.add_vline(x=x_min, line_dash="dash", line_color="white")
47
+ fig.add_annotation(x=(x_min + x_max) / 2, y=10, text=site, showarrow=False, font=dict(color="white"))
48
+
49
+ st.plotly_chart(fig, use_container_width=True)