Spaces:
Sleeping
Sleeping
File size: 1,679 Bytes
44e7e30 4ca91b2 a19fe91 4ca91b2 a19fe91 4ca91b2 a19fe91 4ca91b2 a19fe91 4ca91b2 a19fe91 44e7e30 3d04f0c 44e7e30 156c1e5 44e7e30 156c1e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import streamlit as st
import pydeck as pdk
def display_map(df):
st.subheader("📍 Smart Poles Location Map with Alerts")
alert_colors = {
"Green": [0, 255, 0],
"Yellow": [255, 255, 0],
"Red": [255, 0, 0]
}
df["color"] = df["Alert Level"].apply(lambda x: alert_colors.get(x, [0, 0, 0]))
layer = pdk.Layer(
"ScatterplotLayer",
data=df,
get_position='[Longitude, Latitude]',
get_color="color",
get_radius=4,
pickable=True,
)
view_state = pdk.ViewState(
latitude=df["Latitude"].mean(),
longitude=df["Longitude"].mean(),
zoom=8,
pitch=0
)
tooltip = {
"html": "<b>Pole:</b> {Pole ID} <br/><b>Site:</b> {Site} <br/><b>Alert:</b> {Alert Level} <br/><b>Anomalies:</b> {Anomalies}",
"style": {"backgroundColor": "steelblue", "color": "white"}
}
st.pydeck_chart(pdk.Deck(layers=[layer], initial_view_state=view_state, tooltip=tooltip))
def display_dashboard(df):
st.subheader("📊 System Summary")
col1, col2, col3 = st.columns(3)
col1.metric("Total Poles", df.shape[0])
col2.metric("🚨 Red Alerts", df[df['Alert Level'] == "Red"].shape[0])
col3.metric("⚡ Power Issues", df[df['Power Sufficient'] == "No"].shape[0])
def display_charts(df):
st.subheader("⚙️ Energy Generation Trends")
st.bar_chart(df.set_index("Pole ID")[["Solar Gen (kWh)", "Wind Gen (kWh)"]])
st.subheader("📉 Tilt vs Vibration")
scatter_df = df.rename(columns={"Tilt (°)": "Tilt", "Vibration (g)": "Vibration"})
st.scatter_chart(scatter_df.set_index("Pole ID")[["Tilt", "Vibration"]])
|