Nawinkumar15 commited on
Commit
bda640c
·
verified ·
1 Parent(s): 1fb5fb8

Create modules/simulator.py

Browse files
Files changed (1) hide show
  1. modules/simulator.py +65 -0
modules/simulator.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
9
+ # Define site coordinates
10
+ sites = {
11
+ "Hyderabad": (17.3850, 78.4867),
12
+ "Gadwal": (16.2356, 77.7956),
13
+ "Kurnool": (15.8281, 78.0373),
14
+ "Ballari": (15.1394, 76.9214)
15
+ }
16
+
17
+ site_names = list(sites.keys())
18
+ data = []
19
+
20
+ for pole in poles:
21
+ site = np.random.choice(site_names)
22
+ lat, lon = sites[site]
23
+
24
+ solar = round(np.random.uniform(3.0, 7.5), 2)
25
+ wind = round(np.random.uniform(0.5, 2.0), 2)
26
+ required = round(np.random.uniform(1.0, 1.5), 2)
27
+ total = solar + wind
28
+ cam = np.random.choice(['Online', 'Offline'], p=[0.85, 0.15]) if faults else "Online"
29
+ tilt = round(np.random.uniform(0, 12), 1)
30
+ vib = round(np.random.uniform(0.1, 2.5), 2)
31
+ sufficient = "Yes" if total >= required else "No"
32
+
33
+ anomaly = []
34
+ if faults:
35
+ if solar < 4.0: anomaly.append("Low Solar Output")
36
+ if wind < 0.7: anomaly.append("Low Wind Output")
37
+ if tilt > 10: anomaly.append("Pole Tilt Risk")
38
+ if vib > 2.0: anomaly.append("Vibration Alert")
39
+ if cam == "Offline": anomaly.append("Camera Offline")
40
+ if sufficient == "No": anomaly.append("Power Insufficient")
41
+
42
+ alert = "Green"
43
+ if len(anomaly) == 1:
44
+ alert = "Yellow"
45
+ elif len(anomaly) > 1:
46
+ alert = "Red"
47
+
48
+ data.append({
49
+ "Pole ID": pole,
50
+ "Date": today,
51
+ "Site": site,
52
+ "Latitude": lat,
53
+ "Longitude": lon,
54
+ "Solar Gen (kWh)": solar,
55
+ "Wind Gen (kWh)": wind,
56
+ "Power Required (kWh)": required,
57
+ "Power Sufficient": sufficient,
58
+ "Camera Status": cam,
59
+ "Tilt (°)": tilt,
60
+ "Vibration (g)": vib,
61
+ "Anomalies": "; ".join(anomaly) if anomaly else "None",
62
+ "Alert Level": alert
63
+ })
64
+
65
+ return pd.DataFrame(data)