dschandra commited on
Commit
d68bb02
Β·
verified Β·
1 Parent(s): 2856072

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -24
app.py CHANGED
@@ -1,30 +1,48 @@
1
  import streamlit as st
2
- from modules.simulator import simulate_data
3
- from modules.filters import apply_filters
4
- from modules.visuals import display_dashboard, display_heatmap
5
- from modules.ai_engine import AIEngine
6
 
7
- st.set_page_config(page_title="Pole Monitoring Dashboard", layout="wide")
8
- st.title("πŸ“‘ Pole Monitoring - Real-Time Simulation")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- st.sidebar.header("πŸ› οΈ Simulation Controls")
11
- num_poles = st.sidebar.slider("Number of Poles", min_value=5, max_value=50, value=10)
12
- simulate_faults = st.sidebar.checkbox("Simulate Random Faults", value=True)
 
 
 
13
 
14
- # Simulate pole data
15
- df = simulate_data(num_poles, simulate_faults)
16
 
17
- # AI predictions (optional)
18
- ai_engine = AIEngine()
19
- df = ai_engine.predict_health(df)
20
 
21
- st.sidebar.header("πŸ“‚ Filter Data")
22
- alert_filter = st.sidebar.multiselect("Alert Level", ["Green", "Yellow", "Red"], default=["Green", "Yellow", "Red"])
23
- filtered_df = apply_filters(df, alert_filter)
24
-
25
- # Dashboard and Heatmap Display
26
- display_dashboard(filtered_df)
27
- display_heatmap(filtered_df)
28
-
29
- st.subheader("πŸ“‹ Pole Monitoring Table")
30
- st.dataframe(filtered_df, use_container_width=True)
 
1
  import streamlit as st
2
+ import folium
3
+ from folium.plugins import HeatMap
4
+ import pandas as pd
5
+ import plotly.express as px
6
 
7
+ # Function to display the fault heatmap
8
+ def display_fault_heatmap(df):
9
+ st.subheader("🌑️ Fault Heatmap")
10
+
11
+ # Filter out red alert poles
12
+ red_alert_poles = df[df["Alert Level"] == "Red"]
13
+
14
+ # Create a folium map centered around a location (e.g., Hyderabad)
15
+ map_center = [17.385044, 78.486671] # Hyderabad latitude, longitude (you can adjust for other cities)
16
+ folium_map = folium.Map(location=map_center, zoom_start=7)
17
+
18
+ # Add markers for poles with red alerts
19
+ for _, row in red_alert_poles.iterrows():
20
+ folium.CircleMarker(
21
+ location=[row['Latitude'], row['Longitude']], # Adjust your data accordingly
22
+ radius=8,
23
+ color='red',
24
+ fill=True,
25
+ fill_color='red',
26
+ fill_opacity=0.7,
27
+ popup=f"Pole: {row['Pole ID']}, Anomalies: {row['Anomalies']}"
28
+ ).add_to(folium_map)
29
+
30
+ # Display the map
31
+ st.write(folium_map)
32
 
33
+ # Function to display the dashboard
34
+ def display_dashboard(df):
35
+ st.subheader("πŸ“Š System Summary")
36
+ col1, col2 = st.columns(2)
37
+ col1.metric("Total Poles", df.shape[0])
38
+ col2.metric("🚨 Red Alerts", df[df['Alert Level'] == "Red"].shape[0])
39
 
40
+ display_fault_heatmap(df)
 
41
 
42
+ def display_charts(df):
43
+ st.subheader("βš™οΈ Energy Generation")
44
+ st.plotly_chart(px.bar(df, x="Pole ID", y=["Solar Gen (kWh)", "Wind Gen (kWh)"], barmode="group"))
45
 
46
+ st.subheader("πŸ“‰ Tilt vs Vibration")
47
+ fig = px.scatter(df, x="Tilt (Β°)", y="Vibration (g)", color="Alert Level", hover_data=["Pole ID"])
48
+ st.plotly_chart(fig)