File size: 2,228 Bytes
ffac544
 
 
 
12a0b73
 
 
ffac544
 
 
 
 
 
12a0b73
ffac544
 
 
12a0b73
 
 
 
ffac544
d5a849e
12a0b73
 
d5a849e
 
fef3055
90268db
12a0b73
 
 
 
 
 
 
d5a849e
 
 
12a0b73
 
 
 
 
 
 
 
 
 
 
ffac544
d5a849e
 
 
fef3055
d5a849e
 
ffac544
12a0b73
 
 
ffac544
 
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
57
58
59
60
61
62
63
import streamlit as st
import plotly.express as px
import pandas as pd

def display_dashboard(df, location):
    st.subheader(f"📊 System Summary - {location}")
    col1, col2, col3 = st.columns(3)
    col1.metric("Total Poles", df.shape[0])
    col2.metric("🚨 Red Alerts", df[df['AlertLevel'] == "Red"].shape[0])
    col3.metric("⚡ Power Issues", df[df['PowerSufficient'] == "No"].shape[0])

def display_charts(df):
    st.subheader("⚙️ Energy Generation Trends")
    st.bar_chart(df.groupby("Zone")[["SolarGen(kWh)", "WindGen(kWh)"]].sum())
    st.subheader("📉 Tilt vs Vibration")
    st.scatter_chart(df.rename(columns={"Tilt(°)": "Tilt", "Vibration(g)": "Vibration"}).set_index("PoleID")[["Tilt", "Vibration"]])

def display_map_heatmap(df, location):
    if df.empty:
        st.warning("No data available for this location.")
        return
    
    # Map AlertLevel to sizes and styles
    df = df.copy()
    df["AlertColor"] = df["AlertLevel"].map({"Green": "green", "Yellow": "yellow", "Red": "red"})
    df["MarkerSize"] = df["AlertLevel"].map({"Green": 10, "Yellow": 15, "Red": 20})
    df["MarkerSymbol"] = df["AlertLevel"].map({"Green": "circle", "Yellow": "circle", "Red": "star"})
    df["MarkerOpacity"] = df["AlertLevel"].map({"Green": 0.7, "Yellow": 0.8, "Red": 1.0})
    
    # Create scatter map
    fig = px.scatter_mapbox(
        df,
        lat="Latitude",
        lon="Longitude",
        color="AlertLevel",
        color_discrete_map={"Green": "green", "Yellow": "yellow", "Red": "red"},
        size="MarkerSize",
        size_max=25,
        zoom=11,
        hover_data={
            "PoleID": True,
            "RFID": True,
            "AlertLevel": True,
            "Anomalies": True,
            "Zone": True,
            "Latitude": False,
            "Longitude": False
        },
        title=f"Pole Alert Map - {location}",
        height=600
    )
    fig.update_traces(
        marker=dict(
            symbol=df["MarkerSymbol"],
            opacity=df["MarkerOpacity"]
        )
    )
    fig.update_layout(
        mapbox_style="open-street-map",
        margin={"r":0,"t":50,"l":0,"b":0},
        showlegend=True
    )
    st.plotly_chart(fig, use_container_width=True)