Sanjayraju30 commited on
Commit
720750e
·
verified ·
1 Parent(s): 00e2d3d

Create modules/simulator.py

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