Nawinkumar15 commited on
Commit
af81e4c
·
verified ·
1 Parent(s): 9870ede

Update modules/simulator.py

Browse files
Files changed (1) hide show
  1. modules/simulator.py +46 -23
modules/simulator.py CHANGED
@@ -4,17 +4,24 @@ import datetime
4
 
5
  def simulate_data(n=48, faults=True):
6
  today = datetime.date.today()
7
- site_coords = {
8
- "Hyderabad": (17.3850, 78.4867),
9
- "Gadwal": (16.2350, 77.8000),
10
- "Kurnool": (15.8281, 78.0373),
11
- "Ballari": (15.1394, 76.9214)
12
- }
 
 
 
 
 
13
  poles = [f"Pole_{i+1:03}" for i in range(n)]
14
  data = []
15
 
16
  for i, pole in enumerate(poles):
17
  site = sites[i // 12] # 12 poles per site
 
 
18
  solar = round(np.random.uniform(3.0, 7.5), 2)
19
  wind = round(np.random.uniform(0.5, 2.0), 2)
20
  required = round(np.random.uniform(1.0, 1.5), 2)
@@ -23,28 +30,44 @@ def simulate_data(n=48, faults=True):
23
  tilt = round(np.random.uniform(0, 12), 1)
24
  vib = round(np.random.uniform(0.1, 2.5), 2)
25
  sufficient = "Yes" if total >= required else "No"
26
- anomaly = []
27
 
 
28
  if faults:
29
- if solar < 4.0: anomaly.append("Low Solar Output")
30
- if wind < 0.7: anomaly.append("Low Wind Output")
31
- if tilt > 10: anomaly.append("Pole Tilt Risk")
32
- if vib > 2.0: anomaly.append("Vibration Alert")
33
- if cam == "Offline": anomaly.append("Camera Offline")
34
- if sufficient == "No": anomaly.append("Power Insufficient")
 
 
 
 
 
 
35
 
36
  alert = "Green"
37
  if len(anomaly) == 1:
38
  alert = "Yellow"
39
  elif len(anomaly) > 1:
40
  alert = "Red"
41
-
42
- lat, lon = site_coords[site]
43
-
44
- data.append({
45
- "Pole ID": pole,
46
- "Site": site,
47
- "Latitude": lat + np.random.uniform(-0.005, 0.005), # Add small variation for each pole
48
- "Longitude": lon + np.random.uniform(-0.005, 0.005),
49
- ...
50
- })
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  def simulate_data(n=48, faults=True):
6
  today = datetime.date.today()
7
+
8
+ sites = ["Hyderabad", "Gadwal", "Kurnool", "Ballari"]
9
+
10
+ # Define latitude and longitude for each site
11
+ site_coords = {
12
+ "Hyderabad": (17.3850, 78.4867),
13
+ "Gadwal": (16.2350, 77.8000),
14
+ "Kurnool": (15.8281, 78.0373),
15
+ "Ballari": (15.1394, 76.9214)
16
+ }
17
+
18
  poles = [f"Pole_{i+1:03}" for i in range(n)]
19
  data = []
20
 
21
  for i, pole in enumerate(poles):
22
  site = sites[i // 12] # 12 poles per site
23
+ lat, lon = site_coords[site]
24
+
25
  solar = round(np.random.uniform(3.0, 7.5), 2)
26
  wind = round(np.random.uniform(0.5, 2.0), 2)
27
  required = round(np.random.uniform(1.0, 1.5), 2)
 
30
  tilt = round(np.random.uniform(0, 12), 1)
31
  vib = round(np.random.uniform(0.1, 2.5), 2)
32
  sufficient = "Yes" if total >= required else "No"
 
33
 
34
+ anomaly = []
35
  if faults:
36
+ if solar < 4.0:
37
+ anomaly.append("Low Solar Output")
38
+ if wind < 0.7:
39
+ anomaly.append("Low Wind Output")
40
+ if tilt > 10:
41
+ anomaly.append("Pole Tilt Risk")
42
+ if vib > 2.0:
43
+ anomaly.append("Vibration Alert")
44
+ if cam == "Offline":
45
+ anomaly.append("Camera Offline")
46
+ if sufficient == "No":
47
+ anomaly.append("Power Insufficient")
48
 
49
  alert = "Green"
50
  if len(anomaly) == 1:
51
  alert = "Yellow"
52
  elif len(anomaly) > 1:
53
  alert = "Red"
54
+
55
+ data.append({
56
+ "Pole ID": pole,
57
+ "Site": site,
58
+ "Latitude": lat + np.random.uniform(-0.005, 0.005), # small offset
59
+ "Longitude": lon + np.random.uniform(-0.005, 0.005),
60
+ "Date": today,
61
+ "Solar Gen (kWh)": solar,
62
+ "Wind Gen (kWh)": wind,
63
+ "Power Required (kWh)": required,
64
+ "Power Sufficient": sufficient,
65
+ "Camera Status": cam,
66
+ "Tilt (°)": tilt,
67
+ "Vibration (g)": vib,
68
+ "Anomalies": "; ".join(anomaly) if anomaly else "None",
69
+ "Alert Level": alert
70
+ })
71
+
72
+ return pd.DataFrame(data)
73
+