heatmap_advance / modules /simulator.py
Sanjayraju30's picture
Update modules/simulator.py
bd95f45 verified
raw
history blame
1.91 kB
import pandas as pd
import numpy as np
def simulate_data(n=50, faults=True):
np.random.seed(42)
sites = {
"Hyderabad": (17.385, 78.4867),
"Ballari": (15.1394, 76.9214),
"Gadwal": (16.232, 77.795),
"Kurnool": (15.8281, 78.0373)
}
data = []
for i in range(n):
site = np.random.choice(list(sites.keys()))
lat, lon = sites[site]
solar = np.round(np.random.uniform(3, 7.5), 2)
wind = np.round(np.random.uniform(0.5, 2.0), 2)
tilt = np.round(np.random.uniform(0, 15), 1)
vib = np.round(np.random.uniform(0.1, 3.0), 2)
cam = np.random.choice(["Online", "Offline"], p=[0.85, 0.15])
power_required = np.round(np.random.uniform(1.0, 1.5), 2)
total = solar + wind
sufficient = "Yes" if total >= power_required else "No"
anomaly = []
if faults:
if solar < 4.0: anomaly.append("Low Solar")
if wind < 0.7: anomaly.append("Low Wind")
if tilt > 10: anomaly.append("Tilt Risk")
if vib > 2.0: anomaly.append("Vibration Alert")
if cam == "Offline": anomaly.append("Camera Offline")
if sufficient == "No": anomaly.append("Power Insufficient")
alert = "Green" if len(anomaly) == 0 else "Yellow" if len(anomaly) == 1 else "Red"
data.append({
"Pole ID": f"Pole_{i+1:03}",
"Site": site,
"Latitude": lat + np.random.uniform(-0.01, 0.01),
"Longitude": lon + np.random.uniform(-0.01, 0.01),
"SolarGen(kWh)": solar,
"WindGen(kWh)": wind,
"Tilt(°)": tilt,
"Vibration(g)": vib,
"Camera Status": cam,
"Power Sufficient": sufficient,
"Anomalies": "; ".join(anomaly) if anomaly else "None",
"Alert Level": alert
})
return pd.DataFrame(data)