Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,48 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
from
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
df = simulate_data(num_poles, simulate_faults)
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
df =
|
| 20 |
|
| 21 |
-
st.
|
| 22 |
-
|
| 23 |
-
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|