Spaces:
Sleeping
Sleeping
Create modules/visuals.py
Browse files- modules/visuals.py +35 -0
modules/visuals.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
def display_summary(df: pd.DataFrame):
|
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("Offline Cameras", df[df["CameraStatus"] == "Offline"].shape[0])
|
12 |
+
|
13 |
+
def display_tel_map(df: pd.DataFrame):
|
14 |
+
st.subheader("🗺️ Telangana Pole Heatmap")
|
15 |
+
red_df = df[df["AlertLevel"] == "Red"]
|
16 |
+
fig = px.scatter_mapbox(
|
17 |
+
red_df,
|
18 |
+
lat="Location_Latitude",
|
19 |
+
lon="Location_Longitude",
|
20 |
+
color="AlertLevel",
|
21 |
+
hover_name="PoleID",
|
22 |
+
zoom=6.3,
|
23 |
+
height=500,
|
24 |
+
mapbox_style="carto-positron"
|
25 |
+
)
|
26 |
+
st.plotly_chart(fig, use_container_width=True)
|
27 |
+
|
28 |
+
def display_energy_trends(df: pd.DataFrame):
|
29 |
+
st.subheader("⚙️ Solar vs Wind")
|
30 |
+
st.plotly_chart(px.bar(df, x="PoleID", y=["SolarGen(kWh)", "WindGen(kWh)"], barmode="group"))
|
31 |
+
|
32 |
+
def display_scatter(df: pd.DataFrame):
|
33 |
+
st.subheader("📉 Tilt vs Vibration")
|
34 |
+
fig = px.scatter(df, x="Tilt(°)", y="Vibration(g)", color="AlertLevel", hover_data=["PoleID", "Site"])
|
35 |
+
st.plotly_chart(fig)
|