Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| import numpy as np | |
| import datetime | |
| # Rough base coordinates for each site (example, can adjust for realism) | |
| site_coords = { | |
| "Hyderabad": (17.385, 78.4867), | |
| "Gadwal": (16.2333, 77.8), | |
| "Kurnool": (15.8281, 78.0373), | |
| "Ballari": (15.1394, 76.9214) | |
| } | |
| def simulate_data(n=48, faults=True): | |
| today = datetime.date.today() | |
| sites = list(site_coords.keys()) | |
| data = [] | |
| poles_per_site = n // len(sites) | |
| for site in sites: | |
| base_lat, base_lon = site_coords[site] | |
| for i in range(poles_per_site): | |
| pole_num = len(data) + 1 | |
| pole_id = f"Pole_{pole_num:03}" | |
| # Spread out poles in a grid (every 10 feet ≈ 0.00003 degrees) | |
| row = i // 4 | |
| col = i % 4 | |
| lat = base_lat + row * 0.00003 | |
| lon = base_lon + col * 0.00003 | |
| 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("Low Solar Output") | |
| if wind < 0.7: anomaly.append("Low Wind Output") | |
| if tilt > 10: anomaly.append("Pole 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) == 1: | |
| alert = "Yellow" | |
| elif len(anomaly) > 1: | |
| alert = "Red" | |
| data.append({ | |
| "Pole ID": pole_id, | |
| "Site": site, | |
| "Date": today, | |
| "Latitude": lat, | |
| "Longitude": lon, | |
| "Solar Gen (kWh)": solar, | |
| "Wind Gen (kWh)": wind, | |
| "Power Required (kWh)": required, | |
| "Power Sufficient": sufficient, | |
| "Camera Status": cam, | |
| "Tilt (°)": tilt, | |
| "Vibration (g)": vib, | |
| "Anomalies": "; ".join(anomaly) if anomaly else "None", | |
| "Alert Level": alert | |
| }) | |
| return pd.DataFrame(data) | |