DSatishchandra commited on
Commit
c426e1f
·
verified ·
1 Parent(s): 96f1f84

Update modules/simulator.py

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