Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import plotly.graph_objs as go
|
|
| 7 |
from plotly.subplots import make_subplots
|
| 8 |
import plotly.express as px
|
| 9 |
import datetime
|
|
|
|
| 10 |
|
| 11 |
# Function to fetch renewable energy data
|
| 12 |
def get_renewable_energy_data(city_code):
|
|
@@ -262,4 +263,15 @@ if st.button('Calculate Optimal Energy Mix'):
|
|
| 262 |
|
| 263 |
if correlation_matrix is not None:
|
| 264 |
fig_corr = px.imshow(correlation_matrix, title='Correlation Matrix of Renewable Capacity Factors', labels={'color': 'Correlation'}, template='plotly_white')
|
| 265 |
-
st.plotly_chart(fig_corr, use_container_width=True, height=800)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from plotly.subplots import make_subplots
|
| 8 |
import plotly.express as px
|
| 9 |
import datetime
|
| 10 |
+
import numpy as np
|
| 11 |
|
| 12 |
# Function to fetch renewable energy data
|
| 13 |
def get_renewable_energy_data(city_code):
|
|
|
|
| 263 |
|
| 264 |
if correlation_matrix is not None:
|
| 265 |
fig_corr = px.imshow(correlation_matrix, title='Correlation Matrix of Renewable Capacity Factors', labels={'color': 'Correlation'}, template='plotly_white')
|
| 266 |
+
st.plotly_chart(fig_corr, use_container_width=True, height=800)
|
| 267 |
+
|
| 268 |
+
# Plot heatmaps for renewable energy and demand characteristics
|
| 269 |
+
st.markdown("### Heatmap of Renewable Energy and Demand Characteristics")
|
| 270 |
+
hourly_data = numeric_energy_data_df.copy()
|
| 271 |
+
hourly_data['Date'] = pd.to_datetime(data['Time']).dt.date
|
| 272 |
+
hourly_data['Hour'] = pd.to_datetime(data['Time']).dt.hour
|
| 273 |
+
|
| 274 |
+
for column in hourly_data.columns[2:]: # Skipping 'Date' and 'Hour' columns
|
| 275 |
+
pivot_df = hourly_data.pivot_table(index='Hour', columns='Date', values=column, aggfunc=np.mean)
|
| 276 |
+
fig_heatmap = px.imshow(pivot_df, title=f"Heatmap of {column}", labels={'color': column}, template='plotly_white', aspect='auto')
|
| 277 |
+
st.plotly_chart(fig_heatmap, use_container_width=True, height=800)
|