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

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -100
app.py DELETED
@@ -1,100 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
- import plotly.express as px
4
- from app_backend import fetch_weather, generate_synthetic_data, optimize_load
5
-
6
- # Constants
7
- API_KEY = "84e26811a314599e940f343b4d5894a7"
8
- LOCATION = "Pakistan"
9
-
10
- # Sidebar
11
- st.sidebar.title("Smart Grid Dashboard")
12
- location = st.sidebar.text_input("Enter Location", LOCATION)
13
-
14
- # Fetch and display weather data
15
- weather = fetch_weather(API_KEY, location)
16
- if weather:
17
- st.sidebar.write(f"Temperature: {weather['temperature']} °C")
18
- st.sidebar.write(f"Wind Speed: {weather['wind_speed']} m/s")
19
- st.sidebar.write(f"Weather: {weather['weather']}")
20
-
21
- # Main dashboard with tabs
22
- tabs = st.tabs(["Home", "Electricity Storage", "Electricity Trading"])
23
-
24
- with tabs[0]:
25
- st.title("Real-Time Smart Grid Dashboard")
26
-
27
- # Generate synthetic data
28
- data = generate_synthetic_data()
29
-
30
- # Plot total consumption, grid generation, and storage usage
31
- fig = px.line(data, x="timestamp", y=["total_consumption_kwh", "grid_generation_kwh", "storage_usage_kwh"],
32
- title="Energy Consumption, Generation, and Storage Usage Over Time",
33
- labels={"value": "Energy (kWh)", "variable": "Energy Source"})
34
- st.plotly_chart(fig)
35
-
36
- # Grid health overview
37
- st.subheader("Grid Health Overview")
38
- grid_health_counts = data["grid_health"].value_counts()
39
- st.bar_chart(grid_health_counts)
40
-
41
- # Optimization recommendations
42
- current_demand = data["total_consumption_kwh"].iloc[-1]
43
- current_solar = data["solar_output_kw"].iloc[-1]
44
- current_wind = data["wind_output_kw"].iloc[-1]
45
- recommendation = optimize_load(current_demand, current_solar, current_wind)
46
-
47
- st.subheader("Recommendations")
48
- st.write(f"Current Load Demand: {current_demand} kWh")
49
- st.write(f"Solar Output: {current_solar} kW")
50
- st.write(f"Wind Output: {current_wind} kW")
51
- st.write(f"Recommendation: {recommendation}")
52
-
53
- with tabs[1]:
54
- st.title("Energy Storage Overview")
55
-
56
- # Total energy stored
57
- total_storage = 500 # Example of total energy storage
58
- st.subheader(f"Total Energy Stored: {total_storage} kWh")
59
-
60
- # Energy storage contribution from different sources
61
- st.subheader("Energy Storage Contributions")
62
- energy_sources = pd.DataFrame({
63
- "Source": ["Wind", "Solar", "Turbine"],
64
- "Energy (kW/min)": [5, 7, 10]
65
- })
66
- st.bar_chart(energy_sources.set_index("Source"))
67
-
68
- # Show energy storage status with a rounded circle
69
- st.subheader("Energy Storage Circle")
70
- st.markdown("Energy storage is a combination of contributions from different renewable sources.")
71
-
72
- # Visualization of energy storage circle using Plotly
73
- storage_data = {
74
- "Source": ["Wind", "Solar", "Turbine"],
75
- "Energy": [5, 7, 10],
76
- }
77
- storage_df = pd.DataFrame(storage_data)
78
- fig = px.pie(storage_df, names="Source", values="Energy", title="Energy Storage Sources")
79
- st.plotly_chart(fig)
80
-
81
- with tabs[2]:
82
- st.title("Energy Trading Overview")
83
-
84
- # Energy cubes
85
- st.subheader("Energy Cubes Stored")
86
- energy_cubes = pd.DataFrame({
87
- "Country": ["China", "Sri Lanka", "Bangladesh"],
88
- "Energy (kWh)": [100, 200, 300],
89
- "Shareable": [True, True, False]
90
- })
91
-
92
- # Displaying the energy cubes in a grid
93
- st.write("Stored energy can be shared with other countries.")
94
- st.dataframe(energy_cubes)
95
-
96
- # Visualization of energy that can be shared
97
- st.subheader("Energy Trading Visualization")
98
- st.markdown("The following energy amounts are available for sharing with different countries.")
99
- trading_fig = px.bar(energy_cubes, x="Country", y="Energy (kWh)", color="Shareable", title="Energy Trading")
100
- st.plotly_chart(trading_fig)