File size: 3,068 Bytes
4982cc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import pandas as pd
import numpy as np
import datetime

def simulate_data(n=50, faults=True):
    today = datetime.date.today()
    sites = ["Hyderabad", "Ballari", "Kurnool", "Gadwal"]
    poles_per_site = n // len(sites)  # Approximately 12-13 poles per site
    poles = []
    site_assignments = []
    x_coords = []
    y_coords = []

    # Assign poles to sites and generate spatial coordinates for heatmap
    for i, site in enumerate(sites):
        site_poles = [f"Pole_{j+1:03}" for j in range(i * poles_per_site, (i + 1) * poles_per_site)]
        poles.extend(site_poles)
        site_assignments.extend([site] * len(site_poles))
        # Assign coordinates within a grid for each site (e.g., 4x4 grid per site)
        for _ in site_poles:
            x_coords.append(np.random.uniform(i * 10, (i + 1) * 10))  # Spread across x-axis per site
            y_coords.append(np.random.uniform(0, 10))  # Common y-axis range

    # Handle remaining poles (to reach exactly 50)
    remaining = n - len(poles)
    if remaining > 0:
        extra_poles = [f"Pole_{len(poles)+j+1:03}" for j in range(remaining)]
        poles.extend(extra_poles)
        site_assignments.extend([sites[-1]] * remaining)
        x_coords.extend([np.random.uniform(30, 40)] * remaining)
        y_coords.extend([np.random.uniform(0, 10)] * remaining)

    data = []
    for pole, site, x, y in zip(poles, site_assignments, x_coords, y_coords):
        solar = round(np.random.uniform(3.0, 7.5), 2)
        wind = round(np.random.uniform(0.5, 2.0), 2)
        required = round(np.random.uniform(1.0, 1.5), 2)
        total = solar + wind
        cam = np.random.choice(['Online', 'Offline'], p=[0.85, 0.15]) if faults else "Online"
        tilt = round(np.random.uniform(0, 12), 1)
        vib = round(np.random.uniform(0.1, 2.5), 2)
        sufficient = "Yes" if total >= required else "No"
        anomaly = []
        if faults:
            if solar < 4.0:
                anomaly.append("LowSolarOutput")
            if wind < 0.7:
                anomaly.append("LowWindOutput")
            if tilt > 10:
                anomaly.append("PoleTiltRisk")
            if vib > 2.0:
                anomaly.append("VibrationAlert")
            if cam == "Offline":
                anomaly.append("CameraOffline")
            if sufficient == "No":
                anomaly.append("PowerInsufficient")
        alert = "Green"
        if len(anomaly) == 1:
            alert = "Yellow"
        elif len(anomaly) > 1:
            alert = "Red"
        data.append({
            "PoleID": pole,
            "Site": site,
            "Date": today,
            "SolarGen(kWh)": solar,
            "WindGen(kWh)": wind,
            "PowerRequired(kWh)": required,
            "PowerSufficient": sufficient,
            "CameraStatus": cam,
            "Tilt(°)": tilt,
            "Vibration(g)": vib,
            "Anomalies": ";".join(anomaly) if anomaly else "None",
            "AlertLevel": alert,
            "XCoord": x,
            "YCoord": y
        })
    return pd.DataFrame(data)