Sanjayraju30 commited on
Commit
d4d3e74
·
verified ·
1 Parent(s): 4bbd74a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def simulate_data(n=10, faults=True):
2
+ today = datetime.date.today()
3
+ poles = [f"Pole_{i+1:03}" for i in range(n)]
4
+ data = []
5
+ for pole in poles:
6
+ solar = round(np.random.uniform(3.0, 7.5), 2)
7
+ wind = round(np.random.uniform(0.5, 2.0), 2)
8
+ required = round(np.random.uniform(1.0, 1.5), 2)
9
+ total = solar + wind
10
+ cam = np.random.choice(['Online', 'Offline'], p=[0.85, 0.15]) if faults else "Online"
11
+ tilt = round(np.random.uniform(0, 12), 1)
12
+ vib = round(np.random.uniform(0.1, 2.5), 2)
13
+ sufficient = "Yes" if total >= required else "No"
14
+ anomaly = []
15
+ if faults:
16
+ if solar < 4.0:
17
+ anomaly.append("Low Solar Output")
18
+ if wind < 0.7:
19
+ anomaly.append("Low Wind Output")
20
+ if tilt > 10:
21
+ anomaly.append("Pole Tilt Risk")
22
+ if vib > 2.0:
23
+ anomaly.append("Vibration Alert")
24
+ if cam == "Offline":
25
+ anomaly.append("Camera Offline")
26
+ if sufficient == "No":
27
+ anomaly.append("Power Insufficient")
28
+ alert = "Green"
29
+ if len(anomaly) == 1:
30
+ alert = "Yellow"
31
+ elif len(anomaly) > 1:
32
+ alert = "Red"
33
+ data.append({
34
+ "Pole ID": pole,
35
+ "Date": today,
36
+ "Solar Gen (kWh)": solar,
37
+ "Wind Gen (kWh)": wind,
38
+ "Power Required (kWh)": required,
39
+ "Power Sufficient": sufficient,
40
+ "Camera Status": cam,
41
+ "Tilt (°)": tilt,
42
+ "Vibration (g)": vib,
43
+ "Anomalies": "; ".join(anomaly) if anomaly else "None",
44
+ "Alert Level": alert
45
+ })
46
+ return pd.DataFrame(data)