DSatishchandra commited on
Commit
60d7815
·
verified ·
1 Parent(s): 0096d71

Create modules/simulator.py

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