Sanjayraju30 commited on
Commit
bd95f45
·
verified ·
1 Parent(s): 8ee4423

Update modules/simulator.py

Browse files
Files changed (1) hide show
  1. modules/simulator.py +47 -16
modules/simulator.py CHANGED
@@ -1,19 +1,50 @@
1
  import pandas as pd
2
  import numpy as np
3
 
4
- def simulate_pole_data(n=100):
5
- np.random.seed(1)
6
- sites = ["Hyderabad", "Ballari", "Gadwal", "Kurnool"]
7
- df = pd.DataFrame({
8
- "PoleID": [f"Pole_{i:05}" for i in range(n)],
9
- "Site": np.random.choice(sites, size=n),
10
- "Location_Latitude": np.random.uniform(16.5, 18.5, n),
11
- "Location_Longitude": np.random.uniform(77.0, 79.5, n),
12
- "SolarGen(kWh)": np.random.uniform(2.0, 6.5, n),
13
- "WindGen(kWh)": np.random.uniform(0.3, 2.5, n),
14
- "Tilt(°)": np.random.uniform(0, 20, n),
15
- "Vibration(g)": np.random.uniform(0.1, 3.5, n),
16
- "CameraStatus": np.random.choice(["Online", "Offline"], n),
17
- "PowerSufficient": np.random.choice(["Yes", "No"], n),
18
- })
19
- return df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import pandas as pd
2
  import numpy as np
3
 
4
+ def simulate_data(n=50, faults=True):
5
+ np.random.seed(42)
6
+ sites = {
7
+ "Hyderabad": (17.385, 78.4867),
8
+ "Ballari": (15.1394, 76.9214),
9
+ "Gadwal": (16.232, 77.795),
10
+ "Kurnool": (15.8281, 78.0373)
11
+ }
12
+ data = []
13
+ for i in range(n):
14
+ site = np.random.choice(list(sites.keys()))
15
+ lat, lon = sites[site]
16
+ solar = np.round(np.random.uniform(3, 7.5), 2)
17
+ wind = np.round(np.random.uniform(0.5, 2.0), 2)
18
+ tilt = np.round(np.random.uniform(0, 15), 1)
19
+ vib = np.round(np.random.uniform(0.1, 3.0), 2)
20
+ cam = np.random.choice(["Online", "Offline"], p=[0.85, 0.15])
21
+ power_required = np.round(np.random.uniform(1.0, 1.5), 2)
22
+ total = solar + wind
23
+ sufficient = "Yes" if total >= power_required else "No"
24
+
25
+ anomaly = []
26
+ if faults:
27
+ if solar < 4.0: anomaly.append("Low Solar")
28
+ if wind < 0.7: anomaly.append("Low Wind")
29
+ if tilt > 10: anomaly.append("Tilt Risk")
30
+ if vib > 2.0: anomaly.append("Vibration Alert")
31
+ if cam == "Offline": anomaly.append("Camera Offline")
32
+ if sufficient == "No": anomaly.append("Power Insufficient")
33
+
34
+ alert = "Green" if len(anomaly) == 0 else "Yellow" if len(anomaly) == 1 else "Red"
35
+
36
+ data.append({
37
+ "Pole ID": f"Pole_{i+1:03}",
38
+ "Site": site,
39
+ "Latitude": lat + np.random.uniform(-0.01, 0.01),
40
+ "Longitude": lon + np.random.uniform(-0.01, 0.01),
41
+ "SolarGen(kWh)": solar,
42
+ "WindGen(kWh)": wind,
43
+ "Tilt(°)": tilt,
44
+ "Vibration(g)": vib,
45
+ "Camera Status": cam,
46
+ "Power Sufficient": sufficient,
47
+ "Anomalies": "; ".join(anomaly) if anomaly else "None",
48
+ "Alert Level": alert
49
+ })
50
+ return pd.DataFrame(data)