Tigernawin commited on
Commit
c558d4d
·
verified ·
1 Parent(s): a424c96

Create simulator.py

Browse files
Files changed (1) hide show
  1. simulator.py +51 -0
simulator.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # modules/simulator.py
2
+ import pandas as pd
3
+ import numpy as np
4
+ import datetime
5
+
6
+ def simulate_data(n=10, faults=True):
7
+ today = datetime.date.today()
8
+ poles = [f"Pole_{i+1:03}" for i in range(n)]
9
+ data = []
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
+ if faults:
21
+ if solar < 4.0:
22
+ anomaly.append("Low Solar Output")
23
+ if wind < 0.7:
24
+ anomaly.append("Low Wind Output")
25
+ if tilt > 10:
26
+ anomaly.append("Pole Tilt Risk")
27
+ if vib > 2.0:
28
+ anomaly.append("Vibration Alert")
29
+ if cam == "Offline":
30
+ anomaly.append("Camera Offline")
31
+ if sufficient == "No":
32
+ anomaly.append("Power Insufficient")
33
+ alert = "Green"
34
+ if len(anomaly) == 1:
35
+ alert = "Yellow"
36
+ elif len(anomaly) > 1:
37
+ alert = "Red"
38
+ data.append({
39
+ "Pole ID": pole,
40
+ "Date": today,
41
+ "Solar Gen (kWh)": solar,
42
+ "Wind Gen (kWh)": wind,
43
+ "Power Required (kWh)": required,
44
+ "Power Sufficient": sufficient,
45
+ "Camera Status": cam,
46
+ "Tilt (°)": tilt,
47
+ "Vibration (g)": vib,
48
+ "Anomalies": "; ".join(anomaly) if anomaly else "None",
49
+ "Alert Level": alert
50
+ })
51
+ return pd.DataFrame(data)