Nawinkumar15 commited on
Commit
bc4147c
·
verified ·
1 Parent(s): 3195540

Update modules/simulator.py

Browse files
Files changed (1) hide show
  1. modules/simulator.py +17 -15
modules/simulator.py CHANGED
@@ -2,11 +2,14 @@ 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)
@@ -16,26 +19,24 @@ def simulate_data(n=10, faults=True):
16
  vib = round(np.random.uniform(0.1, 2.5), 2)
17
  sufficient = "Yes" if total >= required else "No"
18
  anomaly = []
 
19
  if faults:
20
- if solar < 4.0:
21
- anomaly.append("Low Solar Output")
22
- if wind < 0.7:
23
- anomaly.append("Low Wind Output")
24
- if tilt > 10:
25
- anomaly.append("Pole Tilt Risk")
26
- if vib > 2.0:
27
- anomaly.append("Vibration Alert")
28
- if cam == "Offline":
29
- anomaly.append("Camera Offline")
30
- if sufficient == "No":
31
- anomaly.append("Power Insufficient")
32
  alert = "Green"
33
  if len(anomaly) == 1:
34
  alert = "Yellow"
35
  elif len(anomaly) > 1:
36
  alert = "Red"
 
37
  data.append({
38
  "Pole ID": pole,
 
39
  "Date": today,
40
  "Solar Gen (kWh)": solar,
41
  "Wind Gen (kWh)": wind,
@@ -47,4 +48,5 @@ def simulate_data(n=10, faults=True):
47
  "Anomalies": "; ".join(anomaly) if anomaly else "None",
48
  "Alert Level": alert
49
  })
50
- return pd.DataFrame(data)
 
 
2
  import numpy as np
3
  import datetime
4
 
5
+ def simulate_data(n=48, faults=True):
6
  today = datetime.date.today()
7
+ sites = ["Hyderabad", "Gadwal", "Kurnool", "Ballari"]
8
  poles = [f"Pole_{i+1:03}" for i in range(n)]
9
  data = []
10
+
11
+ for i, pole in enumerate(poles):
12
+ site = sites[i // 12] # 12 poles per site
13
  solar = round(np.random.uniform(3.0, 7.5), 2)
14
  wind = round(np.random.uniform(0.5, 2.0), 2)
15
  required = round(np.random.uniform(1.0, 1.5), 2)
 
19
  vib = round(np.random.uniform(0.1, 2.5), 2)
20
  sufficient = "Yes" if total >= required else "No"
21
  anomaly = []
22
+
23
  if faults:
24
+ if solar < 4.0: anomaly.append("Low Solar Output")
25
+ if wind < 0.7: anomaly.append("Low Wind Output")
26
+ if tilt > 10: anomaly.append("Pole Tilt Risk")
27
+ if vib > 2.0: anomaly.append("Vibration Alert")
28
+ if cam == "Offline": anomaly.append("Camera Offline")
29
+ if sufficient == "No": anomaly.append("Power Insufficient")
30
+
 
 
 
 
 
31
  alert = "Green"
32
  if len(anomaly) == 1:
33
  alert = "Yellow"
34
  elif len(anomaly) > 1:
35
  alert = "Red"
36
+
37
  data.append({
38
  "Pole ID": pole,
39
+ "Site": site,
40
  "Date": today,
41
  "Solar Gen (kWh)": solar,
42
  "Wind Gen (kWh)": wind,
 
48
  "Anomalies": "; ".join(anomaly) if anomaly else "None",
49
  "Alert Level": alert
50
  })
51
+
52
+ return pd.DataFrame(data)