Tigernawin commited on
Commit
123019e
Β·
verified Β·
1 Parent(s): 3cb9df1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -11
app.py CHANGED
@@ -28,17 +28,16 @@ def simulate_pole(pole_id, site_name):
28
  total_power = solar_kwh + wind_kwh
29
  power_status = 'Sufficient' if total_power >= power_required else 'Insufficient'
30
 
31
- tilt_angle = round(random.uniform(0, 45), 2)
32
  vibration = round(random.uniform(0, 5), 2)
33
  camera_status = random.choice(['Online', 'Offline'])
34
 
35
  alert_level = 'Green'
36
- if tilt_angle > 30 or vibration > 3:
37
  alert_level = 'Yellow'
38
- if tilt_angle > 40 or vibration > 4.5:
39
  alert_level = 'Red'
40
 
41
- health_score = max(0, 100 - (tilt_angle + vibration * 10))
42
  timestamp = datetime.now() - timedelta(hours=random.randint(0, 6))
43
 
44
  return {
@@ -51,7 +50,6 @@ def simulate_pole(pole_id, site_name):
51
  'Power Required (kWh)': power_required,
52
  'Total Power (kWh)': total_power,
53
  'Power Status': power_status,
54
- 'Tilt Angle (Β°)': tilt_angle,
55
  'Vibration (g)': vibration,
56
  'Camera Status': camera_status,
57
  'Health Score': round(health_score, 2),
@@ -86,12 +84,33 @@ if selected_site in SITES:
86
  filtered_df = site_df[(site_df['Alert Level'].isin(alert_filter)) & (site_df['Camera Status'].isin(camera_filter))]
87
  st.dataframe(filtered_df, use_container_width=True)
88
 
89
- # Charts
90
- st.subheader("πŸ“Š Energy Generation Comparison")
91
- st.bar_chart(site_df[['Solar (kWh)', 'Wind (kWh)']].mean())
92
-
93
- st.subheader("πŸ“ˆ Tilt vs. Vibration")
94
- st.scatter_chart(site_df[['Tilt Angle (Β°)', 'Vibration (g)']])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  # Map showing all poles by alert level color
97
  st.subheader("πŸ“ All Pole Locations with Alert Levels")
 
28
  total_power = solar_kwh + wind_kwh
29
  power_status = 'Sufficient' if total_power >= power_required else 'Insufficient'
30
 
 
31
  vibration = round(random.uniform(0, 5), 2)
32
  camera_status = random.choice(['Online', 'Offline'])
33
 
34
  alert_level = 'Green'
35
+ if vibration > 3:
36
  alert_level = 'Yellow'
37
+ if vibration > 4.5:
38
  alert_level = 'Red'
39
 
40
+ health_score = max(0, 100 - ( vibration * 10))
41
  timestamp = datetime.now() - timedelta(hours=random.randint(0, 6))
42
 
43
  return {
 
50
  'Power Required (kWh)': power_required,
51
  'Total Power (kWh)': total_power,
52
  'Power Status': power_status,
 
53
  'Vibration (g)': vibration,
54
  'Camera Status': camera_status,
55
  'Health Score': round(health_score, 2),
 
84
  filtered_df = site_df[(site_df['Alert Level'].isin(alert_filter)) & (site_df['Camera Status'].isin(camera_filter))]
85
  st.dataframe(filtered_df, use_container_width=True)
86
 
87
+ st.subheader("πŸ”‹ Energy Generation per Pole")
88
+
89
+ # Reshape the data for comparison: one row per Pole ID and energy source
90
+ energy_long_df = site_df[['Pole ID', 'Solar (kWh)', 'Wind (kWh)']].melt(
91
+ id_vars='Pole ID',
92
+ value_vars=['Solar (kWh)', 'Wind (kWh)'],
93
+ var_name='Energy Source',
94
+ value_name='kWh'
95
+ )
96
+
97
+ # Plot a grouped bar chart using Altair
98
+ import altair as alt
99
+
100
+ bar_chart = alt.Chart(energy_long_df).mark_bar().encode(
101
+ x=alt.X('Pole ID:N', sort=None, title='Pole ID'),
102
+ y=alt.Y('kWh:Q'),
103
+ color='Energy Source:N',
104
+ tooltip=['Pole ID', 'Energy Source', 'kWh']
105
+ ).properties(
106
+ width=800,
107
+ height=400
108
+ ).configure_axisX(labelAngle=45)
109
+
110
+ st.altair_chart(bar_chart, use_container_width=True)
111
+
112
+ st.subheader("πŸ“ˆ Vibration")
113
+ st.scatter_chart(site_df[[ 'Vibration (g)']])
114
 
115
  # Map showing all poles by alert level color
116
  st.subheader("πŸ“ All Pole Locations with Alert Levels")