|
import pandas as pd |
|
import numpy as np |
|
import datetime |
|
import uuid |
|
|
|
def simulate_data(n=50, faults=True): |
|
today = datetime.date.today() |
|
poles = [f"Pole_{i+1:03}" for i in range(n)] |
|
|
|
locations = ["Hyderabad"] * 12 + ["Gadwal"] * 12 + ["Kurnool"] * 12 + ["Bangalore"] * 14 |
|
np.random.shuffle(locations) |
|
data = [] |
|
for i, (pole, location) in enumerate(zip(poles, locations)): |
|
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] |
|
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, |
|
"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 |
|
}) |
|
return pd.DataFrame(data) |