File size: 3,650 Bytes
04cb255
 
 
2631089
04cb255
60e1fc0
04cb255
60e1fc0
04cb255
2631089
870b1ec
316a19c
870b1ec
316a19c
870b1ec
 
4118212
 
870b1ec
4118212
870b1ec
 
 
 
 
 
 
 
 
 
 
 
 
316a19c
 
 
 
 
04cb255
316a19c
04cb255
 
 
 
 
 
 
 
2631089
04cb255
 
 
 
 
 
 
2631089
04cb255
2631089
04cb255
 
 
 
 
 
 
 
 
 
 
2631089
 
316a19c
 
 
04cb255
60e1fc0
04cb255
 
 
 
 
 
 
 
 
 
 
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
79
80
81
82
83
84
85
86
87
88
import pandas as pd
import numpy as np
import datetime
import uuid

def simulate_data(n=50, faults=True, update_time=None):
    today = datetime.date.today()
    update_time = update_time or datetime.datetime.now()  # Use provided time or current time
    poles = [f"Pole_{i+1:03}" for i in range(n)]
    # Distribute poles across 4 locations
    locations = ["Hyderabad"] * 12 + ["Gadwal"] * 12 + ["Kurnool"] * 12 + ["Ballari"] * 14
    # Simulate coordinates and zones for each location
    base_hyderabad = (17.329181, 78.610091)  # Vacant land space in Hyderabad
    coords = {
        "Hyderabad": [
            (
                base_hyderabad[0] + (i * 0.0001) + np.random.uniform(-0.00005, 0.00005),  # Approx 10-15 ft spacing
                base_hyderabad[1] + (i * 0.0001) + np.random.uniform(-0.00005, 0.00005),
                f"Zone_{np.random.choice(['North', 'South', 'Central'])}"
            ) for i in range(12)
        ],
        "Gadwal": [
            (16.235 + np.random.uniform(-0.03, 0.03), 77.795 + np.random.uniform(-0.03, 0.03), f"Zone_{np.random.choice(['East', 'West'])}")
            for _ in range(12)
        ],
        "Kurnool": [
            (15.828 + np.random.uniform(-0.04, 0.04), 78.037 + np.random.uniform(-0.04, 0.04), f"Zone_{np.random.choice(['Urban', 'Rural'])}")
            for _ in range(12)
        ],
        "Ballari": [
            (15.139 + np.random.uniform(-0.04, 0.04), 76.921 + np.random.uniform(-0.04, 0.04), f"Zone_{np.random.choice(['Downtown', 'Industrial', 'Residential'])}")
            for _ in range(14)
        ]
    }
    location_coords = []
    for loc in locations:
        coord = coords[loc].pop(0)
        location_coords.append(coord)
    data = []
    for i, (pole, location, (lat, lon, zone)) in enumerate(zip(poles, locations, location_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"
        rfid = str(uuid.uuid4())[:16]  # 16-digit unique RFID
        anomaly = []
        if faults:
            if solar < 4.0:
                anomaly.append("Low Solar Output")
            if wind < 0.7:
                anomaly.append("Low Wind Output")
            if tilt > 10:
                anomaly.append("High Pole Tilt Risk")
            if vib > 2.0:
                anomaly.append("Excessive Vibration")
            if cam == "Offline":
                anomaly.append("Camera Offline")
            if sufficient == "No":
                anomaly.append("Power Insufficient")
        alert = "Green"
        if len(anomaly) == 1:
            alert = "Yellow"
        elif len(anomaly) > 1:
            alert = "Red"
        data.append({
            "PoleID": pole,
            "RFID": rfid,
            "Location": location,
            "Zone": zone,
            "Latitude": lat,
            "Longitude": lon,
            "Date": today,
            "Timestamp": update_time,
            "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
        })
    return pd.DataFrame(data)