hareshchander commited on
Commit
006252e
·
verified ·
1 Parent(s): f436e07

Delete app_backend.py

Browse files
Files changed (1) hide show
  1. app_backend.py +0 -37
app_backend.py DELETED
@@ -1,37 +0,0 @@
1
- import pandas as pd
2
- import numpy as np
3
- import requests
4
- from datetime import datetime
5
-
6
- # Function to fetch real-time weather data
7
- def fetch_weather(api_key, location):
8
- url = f"http://api.openweathermap.org/data/2.5/weather?q={location}&appid={api_key}&units=metric"
9
- response = requests.get(url).json()
10
- if response["cod"] == 200:
11
- return {
12
- "temperature": response["main"]["temp"],
13
- "wind_speed": response["wind"]["speed"],
14
- "weather": response["weather"][0]["description"]
15
- }
16
- return None
17
-
18
- # Generate synthetic grid data
19
- def generate_synthetic_data():
20
- time_index = pd.date_range(start=datetime.now(), periods=24, freq="H")
21
- return pd.DataFrame({
22
- "timestamp": time_index,
23
- "load_demand_kwh": np.random.randint(200, 500, len(time_index)),
24
- "solar_output_kw": np.random.randint(50, 150, len(time_index)),
25
- "wind_output_kw": np.random.randint(30, 120, len(time_index)),
26
- "grid_health": np.random.choice(["Good", "Moderate", "Critical"], len(time_index))
27
- })
28
-
29
- # Load optimization recommendation
30
- def optimize_load(demand, solar, wind):
31
- renewable_supply = solar + wind
32
- if renewable_supply >= demand:
33
- return "Grid Stable"
34
- return "Use Backup or Adjust Load"
35
-
36
- if __name__ == "__main__":
37
- print("Backend ready!")