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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import warnings
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
import pandas as pd
|
| 5 |
+
from datetime import datetime, timedelta
|
| 6 |
+
import plotly.graph_objects as go
|
| 7 |
+
from streamlit_option_menu import option_menu
|
| 8 |
+
from plotly.subplots import make_subplots
|
| 9 |
+
from functions import create_combined_time_series
|
| 10 |
+
from functions import (create_area_chart, create_combined_time_series, create_area_mixte, aggregation_menu,
|
| 11 |
+
create_column_mapping, group_by_src, sum_columns_with_suffix, aggregate_by_country,
|
| 12 |
+
process_data_by_month, create_pivot_table, create_heatmap, bar_group_consumption,
|
| 13 |
+
|
| 14 |
+
bar_group_ghg,process_ghg_data_by_month, bar_consumption, bar_ghg,download_data_as_csv)
|
| 15 |
+
|
| 16 |
+
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
| 17 |
+
|
| 18 |
+
# Configuration de la page Streamlit
|
| 19 |
+
st.set_page_config(page_title="Ecodynelec", page_icon=":bar_chart:", layout="wide")
|
| 20 |
+
|
| 21 |
+
# Create three columns, and place the logo in the rightmost column
|
| 22 |
+
logocol1, logocol2, logocol3 = st.columns([1, 8, 1]) # You can adjust these ratios to fit your needs
|
| 23 |
+
|
| 24 |
+
# Place the logo in the right column (col3)
|
| 25 |
+
with logocol1:
|
| 26 |
+
st.image('data/Logo_colored_variant.png', use_container_width=False,width=300) # Set the logo to fit the column width
|
| 27 |
+
with logocol3:
|
| 28 |
+
st.image('data/IE_HEIG-VD_logotype_rouge_rvb.svg', use_container_width=True)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
# Sidebar Menu with Main Options
|
| 34 |
+
with st.sidebar:
|
| 35 |
+
main_option = option_menu(
|
| 36 |
+
menu_title="Main Menu", # Main menu title
|
| 37 |
+
options=["Mix data", "Applications", "Methodology"], # Main menu options
|
| 38 |
+
icons=["database", "layers", "gear", "info-circle"], # Optional icons
|
| 39 |
+
menu_icon="cast", # Main menu icon
|
| 40 |
+
default_index=0, # Default active index
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
if main_option == "Applications":
|
| 44 |
+
applications_option = option_menu(
|
| 45 |
+
menu_title="Applications", # Applications submenu
|
| 46 |
+
options=["Bâtiment", "PAC"], # Submenu options
|
| 47 |
+
icons=["building", "plug"], # Submenu icons
|
| 48 |
+
menu_icon="apps", # Submenu icon
|
| 49 |
+
default_index=0,
|
| 50 |
+
orientation="vertical"
|
| 51 |
+
)
|
| 52 |
+
else:
|
| 53 |
+
applications_option = None
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
# Données flows
|
| 58 |
+
flows_FR = pd.read_parquet("./data/flows/flows_FR.parquet.gz")
|
| 59 |
+
flows_DE = pd.read_parquet("./data/flows/flows_DE.parquet.gz")
|
| 60 |
+
flows_AT = pd.read_parquet("./data/flows/flows_AT.parquet.gz")
|
| 61 |
+
flows_CH = pd.read_parquet("./data/flows/flows_CH.parquet.gz")
|
| 62 |
+
flows_IT = pd.read_parquet("./data/flows/flows_IT.parquet.gz")
|
| 63 |
+
|
| 64 |
+
# Données de consommation totale
|
| 65 |
+
tot_consumption_FR = pd.read_parquet("./data/consumptions/tot_consumption_FR.parquet.gz")
|
| 66 |
+
tot_consumption_DE = pd.read_parquet("./data/consumptions/tot_consumption_DE.parquet.gz")
|
| 67 |
+
tot_consumption_AT = pd.read_parquet("./data/consumptions/tot_consumption_AT.parquet.gz")
|
| 68 |
+
tot_consumption_CH = pd.read_parquet("./data/consumptions/tot_consumption_CH.parquet.gz")
|
| 69 |
+
tot_consumption_IT = pd.read_parquet("./data/consumptions/tot_consumption_IT.parquet.gz")
|
| 70 |
+
|
| 71 |
+
# Données de consommation by src
|
| 72 |
+
raw_consumption_by_src_FR = pd.read_parquet("./data/consumptions/raw_consumption_by_src_FR.parquet.gz")
|
| 73 |
+
raw_consumption_by_src_DE = pd.read_parquet("./data/consumptions/raw_consumption_by_src_DE.parquet.gz")
|
| 74 |
+
raw_consumption_by_src_AT = pd.read_parquet("./data/consumptions/raw_consumption_by_src_AT.parquet.gz")
|
| 75 |
+
raw_consumption_by_src_CH = pd.read_parquet("./data/consumptions/raw_consumption_by_src_CH.parquet.gz")
|
| 76 |
+
raw_consumption_by_src_IT = pd.read_parquet("./data/consumptions/raw_consumption_by_src_IT.parquet.gz")
|
| 77 |
+
|
| 78 |
+
# electricity_mixs
|
| 79 |
+
tot_electricity_mix_CH = pd.read_parquet("./data/electricity_mixs/electricity_mix_CH.parquet.gz")
|
| 80 |
+
tot_electricity_mix_AT = pd.read_parquet("./data/electricity_mixs/electricity_mix_AT.parquet.gz")
|
| 81 |
+
tot_electricity_mix_DE = pd.read_parquet("./data/electricity_mixs/electricity_mix_DE.parquet.gz")
|
| 82 |
+
tot_electricity_mix_FR = pd.read_parquet("./data/electricity_mixs/electricity_mix_FR.parquet.gz")
|
| 83 |
+
tot_electricity_mix_IT = pd.read_parquet("./data/electricity_mixs/electricity_mix_IT.parquet.gz")
|
| 84 |
+
|
| 85 |
+
# electricity_impacts
|
| 86 |
+
tot_electricity_impact_CH = pd.read_parquet("./data/electricity_impacts/electricity_impact_CH.parquet.gz")
|
| 87 |
+
tot_electricity_impact_AT = pd.read_parquet("./data/electricity_impacts/electricity_impact_AT.parquet.gz")
|
| 88 |
+
tot_electricity_impact_DE = pd.read_parquet("./data/electricity_impacts/electricity_impact_DE.parquet.gz")
|
| 89 |
+
tot_electricity_impact_FR = pd.read_parquet("./data/electricity_impacts/electricity_impact_FR.parquet.gz")
|
| 90 |
+
tot_electricity_impact_IT = pd.read_parquet("./data/electricity_impacts/electricity_impact_IT.parquet.gz")
|
| 91 |
+
|
| 92 |
+
# electricity_impacts by source
|
| 93 |
+
electricity_impact_by_src_CH = pd.read_parquet("./data/electricity_impacts/electricity_impact_by_src_CH.parquet.gz")
|
| 94 |
+
electricity_impact_by_src_AT = pd.read_parquet("./data/electricity_impacts/electricity_impact_by_src_AT.parquet.gz")
|
| 95 |
+
electricity_impact_by_src_DE = pd.read_parquet("./data/electricity_impacts/electricity_impact_by_src_DE.parquet.gz")
|
| 96 |
+
electricity_impact_by_src_FR = pd.read_parquet("./data/electricity_impacts/electricity_impact_by_src_FR.parquet.gz")
|
| 97 |
+
electricity_impact_by_src_IT = pd.read_parquet("./data/electricity_impacts/electricity_impact_by_src_IT.parquet.gz")
|
| 98 |
+
|
| 99 |
+
# Technologies
|
| 100 |
+
Techno_FR = pd.read_parquet("./data/technologies/technologies_FR.parquet.gz")
|
| 101 |
+
Techno_AT = pd.read_parquet("./data/technologies/technologies_AT.parquet.gz")
|
| 102 |
+
Techno_DE = pd.read_parquet("./data/technologies/technologies_DE.parquet.gz")
|
| 103 |
+
Techno_CH = pd.read_parquet("./data/technologies/technologies_CH.parquet.gz")
|
| 104 |
+
Techno_IT = pd.read_parquet("./data/technologies/technologies_IT.parquet.gz")
|
| 105 |
+
|
| 106 |
+
# Technologies impact
|
| 107 |
+
Techno_impact_FR = pd.read_parquet("./data/technologies/Techno_impact_FR.parquet.gz")
|
| 108 |
+
Techno_impact_AT = pd.read_parquet("./data/technologies/Techno_impact_AT.parquet.gz")
|
| 109 |
+
Techno_impact_DE = pd.read_parquet("./data/technologies/Techno_impact_DE.parquet.gz")
|
| 110 |
+
Techno_impact_CH = pd.read_parquet("./data/technologies/Techno_impact_CH.parquet.gz")
|
| 111 |
+
Techno_impact_IT = pd.read_parquet("./data/technologies/Techno_impact_IT.parquet.gz")
|
| 112 |
+
|
| 113 |
+
for df in [flows_FR, flows_DE, flows_AT, flows_CH, tot_consumption_FR, tot_consumption_DE, tot_consumption_AT, tot_consumption_CH,
|
| 114 |
+
tot_electricity_mix_CH,tot_electricity_mix_AT,tot_electricity_mix_DE,tot_electricity_mix_FR,tot_electricity_impact_CH,
|
| 115 |
+
tot_electricity_impact_AT,tot_electricity_impact_DE,tot_electricity_impact_FR,raw_consumption_by_src_FR,raw_consumption_by_src_CH,
|
| 116 |
+
raw_consumption_by_src_DE,raw_consumption_by_src_AT,electricity_impact_by_src_CH,electricity_impact_by_src_AT,
|
| 117 |
+
electricity_impact_by_src_DE,electricity_impact_by_src_FR,Techno_FR,Techno_AT,Techno_DE,Techno_CH,Techno_impact_FR,Techno_impact_AT,
|
| 118 |
+
Techno_impact_DE,Techno_impact_CH,flows_IT,tot_consumption_IT,raw_consumption_by_src_IT,tot_electricity_mix_IT,
|
| 119 |
+
tot_electricity_impact_IT,electricity_impact_by_src_IT,Techno_IT,Techno_impact_IT]:
|
| 120 |
+
|
| 121 |
+
df.rename(columns={'Unnamed: 0': 'Date'}, inplace=True)
|
| 122 |
+
df['Date'] = pd.to_datetime(df['Date'])
|
| 123 |
+
df.set_index('Date', inplace=True)
|
| 124 |
+
|
| 125 |
+
for df in [flows_FR, flows_DE, flows_AT, flows_CH,flows_IT]:
|
| 126 |
+
df['total_consumption']=df['production']+df['imports']-df['exports']
|
| 127 |
+
|
| 128 |
+
# Utilisation de colonnes pour une mise en page personnalisée
|
| 129 |
+
col1, col2, col3, col4, col5 = st.columns(5) # Créer 5 colonnes
|
| 130 |
+
years = list(range(2016, 2023))
|
| 131 |
+
months = ["January", "February", "March", "April", "May", "June",
|
| 132 |
+
"July", "August", "September", "October", "November", "December"]
|
| 133 |
+
|
| 134 |
+
Countries = {'Switzerland': 'CH', 'France': 'FR', 'Germany': 'DE', 'Austria': 'AT','Italy':'IT'}
|
| 135 |
+
|
| 136 |
+
ordered_countries = ['CH', 'DE', 'FR', 'AT', 'IT', 'Other']
|
| 137 |
+
ordered_colors = ['blue','green', 'red', 'purple', 'orange', 'yellow' ]
|
| 138 |
+
month_dict = {1: "January", 2: "February", 3: "March", 4: "April",5: "May", 6: "June", 7: "July", 8: "August",9: "September", 10: "October", 11: "November", 12: "December"}
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
# Dictionary of dataframes with Italy added
|
| 143 |
+
dataframes_flows = {'Switzerland': flows_CH,
|
| 144 |
+
'France': flows_FR,
|
| 145 |
+
'Germany': flows_DE,
|
| 146 |
+
'Austria': flows_AT,
|
| 147 |
+
'Italy': flows_IT
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
dataframes_tot_consumption = {
|
| 151 |
+
'Switzerland': tot_consumption_CH,
|
| 152 |
+
'France': tot_consumption_FR,
|
| 153 |
+
'Germany': tot_consumption_DE,
|
| 154 |
+
'Austria': tot_consumption_AT,
|
| 155 |
+
'Italy': tot_consumption_IT
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
dataframes_raw_consumption_by_src = {
|
| 159 |
+
'Switzerland': raw_consumption_by_src_CH,
|
| 160 |
+
'France': raw_consumption_by_src_FR,
|
| 161 |
+
'Germany': raw_consumption_by_src_DE,
|
| 162 |
+
'Austria': raw_consumption_by_src_AT,
|
| 163 |
+
'Italy': raw_consumption_by_src_IT
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
dataframes_tot_electricity_mix = {
|
| 167 |
+
'Switzerland': tot_electricity_mix_CH,
|
| 168 |
+
'France': tot_electricity_mix_FR,
|
| 169 |
+
'Germany': tot_electricity_mix_DE,
|
| 170 |
+
'Austria': tot_electricity_mix_AT,
|
| 171 |
+
'Italy': tot_electricity_mix_IT
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
dataframes_tot_electricity_impact = {
|
| 175 |
+
'Switzerland': tot_electricity_impact_CH,
|
| 176 |
+
'France': tot_electricity_impact_FR,
|
| 177 |
+
'Germany': tot_electricity_impact_DE,
|
| 178 |
+
'Austria': tot_electricity_impact_AT,
|
| 179 |
+
'Italy': tot_electricity_impact_IT
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
dataframes_electricity_impact_by_src = {
|
| 183 |
+
'Switzerland': electricity_impact_by_src_CH,
|
| 184 |
+
'France': electricity_impact_by_src_FR,
|
| 185 |
+
'Germany': electricity_impact_by_src_DE,
|
| 186 |
+
'Austria': electricity_impact_by_src_AT,
|
| 187 |
+
'Italy': electricity_impact_by_src_IT
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
dataframes_techno = {
|
| 191 |
+
'Switzerland': Techno_CH,
|
| 192 |
+
'France': Techno_FR,
|
| 193 |
+
'Germany': Techno_DE,
|
| 194 |
+
'Austria': Techno_AT,
|
| 195 |
+
'Italy': Techno_IT
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
dataframes_techno_impact = {
|
| 199 |
+
'Switzerland': Techno_impact_CH,
|
| 200 |
+
'France': Techno_impact_FR,
|
| 201 |
+
'Germany': Techno_impact_DE,
|
| 202 |
+
'Austria': Techno_impact_AT,
|
| 203 |
+
'Italy': Techno_impact_IT
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
with col1:
|
| 213 |
+
selected_country_name = st.selectbox('Choose a country:', list(Countries.keys()))
|
| 214 |
+
|
| 215 |
+
with col2:
|
| 216 |
+
resolution = st.selectbox('Resolution:', ['Annual', 'Monthly','Daily','Hourly'])
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
# Récupération du DataFrame basé sur le pays sélectionné
|
| 220 |
+
tot_consumption_selected_df = dataframes_tot_consumption [selected_country_name]
|
| 221 |
+
raw_consumption_by_src_selected_df = dataframes_raw_consumption_by_src [selected_country_name]
|
| 222 |
+
flows_selected_df =dataframes_flows[selected_country_name]
|
| 223 |
+
tot_electricity_mix_selected_df = dataframes_tot_electricity_mix [selected_country_name]
|
| 224 |
+
tot_electricity_impact_selected_df = dataframes_tot_electricity_impact [selected_country_name]
|
| 225 |
+
electricity_impact_by_src_selected_df = dataframes_electricity_impact_by_src [selected_country_name]
|
| 226 |
+
techno_selected_df=dataframes_techno [selected_country_name]
|
| 227 |
+
techno_impact_selected_df=dataframes_techno_impact [selected_country_name]
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
if main_option == "Mix data":
|
| 233 |
+
if resolution == 'Annual':
|
| 234 |
+
flows_selected_df['exports'] = -flows_selected_df['exports']
|
| 235 |
+
flows_annual_df = flows_selected_df.resample('Y').sum() / 1000
|
| 236 |
+
flows_annual_df.index = flows_annual_df.index.year
|
| 237 |
+
tot_consumption_annual_df = tot_consumption_selected_df['sum'].resample('Y').sum() / 1000
|
| 238 |
+
|
| 239 |
+
col1, col2 = st.columns(2)
|
| 240 |
+
with col1:
|
| 241 |
+
|
| 242 |
+
bar_group_consumption(flows_annual_df, title=f'Yearly Time Series of Production, Imports, and Exports in {selected_country_name} ', text="GWh",
|
| 243 |
+
y_cols=['total_consumption', 'production', 'imports', 'exports'], barmode='group')
|
| 244 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 245 |
+
|
| 246 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 247 |
+
with download_col:
|
| 248 |
+
download_data_as_csv(flows_annual_df, f"Yearly_Time_Series_of_Production_Imports_and_Exports_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 249 |
+
|
| 250 |
+
# Use an expander to display the general description in info_col (right)
|
| 251 |
+
with info_col:
|
| 252 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 253 |
+
st.write(f"""
|
| 254 |
+
**Chart Description:**
|
| 255 |
+
This bar chart represents the yearly time series of production, imports, exports, and total electricity consumption in **{selected_country_name}**,
|
| 256 |
+
measured in gigawatt-hours (GWh), over a period from 2016 to 2022.
|
| 257 |
+
|
| 258 |
+
**Data Source:** EcoDynElec
|
| 259 |
+
""")
|
| 260 |
+
|
| 261 |
+
# pour les impacts
|
| 262 |
+
consumer_impact_annual = tot_electricity_impact_selected_df['sum'].resample('Y').mean()
|
| 263 |
+
consumer_impact_annual.index = consumer_impact_annual.index.year
|
| 264 |
+
with col2:
|
| 265 |
+
bar_group_ghg(consumer_impact_annual, f'Yearly average of GHG emissions in {selected_country_name}')
|
| 266 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 267 |
+
|
| 268 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 269 |
+
with download_col:
|
| 270 |
+
download_data_as_csv(consumer_impact_annual, f"Yearly_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 271 |
+
|
| 272 |
+
# Use an expander to display the general description in info_col (right)
|
| 273 |
+
with info_col:
|
| 274 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 275 |
+
st.write(f"""
|
| 276 |
+
**Chart Description:**
|
| 277 |
+
This bar chart represents the yearly average of greenhouse gas (GHG) emissions in **{selected_country_name}**,
|
| 278 |
+
measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh), from 2016 to 2022.
|
| 279 |
+
|
| 280 |
+
**Data Source:** EcoDynElec
|
| 281 |
+
""")
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
selection = aggregation_menu()
|
| 287 |
+
if selection == "Mixed":
|
| 288 |
+
raw_consumption_by_src_annual_df = raw_consumption_by_src_selected_df.resample('Y').sum() / 1000
|
| 289 |
+
raw_consumption_by_src_annual_df = aggregate_by_country(selected_country_name,raw_consumption_by_src_annual_df)
|
| 290 |
+
raw_consumption_by_src_annual_df.index = raw_consumption_by_src_annual_df.index.year
|
| 291 |
+
col1, col2 = st.columns(2)
|
| 292 |
+
with col1:
|
| 293 |
+
|
| 294 |
+
bar_consumption(raw_consumption_by_src_annual_df,title=f'Yearly consumption by source in {selected_country_name}')
|
| 295 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 296 |
+
|
| 297 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 298 |
+
with download_col:
|
| 299 |
+
download_data_as_csv(raw_consumption_by_src_annual_df, f"Yearly_consumption_by_source_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 300 |
+
|
| 301 |
+
# Use an expander to display the general description in info_col (right)
|
| 302 |
+
with info_col:
|
| 303 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 304 |
+
st.write(f"""
|
| 305 |
+
**Chart Description:**
|
| 306 |
+
This stacked bar chart represents the yearly electricity consumption by source in **{selected_country_name}** from 2016 to 2022, measured in gigawatt-hours (GWh).
|
| 307 |
+
Each bar is divided into segments that correspond to different energy sources contributing to the overall electricity consumption.
|
| 308 |
+
|
| 309 |
+
**Data Source:** EcoDynElec
|
| 310 |
+
""")
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
electricity_impact_by_src_annual_df = electricity_impact_by_src_selected_df.resample('Y').mean()
|
| 314 |
+
electricity_impact_by_src_annual_df = aggregate_by_country(selected_country_name,electricity_impact_by_src_annual_df)
|
| 315 |
+
electricity_impact_by_src_annual_df.index = electricity_impact_by_src_annual_df.index.year
|
| 316 |
+
|
| 317 |
+
with col2:
|
| 318 |
+
|
| 319 |
+
bar_ghg(electricity_impact_by_src_annual_df, f'Yearly average of GHG emissions in {selected_country_name} by source')
|
| 320 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 321 |
+
|
| 322 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 323 |
+
with download_col:
|
| 324 |
+
download_data_as_csv(electricity_impact_by_src_annual_df, f"Yearly_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}_by_source.csv")
|
| 325 |
+
|
| 326 |
+
# Use an expander to display the general description in info_col (right)
|
| 327 |
+
with info_col:
|
| 328 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 329 |
+
st.write(f"""
|
| 330 |
+
**Chart Description:**
|
| 331 |
+
This stacked bar chart illustrates the yearly average of greenhouse gas (GHG) emissions in **{selected_country_name}** by energy source, measured in grams
|
| 332 |
+
of CO2 equivalent per kilowatt-hour (gCO2eq/kWh), from 2016 to 2022.
|
| 333 |
+
Each bar is segmented to show the GHG emissions contribution from various energy sources used in **{selected_country_name}**'s electricity consumption.
|
| 334 |
+
|
| 335 |
+
**Data Source:** EcoDynElec
|
| 336 |
+
""")
|
| 337 |
+
|
| 338 |
+
if selection == "By Technology":
|
| 339 |
+
col1, col2 = st.columns(2)
|
| 340 |
+
|
| 341 |
+
techno_annual_df = techno_selected_df.resample('Y').sum() / 1000
|
| 342 |
+
techno_annual_df.index = techno_annual_df.index.year
|
| 343 |
+
col1, col2 = st.columns(2)
|
| 344 |
+
with col1:
|
| 345 |
+
#bar_consumption(techno_annual_df,title=f'Yearly consumption of {selected_technologie} in {selected_country_name}')
|
| 346 |
+
bar_group_consumption(techno_annual_df,
|
| 347 |
+
title=f'Yearly consumption by technology in {selected_country_name}',
|
| 348 |
+
text="GWh",
|
| 349 |
+
y_cols=techno_annual_df.columns,barmode='stack')
|
| 350 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 351 |
+
|
| 352 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 353 |
+
with download_col:
|
| 354 |
+
download_data_as_csv(techno_annual_df, f"Yearly_consumption_by_technology_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 355 |
+
|
| 356 |
+
# Use an expander to display the general description in info_col (right)
|
| 357 |
+
with info_col:
|
| 358 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 359 |
+
st.write(f"""
|
| 360 |
+
**Chart Description:**
|
| 361 |
+
This stacked bar chart represents the yearly electricity consumption by technology in **{selected_country_name}** from 2016 to 2022, measured in gigawatt-hours (GWh).
|
| 362 |
+
Each bar is divided into segments that correspond to the contributions of various energy technologies to the total electricity consumption.
|
| 363 |
+
|
| 364 |
+
**Data Source:** EcoDynElec
|
| 365 |
+
""")
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
|
| 369 |
+
techno_impact_annual_df=techno_impact_selected_df.resample('Y').mean()
|
| 370 |
+
techno_impact_annual_df.index = techno_impact_annual_df.index.year
|
| 371 |
+
|
| 372 |
+
with col2:
|
| 373 |
+
|
| 374 |
+
bar_group_consumption(techno_impact_annual_df,
|
| 375 |
+
title=f'Yearly average of GHG emissions by technology in {selected_country_name}',
|
| 376 |
+
text="gCO2eq/kWh",
|
| 377 |
+
y_cols=techno_impact_annual_df.columns, barmode='stack')
|
| 378 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 379 |
+
|
| 380 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 381 |
+
with download_col:
|
| 382 |
+
download_data_as_csv(techno_impact_annual_df, f"Yearly_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}_by_technology.csv")
|
| 383 |
+
|
| 384 |
+
# Use an expander to display the general description in info_col (right)
|
| 385 |
+
with info_col:
|
| 386 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 387 |
+
st.write(f"""
|
| 388 |
+
**Chart Description:**
|
| 389 |
+
This stacked bar chart represents the yearly average of greenhouse gas (GHG) emissions by technology in **{selected_country_name}** from 2016 to 2022, measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 390 |
+
Each bar is divided into segments representing the GHG emissions contributions from various energy technologies.
|
| 391 |
+
|
| 392 |
+
**Data Source:** EcoDynElec
|
| 393 |
+
""")
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
if selection == "Country of origin":
|
| 398 |
+
mix_import_annual = tot_electricity_mix_selected_df.drop(['sum'], axis=1)
|
| 399 |
+
mix_import_annual = mix_import_annual.multiply(tot_consumption_selected_df['sum'], axis='index').resample('Y').sum() / 1000
|
| 400 |
+
mix_import_annual.index = mix_import_annual.index.year
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
col1, col2 = st.columns(2)
|
| 405 |
+
with col1:
|
| 406 |
+
|
| 407 |
+
bar_group_consumption(mix_import_annual, title=f"Origins of yearly Swiss consumer mix in {selected_country_name}",
|
| 408 |
+
text="GWh",
|
| 409 |
+
y_cols=ordered_countries, barmode='stack')
|
| 410 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 411 |
+
|
| 412 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 413 |
+
with download_col:
|
| 414 |
+
download_data_as_csv(mix_import_annual, f"Origins_of_yearly_Swiss_consumer_mix_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 415 |
+
|
| 416 |
+
# Use an expander to display the general description in info_col (right)
|
| 417 |
+
with info_col:
|
| 418 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 419 |
+
st.write(f"""
|
| 420 |
+
**Chart Description:**
|
| 421 |
+
This stacked bar chart illustrates the origins of the yearly Swiss consumer electricity mix from 2016 to 2022, measured in gigawatt-hours (GWh).
|
| 422 |
+
Each bar is divided into segments representing the contributions of electricity sourced from **{selected_country_name}** and its neighboring countries.
|
| 423 |
+
|
| 424 |
+
**Data Source:** EcoDynElec
|
| 425 |
+
""")
|
| 426 |
+
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
mix_impact_annual = tot_electricity_impact_selected_df.drop(['sum'], axis=1).resample('Y').mean()
|
| 430 |
+
mix_impact_annual.index=mix_impact_annual.index.year
|
| 431 |
+
with col2:
|
| 432 |
+
|
| 433 |
+
bar_group_consumption(mix_impact_annual,title=f'Yearly average of GHG emissions in {selected_country_name} by country',
|
| 434 |
+
text="gCO2eq/kWh",y_cols=ordered_countries, barmode='stack')
|
| 435 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 436 |
+
|
| 437 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 438 |
+
with download_col:
|
| 439 |
+
download_data_as_csv(mix_impact_annual, f"Yearly_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}_by_country.csv")
|
| 440 |
+
|
| 441 |
+
# Use an expander to display the general description in info_col (right)
|
| 442 |
+
with info_col:
|
| 443 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 444 |
+
st.write(f"""
|
| 445 |
+
**Chart Description:**
|
| 446 |
+
This stacked bar chart represents the yearly average of greenhouse gas (GHG) emissions in **{selected_country_name}** by country from 2016 to 2022, measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 447 |
+
The stacked bars show the contributions of GHG emissions from domestic electricity production and imports from neighboring countries.
|
| 448 |
+
|
| 449 |
+
**Data Source:** EcoDynElec
|
| 450 |
+
""")
|
| 451 |
+
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
elif resolution == 'Monthly':
|
| 456 |
+
|
| 457 |
+
with col3:
|
| 458 |
+
# Utilisation d'un slider pour choisir une année
|
| 459 |
+
selected_year = st.slider('Choose a year:', min_value=min(years), max_value=max(years), value=min(years))
|
| 460 |
+
|
| 461 |
+
#flows
|
| 462 |
+
flows_selected_df['exports'] = -flows_selected_df['exports']
|
| 463 |
+
flows_monthly_df = flows_selected_df[(flows_selected_df.index.year == selected_year)]
|
| 464 |
+
flows_monthly_df = flows_monthly_df.resample('M').sum() / 1000
|
| 465 |
+
flows_monthly_df.index = flows_monthly_df.index.month.map(lambda x: month_dict[x])
|
| 466 |
+
#tot_consumption
|
| 467 |
+
tot_consumption_monthly_df = tot_consumption_selected_df[(tot_consumption_selected_df.index.year == selected_year)]
|
| 468 |
+
tot_consumption_monthly_df = tot_consumption_monthly_df['sum'].resample('M').sum() / 1000
|
| 469 |
+
|
| 470 |
+
col1, col2 = st.columns(2)
|
| 471 |
+
with col1:
|
| 472 |
+
|
| 473 |
+
bar_group_consumption(flows_monthly_df, title=f'Monthly Time Series of Production, Imports, and Exports in {selected_country_name} in {selected_year} ',
|
| 474 |
+
text="GWh",
|
| 475 |
+
y_cols=['total_consumption', 'production', 'imports', 'exports'], barmode='group')
|
| 476 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 477 |
+
|
| 478 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 479 |
+
with download_col:
|
| 480 |
+
download_data_as_csv(flows_monthly_df, f"Monthly_Time_Series_of_Production_Imports_and_Exports_in_{selected_country_name.replace(' ', '_')}_in_{selected_year}.csv")
|
| 481 |
+
|
| 482 |
+
# Use an expander to display the general description in info_col (right)
|
| 483 |
+
with info_col:
|
| 484 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 485 |
+
st.write(f"""
|
| 486 |
+
**Chart Description:**
|
| 487 |
+
This bar chart represents the monthly time series of production, imports, exports, and total electricity consumption in **{selected_country_name}**,
|
| 488 |
+
measured in gigawatt-hours (GWh), over a period from 2016 to 2022.
|
| 489 |
+
|
| 490 |
+
**Data Source:** EcoDynElec
|
| 491 |
+
""")
|
| 492 |
+
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
# pour les impacts
|
| 497 |
+
tot_electricity_impact_monthly_df=tot_electricity_impact_selected_df[(tot_electricity_impact_selected_df.index.year == selected_year)]
|
| 498 |
+
monthly_consumer_impact = tot_electricity_impact_monthly_df['sum'].resample('M').mean()
|
| 499 |
+
monthly_consumer_impact.index = monthly_consumer_impact.index.month.map(lambda x: month_dict[x])
|
| 500 |
+
with col2:
|
| 501 |
+
|
| 502 |
+
bar_group_ghg(monthly_consumer_impact, f'Monthly average of GHG emissions in {selected_country_name} in {selected_year} ')
|
| 503 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 504 |
+
|
| 505 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 506 |
+
with download_col:
|
| 507 |
+
download_data_as_csv(monthly_consumer_impact, f"Monthly_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}_in_{selected_year}.csv")
|
| 508 |
+
|
| 509 |
+
# Use an expander to display the general description in info_col (right)
|
| 510 |
+
with info_col:
|
| 511 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 512 |
+
st.write(f"""
|
| 513 |
+
**Chart Description:**
|
| 514 |
+
This bar chart represents the monthly average of greenhouse gas (GHG) emissions in **{selected_country_name}**,
|
| 515 |
+
measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh), from 2016 to 2022.
|
| 516 |
+
|
| 517 |
+
**Data Source:** EcoDynElec
|
| 518 |
+
""")
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
selection = aggregation_menu()
|
| 522 |
+
if selection == "Mixed":
|
| 523 |
+
|
| 524 |
+
raw_consumption_by_src_monthly_df = process_data_by_month(raw_consumption_by_src_selected_df, selected_year, selected_country_name, month_dict,
|
| 525 |
+
aggregate_by_country)
|
| 526 |
+
|
| 527 |
+
electricity_impact_by_src_monthly_df = process_ghg_data_by_month(electricity_impact_by_src_selected_df, selected_year, selected_country_name, month_dict,
|
| 528 |
+
aggregate_by_country)
|
| 529 |
+
|
| 530 |
+
col1, col2 = st.columns(2)
|
| 531 |
+
with col1:
|
| 532 |
+
bar_consumption(raw_consumption_by_src_monthly_df,title=f'Monthly consumption by source in {selected_country_name} in {selected_year}')
|
| 533 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 534 |
+
|
| 535 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 536 |
+
with download_col:
|
| 537 |
+
download_data_as_csv(raw_consumption_by_src_monthly_df, f"Monthly_consumption_by_source_in_{selected_country_name.replace(' ', '_')}_in_{selected_year}.csv")
|
| 538 |
+
|
| 539 |
+
# Use an expander to display the general description in info_col (right)
|
| 540 |
+
with info_col:
|
| 541 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 542 |
+
st.write(f"""
|
| 543 |
+
**Chart Description:**
|
| 544 |
+
This stacked bar chart represents the monthly electricity consumption by source in **{selected_country_name}** from 2016 to 2022, measured in gigawatt-hours (GWh).
|
| 545 |
+
Each bar is divided into segments that correspond to different energy sources contributing to the overall electricity consumption.
|
| 546 |
+
|
| 547 |
+
**Data Source:** EcoDynElec
|
| 548 |
+
""")
|
| 549 |
+
|
| 550 |
+
with col2:
|
| 551 |
+
bar_ghg(electricity_impact_by_src_monthly_df,f'Monthly average of GHG emissions in {selected_country_name} in {selected_year} by source')
|
| 552 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 553 |
+
|
| 554 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 555 |
+
with download_col:
|
| 556 |
+
download_data_as_csv(electricity_impact_by_src_monthly_df, f"Monthly_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}_in_{selected_year}_by_source.csv")
|
| 557 |
+
|
| 558 |
+
# Use an expander to display the general description in info_col (right)
|
| 559 |
+
with info_col:
|
| 560 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 561 |
+
st.write(f"""
|
| 562 |
+
**Chart Description:**
|
| 563 |
+
This stacked bar chart illustrates the monthly average of greenhouse gas (GHG) emissions in **{selected_country_name}** by energy source, measured in grams
|
| 564 |
+
of CO2 equivalent per kilowatt-hour (gCO2eq/kWh), from 2016 to 2022.
|
| 565 |
+
Each bar is segmented to show the GHG emissions contribution from various energy sources used in **{selected_country_name}**'s electricity consumption.
|
| 566 |
+
|
| 567 |
+
**Data Source:** EcoDynElec
|
| 568 |
+
""")
|
| 569 |
+
|
| 570 |
+
if selection == "By Technology":
|
| 571 |
+
|
| 572 |
+
techno_monthly_df = techno_selected_df.loc[techno_selected_df.index.year == selected_year]
|
| 573 |
+
techno_monthly_df = techno_monthly_df.resample('M').sum() / 1000
|
| 574 |
+
techno_monthly_df.index = techno_monthly_df.index.month.map(lambda x: month_dict[x])
|
| 575 |
+
col1, col2 = st.columns(2)
|
| 576 |
+
with col1:
|
| 577 |
+
bar_consumption(techno_monthly_df,title=f'Monthly consumption by technology in {selected_country_name} in {selected_year}')
|
| 578 |
+
|
| 579 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 580 |
+
|
| 581 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 582 |
+
with download_col:
|
| 583 |
+
download_data_as_csv(techno_monthly_df, f"Monthly_consumption_by_technology_in_{selected_country_name.replace(' ', '_')}_in_{selected_year}.csv")
|
| 584 |
+
|
| 585 |
+
# Use an expander to display the general description in info_col (right)
|
| 586 |
+
with info_col:
|
| 587 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 588 |
+
st.write(f"""
|
| 589 |
+
**Chart Description:**
|
| 590 |
+
This stacked bar chart represents the monthly electricity consumption by technology in **{selected_country_name}** from 2016 to 2022, measured in gigawatt-hours (GWh).
|
| 591 |
+
Each bar is divided into segments that correspond to the contributions of various energy technologies to the total electricity consumption.
|
| 592 |
+
|
| 593 |
+
**Data Source:** EcoDynElec
|
| 594 |
+
""")
|
| 595 |
+
|
| 596 |
+
techno_impact_monthly_df = techno_impact_selected_df.loc[techno_impact_selected_df.index.year == selected_year]
|
| 597 |
+
techno_impact_monthly_df = techno_impact_monthly_df.resample('M').mean()
|
| 598 |
+
techno_impact_monthly_df.index = techno_impact_monthly_df.index.month.map(lambda x: month_dict[x])
|
| 599 |
+
|
| 600 |
+
with col2:
|
| 601 |
+
bar_ghg(techno_impact_monthly_df,f'Monthly average of GHG emissions by technology in {selected_country_name} in {selected_year}')
|
| 602 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 603 |
+
|
| 604 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 605 |
+
with download_col:
|
| 606 |
+
download_data_as_csv(techno_impact_monthly_df, f"Monthly_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}_in_{selected_year}_by_technology.csv")
|
| 607 |
+
|
| 608 |
+
# Use an expander to display the general description in info_col (right)
|
| 609 |
+
with info_col:
|
| 610 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 611 |
+
st.write(f"""
|
| 612 |
+
**Chart Description:**
|
| 613 |
+
This stacked bar chart represents the monthly average of greenhouse gas (GHG) emissions by technology in **{selected_country_name}** from 2016 to 2022, measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 614 |
+
Each bar is divided into segments representing the GHG emissions contributions from various energy technologies.
|
| 615 |
+
|
| 616 |
+
**Data Source:** EcoDynElec
|
| 617 |
+
""")
|
| 618 |
+
|
| 619 |
+
|
| 620 |
+
|
| 621 |
+
|
| 622 |
+
if selection == "Country of origin":
|
| 623 |
+
tot_electricity_mix_monthly_df = tot_electricity_mix_selected_df[(tot_electricity_mix_selected_df.index.year == selected_year)]
|
| 624 |
+
monthly_mix_import = tot_electricity_mix_monthly_df.drop(['sum'], axis=1)
|
| 625 |
+
monthly_mix_import = monthly_mix_import.multiply(tot_consumption_monthly_df, axis='index').resample('M').sum() / 1000
|
| 626 |
+
monthly_mix_import.index = monthly_mix_import.index.month.map(lambda x: month_dict[x])
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
col1, col2 = st.columns(2)
|
| 630 |
+
with col1:
|
| 631 |
+
bar_group_consumption(monthly_mix_import,
|
| 632 |
+
title=f"Origins of monthly consumer mix by country in {selected_country_name} in {selected_year}",
|
| 633 |
+
text="GWh",
|
| 634 |
+
y_cols=ordered_countries, barmode='stack')
|
| 635 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 636 |
+
|
| 637 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 638 |
+
with download_col:
|
| 639 |
+
download_data_as_csv(monthly_mix_import, f"Monthly_consumption_by_country_in_{selected_country_name.replace(' ', '_')}_in_{selected_year}.csv")
|
| 640 |
+
|
| 641 |
+
# Use an expander to display the general description in info_col (right)
|
| 642 |
+
with info_col:
|
| 643 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 644 |
+
st.write(f"""
|
| 645 |
+
**Chart Description:**
|
| 646 |
+
This stacked bar chart illustrates the origins of the monthly Swiss consumer electricity mix from 2016 to 2022, measured in gigawatt-hours (GWh).
|
| 647 |
+
Each bar is divided into segments representing the contributions of electricity sourced from **{selected_country_name}** and its neighboring countries.
|
| 648 |
+
|
| 649 |
+
**Data Source:** EcoDynElec
|
| 650 |
+
""")
|
| 651 |
+
|
| 652 |
+
|
| 653 |
+
tot_electricity_impact_monthly_df = tot_electricity_impact_selected_df[(tot_electricity_impact_selected_df.index.year == selected_year)]
|
| 654 |
+
monthly_mix_impact = tot_electricity_impact_monthly_df.drop(['sum'], axis=1).resample('M').mean()
|
| 655 |
+
monthly_mix_impact.index = monthly_mix_impact.index.month.map(lambda x: month_dict[x])
|
| 656 |
+
with col2:
|
| 657 |
+
|
| 658 |
+
bar_group_consumption(monthly_mix_impact,
|
| 659 |
+
title=f'Monthly average of GHG emissions by country in {selected_country_name} in {selected_year}',
|
| 660 |
+
text="gCO2eq/kWh",
|
| 661 |
+
y_cols=ordered_countries, barmode='stack')
|
| 662 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 663 |
+
|
| 664 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 665 |
+
with download_col:
|
| 666 |
+
download_data_as_csv(monthly_mix_impact, f"Monthly_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}_in_{selected_year}_by_country.csv")
|
| 667 |
+
|
| 668 |
+
# Use an expander to display the general description in info_col (right)
|
| 669 |
+
with info_col:
|
| 670 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 671 |
+
st.write(f"""
|
| 672 |
+
**Chart Description:**
|
| 673 |
+
This stacked bar chart represents the monthly average of greenhouse gas (GHG) emissions in **{selected_country_name}** by country from 2016 to 2022, measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 674 |
+
The stacked bars show the contributions of GHG emissions from domestic electricity production and imports from neighboring countries.
|
| 675 |
+
|
| 676 |
+
**Data Source:** EcoDynElec
|
| 677 |
+
""")
|
| 678 |
+
|
| 679 |
+
|
| 680 |
+
|
| 681 |
+
elif resolution == 'Daily':
|
| 682 |
+
|
| 683 |
+
# Supposons que flows_selected_df est déjà défini et correctement configuré
|
| 684 |
+
min_date = flows_selected_df.index.min()
|
| 685 |
+
max_date = flows_selected_df.index.max()
|
| 686 |
+
|
| 687 |
+
# Positionnement des widgets dans les colonnes si déjà définies
|
| 688 |
+
with col3: # Exemple de placement dans la colonne
|
| 689 |
+
start_date, end_date = st.date_input(
|
| 690 |
+
"Select a date range:",
|
| 691 |
+
[min_date, max_date], # Utilisez les extrêmes de l'index comme valeur par défaut
|
| 692 |
+
min_value=min_date, # Date minimale extraite de l'index
|
| 693 |
+
max_value=max_date, # Date maximale extraite de l'index
|
| 694 |
+
help="You can select a range within the available dates in the data."
|
| 695 |
+
)
|
| 696 |
+
# Ajustez end_date pour inclure toute la journée
|
| 697 |
+
start_date = pd.Timestamp(start_date)
|
| 698 |
+
end_date = pd.Timestamp(end_date) + pd.Timedelta(days=1, seconds=-1)
|
| 699 |
+
|
| 700 |
+
|
| 701 |
+
|
| 702 |
+
|
| 703 |
+
|
| 704 |
+
# Filtrer le DataFrame selon la plage sélectionnée
|
| 705 |
+
flows_daily= flows_selected_df.loc[(flows_selected_df.index >= start_date) & (flows_selected_df.index <= end_date)].resample('D').sum() / 1000
|
| 706 |
+
tot_consumption_daily= tot_consumption_selected_df.loc[(tot_consumption_selected_df.index >= start_date) & (tot_consumption_selected_df.index <= end_date)].resample('D').sum()
|
| 707 |
+
tot_consumption_daily=tot_consumption_daily['sum'].resample('D').sum() / 1000
|
| 708 |
+
col1, col2 = st.columns(2)
|
| 709 |
+
with col1:
|
| 710 |
+
create_combined_time_series(flows_daily, tot_consumption_daily, title=f'Daily Time Series of Production, Imports, and Exports in {selected_country_name} ')
|
| 711 |
+
# Ajouter des colonnes pour les boutons à l'intérieur de col1
|
| 712 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 713 |
+
|
| 714 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 715 |
+
with download_col:
|
| 716 |
+
download_data_as_csv(flows_daily,
|
| 717 |
+
f"Daily_Time_Series_of_Production_Imports_and_Exports_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 718 |
+
|
| 719 |
+
# Use an expander to display the general description in info_col (right)
|
| 720 |
+
with info_col:
|
| 721 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 722 |
+
st.write(f"""
|
| 723 |
+
**Chart Description:**
|
| 724 |
+
This chart presents the daily evolution of energy flows in **{selected_country_name}**,
|
| 725 |
+
including production, imports, exports, and total electricity consumption.
|
| 726 |
+
|
| 727 |
+
**Data Source:** EcoDynElec
|
| 728 |
+
""")
|
| 729 |
+
|
| 730 |
+
|
| 731 |
+
|
| 732 |
+
|
| 733 |
+
|
| 734 |
+
# for impacts
|
| 735 |
+
tot_electricity_impact_daily_df = tot_electricity_impact_selected_df.loc[
|
| 736 |
+
(tot_electricity_impact_selected_df.index >= start_date) &
|
| 737 |
+
(tot_electricity_impact_selected_df.index <= end_date)
|
| 738 |
+
]
|
| 739 |
+
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
|
| 743 |
+
|
| 744 |
+
# disp the chart based on user's choice
|
| 745 |
+
with col2:
|
| 746 |
+
|
| 747 |
+
# Create a line plot (assuming you want to use Plotly)
|
| 748 |
+
fig = px.line(tot_electricity_impact_daily_df.resample('D').mean(),
|
| 749 |
+
x=tot_electricity_impact_daily_df.resample('D').mean().index, y='sum',
|
| 750 |
+
title=f'Line Plot of GHG Emissions in {selected_country_name}')
|
| 751 |
+
fig.update_layout(legend_title_text='')
|
| 752 |
+
|
| 753 |
+
fig.update_traces(hovertemplate='%{y:.0f} gCO2eq/KWh<br>Date: %{x|%a %d %b %Y}<extra></extra>')
|
| 754 |
+
fig.add_annotation(text="© Ecodynelec-HEIG-VD", xref="paper", yref="paper", x=0, y=-0.2,
|
| 755 |
+
showarrow=False, font=dict(size=12, color="gray"), xanchor='left', yanchor='bottom')
|
| 756 |
+
# Add annotation for unit
|
| 757 |
+
fig.add_annotation(text="gCO2eq/KWh", xref="paper", yref="paper", x=-0.05, y=1.1, showarrow=False,
|
| 758 |
+
font=dict(size=12))
|
| 759 |
+
fig.update_xaxes(title_text='', tickformat='%a %d %b %y')
|
| 760 |
+
fig.update_yaxes(title_text='')
|
| 761 |
+
st.plotly_chart(fig)
|
| 762 |
+
|
| 763 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 764 |
+
with download_col:
|
| 765 |
+
download_data_as_csv(tot_electricity_impact_daily_df, f"Daily_Line_Plot_of_GHG_Emissions_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 766 |
+
with info_col:
|
| 767 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 768 |
+
st.write(f"""
|
| 769 |
+
**Chart's Description:**
|
| 770 |
+
This line plot visualizes the temporal evolution of greenhouse gas (GHG) emissions in **{selected_country_name}**,
|
| 771 |
+
measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 772 |
+
The x-axis represents the time series data over several days, while the y-axis indicates the magnitude of GHG emissions
|
| 773 |
+
|
| 774 |
+
**Data Source:** EcoDynElec
|
| 775 |
+
""")
|
| 776 |
+
|
| 777 |
+
|
| 778 |
+
|
| 779 |
+
|
| 780 |
+
|
| 781 |
+
|
| 782 |
+
selection = aggregation_menu()
|
| 783 |
+
if selection == "Mixed":
|
| 784 |
+
raw_consumption_by_src_daily_df = raw_consumption_by_src_selected_df.loc[(raw_consumption_by_src_selected_df.index >= start_date) & (
|
| 785 |
+
raw_consumption_by_src_selected_df.index <= end_date)].resample('D').sum()
|
| 786 |
+
raw_consumption_by_src_daily_df = raw_consumption_by_src_daily_df.resample('D').sum() / 1000
|
| 787 |
+
raw_consumption_by_src_daily_df = aggregate_by_country(selected_country_name,
|
| 788 |
+
raw_consumption_by_src_daily_df)
|
| 789 |
+
col1, col2 = st.columns(2)
|
| 790 |
+
with col1:
|
| 791 |
+
create_area_mixte(raw_consumption_by_src_daily_df,
|
| 792 |
+
title=f'Daily consumption by source in {selected_country_name}',text='GWh')
|
| 793 |
+
|
| 794 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 795 |
+
with download_col:
|
| 796 |
+
download_data_as_csv(raw_consumption_by_src_daily_df, f"Daily_consumption_by_source_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 797 |
+
with info_col:
|
| 798 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 799 |
+
st.write(f"""
|
| 800 |
+
**Chart Description:**
|
| 801 |
+
|
| 802 |
+
This stacked area chart illustrates the daily electricity consumption by energy source in **{selected_country_name}** over the selected time period.
|
| 803 |
+
Each area in the plot corresponds to a different energy source contributing to the total electricity consumption.
|
| 804 |
+
|
| 805 |
+
**Data Source:** EcoDynElec
|
| 806 |
+
""")
|
| 807 |
+
|
| 808 |
+
|
| 809 |
+
electricity_impact_by_src_daily_df = electricity_impact_by_src_selected_df.loc[(electricity_impact_by_src_selected_df.index >= start_date) & (
|
| 810 |
+
electricity_impact_by_src_selected_df.index <= end_date)]
|
| 811 |
+
electricity_impact_by_src_daily_df = electricity_impact_by_src_daily_df.resample('D').mean()
|
| 812 |
+
electricity_impact_by_src_daily_df = aggregate_by_country(selected_country_name,
|
| 813 |
+
electricity_impact_by_src_daily_df)
|
| 814 |
+
with col2:
|
| 815 |
+
create_area_mixte(electricity_impact_by_src_daily_df,title=f'Daily average of GHG emissions by source in {selected_country_name}',text='gCO2/KWh')
|
| 816 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 817 |
+
with download_col:
|
| 818 |
+
download_data_as_csv(electricity_impact_by_src_daily_df, f"Daily_average_of_GHG_emissions_by_source_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 819 |
+
with info_col:
|
| 820 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 821 |
+
st.write(f"""
|
| 822 |
+
**Chart Description:**
|
| 823 |
+
This stacked area chart visualizes the daily average of greenhouse gas (GHG) emissions by energy source in **{selected_country_name}** over the selected period.
|
| 824 |
+
Each color band represents the contribution of a different energy source to the total GHG emissions,
|
| 825 |
+
measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh)
|
| 826 |
+
|
| 827 |
+
**Data Source:** EcoDynElec
|
| 828 |
+
""")
|
| 829 |
+
|
| 830 |
+
if selection == "By Technology":
|
| 831 |
+
|
| 832 |
+
col1, col2 = st.columns(2) # Crée deux colonnes pour les graphiques
|
| 833 |
+
with col1:
|
| 834 |
+
techno_daily_df=(techno_selected_df.loc[(techno_selected_df.index >= start_date) & (techno_selected_df.index <= end_date)]
|
| 835 |
+
.resample('D').sum()) / 1000
|
| 836 |
+
#create_time_series(techno_daily_df,title=f'Daily average of GHG emissions by source in {selected_country_name}')
|
| 837 |
+
create_area_mixte(techno_daily_df,
|
| 838 |
+
title=f'Daily consumption by technology in {selected_country_name}',text='GWh')
|
| 839 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 840 |
+
with download_col:
|
| 841 |
+
download_data_as_csv(techno_daily_df, f"Daily_consumption_by_technology_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 842 |
+
with info_col:
|
| 843 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 844 |
+
st.write(f"""
|
| 845 |
+
**Chart Description:**
|
| 846 |
+
|
| 847 |
+
This stacked area chart illustrates the daily electricity consumption by technology in **{selected_country_name}** over the selected time period.
|
| 848 |
+
Each area in the plot corresponds to a different energy source contributing to the total electricity consumption.
|
| 849 |
+
|
| 850 |
+
**Data Source:** EcoDynElec
|
| 851 |
+
""")
|
| 852 |
+
|
| 853 |
+
|
| 854 |
+
techno_impact_daily_df = techno_impact_selected_df.loc[(techno_impact_selected_df.index >= start_date) &
|
| 855 |
+
(techno_impact_selected_df.index <= end_date)].resample('D').mean()
|
| 856 |
+
|
| 857 |
+
|
| 858 |
+
|
| 859 |
+
with col2:
|
| 860 |
+
create_area_mixte(techno_impact_daily_df,
|
| 861 |
+
title=f'Daily average of GHG emissions by technology in {selected_country_name}', text='gCO2eq/KWh')
|
| 862 |
+
|
| 863 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 864 |
+
with download_col:
|
| 865 |
+
download_data_as_csv(techno_impact_daily_df, f"Daily_average_of_GHG_emissions_by_technology_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 866 |
+
with info_col:
|
| 867 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 868 |
+
st.write(f"""
|
| 869 |
+
**Chart Description:**
|
| 870 |
+
This stacked area chart visualizes the daily average of greenhouse gas (GHG) emissions by technology in **{selected_country_name}** over the selected period.
|
| 871 |
+
Each color band represents the contribution of a different energy source to the total GHG emissions,
|
| 872 |
+
measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh)
|
| 873 |
+
|
| 874 |
+
|
| 875 |
+
|
| 876 |
+
**Data Source:** EcoDynElec
|
| 877 |
+
""")
|
| 878 |
+
|
| 879 |
+
|
| 880 |
+
|
| 881 |
+
|
| 882 |
+
if selection == "Country of origin":
|
| 883 |
+
tot_electricity_mix_daily_df = tot_electricity_mix_selected_df.loc[
|
| 884 |
+
(tot_electricity_mix_selected_df.index >= start_date) & (tot_electricity_mix_selected_df.index <= end_date)].resample('D').sum()
|
| 885 |
+
daily_mix_import = tot_electricity_mix_daily_df.drop(['sum'], axis=1)
|
| 886 |
+
daily_mix_import = daily_mix_import.multiply(tot_consumption_daily, axis='index').resample('D').sum() / 1000
|
| 887 |
+
|
| 888 |
+
|
| 889 |
+
col1, col2 = st.columns(2)
|
| 890 |
+
with col1:
|
| 891 |
+
create_area_chart(daily_mix_import,title=f"Origins of daily consumer mix by country in {selected_country_name}")
|
| 892 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 893 |
+
with download_col:
|
| 894 |
+
download_data_as_csv(daily_mix_import, f"Daily_consumption_by_country_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 895 |
+
with info_col:
|
| 896 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 897 |
+
st.write(f"""
|
| 898 |
+
**Chart Description:**
|
| 899 |
+
|
| 900 |
+
This stacked area chart displays the origins of the daily consumer electricity mix by country in Switzerland over the selected time period.
|
| 901 |
+
Each color band represents the contribution of electricity imports from different countries to the total electricity mix consumed in **{selected_country_name}**.
|
| 902 |
+
|
| 903 |
+
**Data Source:** EcoDynElec
|
| 904 |
+
""")
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
tot_electricity_impact_daily_df = tot_electricity_impact_selected_df[(tot_electricity_impact_selected_df.index >= start_date) &
|
| 908 |
+
(tot_electricity_impact_selected_df.index <= end_date)]
|
| 909 |
+
|
| 910 |
+
daily_mix_impact = tot_electricity_impact_daily_df.drop(['sum'], axis=1).resample('D').mean()
|
| 911 |
+
with col2:
|
| 912 |
+
create_area_chart(daily_mix_impact, title=f'Daily average of GHG emissions by country (gCO2eq/kWh) in {selected_country_name}', unit="gCO2eq/kWh")
|
| 913 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 914 |
+
with download_col:
|
| 915 |
+
|
| 916 |
+
download_data_as_csv(daily_mix_impact, f"Daily_average_of_GHG_emissions_by_country_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 917 |
+
with info_col:
|
| 918 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 919 |
+
st.write(f"""
|
| 920 |
+
**Chart Description:**
|
| 921 |
+
|
| 922 |
+
This stacked area chart shows the daily average of greenhouse gas (GHG) emissions by country in **{selected_country_name}**, measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 923 |
+
Each color band represents the GHG emissions associated with electricity produced or imported from different countries.
|
| 924 |
+
|
| 925 |
+
**Data Source:** EcoDynElec
|
| 926 |
+
""")
|
| 927 |
+
|
| 928 |
+
elif resolution == 'Hourly':
|
| 929 |
+
|
| 930 |
+
# Supposons que flows_selected_df est déjà défini et correctement configuré
|
| 931 |
+
min_date = flows_selected_df.index.min()
|
| 932 |
+
max_date = flows_selected_df.index.max()
|
| 933 |
+
|
| 934 |
+
# Positionnement des widgets dans les colonnes si déjà définies
|
| 935 |
+
with col3: # Exemple de placement dans la colonne
|
| 936 |
+
start_date, end_date = st.date_input(
|
| 937 |
+
"Select a date range:",
|
| 938 |
+
[min_date, max_date], # Utilisez les extrêmes de l'index comme valeur par défaut
|
| 939 |
+
min_value=min_date, # Date minimale extraite de l'index
|
| 940 |
+
max_value=max_date, # Date maximale extraite de l'index
|
| 941 |
+
help="You can select a range within the available dates in the data."
|
| 942 |
+
)
|
| 943 |
+
# Ajustez end_date pour inclure toute la journée
|
| 944 |
+
start_date = pd.Timestamp(start_date)
|
| 945 |
+
end_date = pd.Timestamp(end_date) + pd.Timedelta(days=1, seconds=-1)
|
| 946 |
+
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
# Filtrer le DataFrame selon la plage sélectionnée
|
| 950 |
+
flows_hourly = flows_selected_df.loc[(flows_selected_df.index >= start_date) & (flows_selected_df.index <= end_date)]/ 1000
|
| 951 |
+
tot_consumption_hourly = tot_consumption_selected_df.loc[
|
| 952 |
+
(tot_consumption_selected_df.index >= start_date) & (tot_consumption_selected_df.index <= end_date)]
|
| 953 |
+
tot_consumption_hourly=tot_consumption_hourly['sum'] / 1000
|
| 954 |
+
col1,col2= st.columns(2)
|
| 955 |
+
with col1:
|
| 956 |
+
create_combined_time_series(flows_hourly, tot_consumption_hourly, title=f'Hourly Time Series of Production, Imports, and Exports in {selected_country_name}',resolution='hourly')
|
| 957 |
+
download_col, info_col = st.columns([0.7, 0.3]) # Adjust the ratios as needed
|
| 958 |
+
|
| 959 |
+
# Bouton pour télécharger le CSV dans download_col (gauche)
|
| 960 |
+
with download_col:
|
| 961 |
+
download_data_as_csv(flows_hourly, f"Hourly_Time_Series_of_Production_Imports_and_Exports_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 962 |
+
|
| 963 |
+
# Use an expander to display the general description in info_col (right)
|
| 964 |
+
with info_col:
|
| 965 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 966 |
+
st.write(f"""
|
| 967 |
+
**Chart Description:**
|
| 968 |
+
This chart presents the hourly evolution of energy flows in **{selected_country_name}**,
|
| 969 |
+
including production, imports, exports, and total electricity consumption.
|
| 970 |
+
|
| 971 |
+
**Data Source:** EcoDynElec
|
| 972 |
+
""")
|
| 973 |
+
|
| 974 |
+
|
| 975 |
+
|
| 976 |
+
# pour les impacts
|
| 977 |
+
tot_electricity_impact_hourly_df = tot_electricity_impact_selected_df.loc[(tot_electricity_impact_selected_df.index >= start_date) & (
|
| 978 |
+
tot_electricity_impact_selected_df.index <= end_date)]
|
| 979 |
+
|
| 980 |
+
|
| 981 |
+
pivot_table = create_pivot_table(tot_electricity_impact_hourly_df['sum'].resample('H').mean())
|
| 982 |
+
|
| 983 |
+
|
| 984 |
+
# Display the chart based on user's choice
|
| 985 |
+
with col4:
|
| 986 |
+
# Add a selectbox to allow the user to choose between heatmap and line plot
|
| 987 |
+
chart_type = st.selectbox("Choose chart type:", ["Heatmap", "Line Plot"])
|
| 988 |
+
with col2:
|
| 989 |
+
if chart_type == "Line Plot":
|
| 990 |
+
# Create a line plot (assuming you want to use Plotly)
|
| 991 |
+
fig = px.line(tot_electricity_impact_hourly_df.resample('H').mean(),
|
| 992 |
+
x=tot_electricity_impact_hourly_df.index, y='sum',
|
| 993 |
+
title=f'Line Plot of GHG Emissions in {selected_country_name}')
|
| 994 |
+
fig.update_layout(legend_title_text='')
|
| 995 |
+
fig.update_traces(hovertemplate='%{y:.0f} gCO2eq/KWh<br>Date: %{x| %a %d %b %Y %H %M}<extra></extra>')
|
| 996 |
+
fig.update_xaxes(title_text='', tickformat=' %a %d %b %y %H %M')
|
| 997 |
+
fig.update_yaxes(title_text='')
|
| 998 |
+
fig.add_annotation(text="© Ecodynelec-HEIG-VD", xref="paper", yref="paper", x=0, y=-0.5,
|
| 999 |
+
showarrow=False, font=dict(size=12, color="gray"), xanchor='left', yanchor='bottom')
|
| 1000 |
+
fig.add_annotation(text="gCO2eq/KWh", xref="paper", yref="paper", x=-0.05, y=1.1, showarrow=False,
|
| 1001 |
+
font=dict(size=12))
|
| 1002 |
+
st.plotly_chart(fig)
|
| 1003 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 1004 |
+
with download_col:
|
| 1005 |
+
download_data_as_csv(tot_electricity_impact_hourly_df, f"Hourly_Line_Plot_of_GHG_Emissions_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 1006 |
+
with info_col:
|
| 1007 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 1008 |
+
st.write(f"""
|
| 1009 |
+
**Chart's Description:**
|
| 1010 |
+
This line plot visualizes the temporal evolution of greenhouse gas (GHG) emissions in **{selected_country_name}**,
|
| 1011 |
+
measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 1012 |
+
The x-axis represents the time series data over time (hourly), while the y-axis indicates the magnitude of GHG emissions
|
| 1013 |
+
|
| 1014 |
+
**Data Source:** EcoDynElec
|
| 1015 |
+
""")
|
| 1016 |
+
|
| 1017 |
+
elif chart_type == "Heatmap":
|
| 1018 |
+
create_heatmap(pivot_table, f'Heatmap of the average of GHG emissions in {selected_country_name}')
|
| 1019 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 1020 |
+
with download_col:
|
| 1021 |
+
download_data_as_csv(pivot_table, f"Heatmap_of_the_average_of_GHG_emissions_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 1022 |
+
with info_col:
|
| 1023 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 1024 |
+
st.write(f"""
|
| 1025 |
+
**Chart Description:**
|
| 1026 |
+
This heatmap displays the average greenhouse gas (GHG) emissions in **{selected_country_name}** over time.
|
| 1027 |
+
The horizontal axis represents the dates, while the vertical axis represents the hours of the day.
|
| 1028 |
+
Each colored cell in the heatmap corresponds to the intensity of GHG emissions, measured in grams of
|
| 1029 |
+
CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 1030 |
+
|
| 1031 |
+
**Data Source:** EcoDynElec
|
| 1032 |
+
""")
|
| 1033 |
+
|
| 1034 |
+
selection = aggregation_menu()
|
| 1035 |
+
if selection == "Mixed":
|
| 1036 |
+
raw_consumption_by_src_hourly_df = raw_consumption_by_src_selected_df.loc[(raw_consumption_by_src_selected_df.index >= start_date) & (
|
| 1037 |
+
raw_consumption_by_src_selected_df.index <= end_date)].resample('H').sum()
|
| 1038 |
+
raw_consumption_by_src_hourly_df = raw_consumption_by_src_hourly_df.resample('H').sum() / 1000
|
| 1039 |
+
raw_consumption_by_src_hourly_df = aggregate_by_country(selected_country_name,raw_consumption_by_src_hourly_df)
|
| 1040 |
+
col1, col2 = st.columns(2)
|
| 1041 |
+
with col1:
|
| 1042 |
+
create_area_mixte(raw_consumption_by_src_hourly_df,
|
| 1043 |
+
title=f'Hourly consumption by source in {selected_country_name}',text='GWh',resolution='hourly')
|
| 1044 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 1045 |
+
with download_col:
|
| 1046 |
+
download_data_as_csv(raw_consumption_by_src_hourly_df, f"Hourly_consumption_by_source_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 1047 |
+
with info_col:
|
| 1048 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 1049 |
+
st.write(f"""
|
| 1050 |
+
**Chart Description:**
|
| 1051 |
+
|
| 1052 |
+
This stacked area chart illustrates the hourly electricity consumption by energy source in **{selected_country_name}** over the selected time period.
|
| 1053 |
+
Each area in the plot corresponds to a different energy source contributing to the total electricity consumption.
|
| 1054 |
+
|
| 1055 |
+
**Data Source:** EcoDynElec
|
| 1056 |
+
""")
|
| 1057 |
+
|
| 1058 |
+
|
| 1059 |
+
electricity_impact_by_src_hourly_df = electricity_impact_by_src_selected_df.loc[(electricity_impact_by_src_selected_df.index >= start_date) & (
|
| 1060 |
+
electricity_impact_by_src_selected_df.index <= end_date)].resample('H').sum()
|
| 1061 |
+
electricity_impact_by_src_hourly_df = electricity_impact_by_src_hourly_df.resample('H').mean()
|
| 1062 |
+
electricity_impact_by_src_hourly_df = aggregate_by_country(selected_country_name,
|
| 1063 |
+
electricity_impact_by_src_hourly_df)
|
| 1064 |
+
with col2:
|
| 1065 |
+
create_area_mixte(electricity_impact_by_src_hourly_df,
|
| 1066 |
+
title=f'Hourly average of GHG emissions by source in {selected_country_name}',text='gCO2/KWh',resolution='hourly')
|
| 1067 |
+
|
| 1068 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 1069 |
+
with download_col:
|
| 1070 |
+
download_data_as_csv(electricity_impact_by_src_hourly_df, f"Hourly_average_of_GHG_emissions_by_source_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 1071 |
+
with info_col:
|
| 1072 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 1073 |
+
st.write(f"""
|
| 1074 |
+
**Chart Description:**
|
| 1075 |
+
This stacked area chart visualizes the hourly average of greenhouse gas (GHG) emissions by energy source in **{selected_country_name}** over the selected period.
|
| 1076 |
+
Each color band represents the contribution of a different energy source to the total GHG emissions,
|
| 1077 |
+
measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh)
|
| 1078 |
+
|
| 1079 |
+
**Data Source:** EcoDynElec
|
| 1080 |
+
""")
|
| 1081 |
+
|
| 1082 |
+
|
| 1083 |
+
|
| 1084 |
+
if selection == "By Technology":
|
| 1085 |
+
|
| 1086 |
+
col1, col2 = st.columns(2) # Crée deux colonnes pour les graphiques
|
| 1087 |
+
with col1:
|
| 1088 |
+
techno_hourly_df = (techno_selected_df.loc[
|
| 1089 |
+
(techno_selected_df.index >= start_date) &
|
| 1090 |
+
(techno_selected_df.index <= end_date)]
|
| 1091 |
+
.resample('H').sum()) / 1000
|
| 1092 |
+
|
| 1093 |
+
create_area_mixte(techno_hourly_df,
|
| 1094 |
+
title=f'Daily average of GHG emissions by technology in {selected_country_name}',text='GWh',resolution='hourly')
|
| 1095 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 1096 |
+
with download_col:
|
| 1097 |
+
download_data_as_csv(techno_hourly_df, f"Hourly_average_of_GHG_emissions_by_technology_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 1098 |
+
with info_col:
|
| 1099 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 1100 |
+
st.write(f"""
|
| 1101 |
+
**Chart Description:**
|
| 1102 |
+
|
| 1103 |
+
This stacked area chart illustrates the hourly electricity consumption by technology in **{selected_country_name}** over the selected time period.
|
| 1104 |
+
Each area in the plot corresponds to a different energy source contributing to the total electricity consumption.
|
| 1105 |
+
|
| 1106 |
+
**Data Source:** EcoDynElec
|
| 1107 |
+
""")
|
| 1108 |
+
|
| 1109 |
+
|
| 1110 |
+
with col2:
|
| 1111 |
+
techno_impact_hourly_df = techno_impact_selected_df.loc[
|
| 1112 |
+
(techno_impact_selected_df.index >= start_date) &
|
| 1113 |
+
(techno_impact_selected_df.index <= end_date)].resample('D').mean()
|
| 1114 |
+
|
| 1115 |
+
create_area_mixte(techno_impact_hourly_df,
|
| 1116 |
+
title=f'Hourly average of GHG emissions by technology in {selected_country_name}',text='gCO2/KWh',resolution="hourly")
|
| 1117 |
+
|
| 1118 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 1119 |
+
with download_col:
|
| 1120 |
+
download_data_as_csv(techno_impact_hourly_df, f"Hourly_consumption_by_technology_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 1121 |
+
with info_col:
|
| 1122 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 1123 |
+
st.write(f"""
|
| 1124 |
+
**Chart Description:**
|
| 1125 |
+
This stacked area chart visualizes the hourly average of greenhouse gas (GHG) emissions by technology in **{selected_country_name}** over the selected period.
|
| 1126 |
+
Each color band represents the contribution of a different energy source to the total GHG emissions,
|
| 1127 |
+
measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh)
|
| 1128 |
+
|
| 1129 |
+
|
| 1130 |
+
|
| 1131 |
+
**Data Source:** EcoDynElec
|
| 1132 |
+
""")
|
| 1133 |
+
|
| 1134 |
+
|
| 1135 |
+
if selection == "Country of origin":
|
| 1136 |
+
tot_electricity_mix_hourly_df = tot_electricity_mix_selected_df.loc[
|
| 1137 |
+
(tot_electricity_mix_selected_df.index >= start_date) & (tot_electricity_mix_selected_df.index <= end_date)].resample('H').sum()
|
| 1138 |
+
hourly_mix_import = tot_electricity_mix_hourly_df.drop(['sum'], axis=1)
|
| 1139 |
+
hourly_mix_import = hourly_mix_import.multiply(tot_consumption_hourly, axis='index').resample('H').sum() / 1000
|
| 1140 |
+
|
| 1141 |
+
|
| 1142 |
+
col1, col2 = st.columns(2)
|
| 1143 |
+
with col1:
|
| 1144 |
+
create_area_chart(hourly_mix_import,title=f"Origins of hourly consumer mix by country in {selected_country_name}",resolution="hourly")
|
| 1145 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 1146 |
+
with download_col:
|
| 1147 |
+
download_data_as_csv(hourly_mix_import, f"Hourly_consumption_by_country_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 1148 |
+
with info_col:
|
| 1149 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 1150 |
+
st.write(f"""
|
| 1151 |
+
**Chart Description:**
|
| 1152 |
+
|
| 1153 |
+
This stacked area chart displays the origins of the hourly consumer electricity mix by country in Switzerland over the selected time period.
|
| 1154 |
+
Each color band represents the contribution of electricity imports from different countries to the total electricity mix consumed in **{selected_country_name}**.
|
| 1155 |
+
|
| 1156 |
+
**Data Source:** EcoDynElec
|
| 1157 |
+
""")
|
| 1158 |
+
|
| 1159 |
+
|
| 1160 |
+
tot_electricity_impact_hourly_df = tot_electricity_impact_selected_df[(tot_electricity_impact_selected_df.index >= start_date) &
|
| 1161 |
+
(tot_electricity_impact_selected_df.index <= end_date)]
|
| 1162 |
+
|
| 1163 |
+
hourly_mix_impact = tot_electricity_impact_hourly_df.drop(['sum'], axis=1).resample('H').mean()
|
| 1164 |
+
with col2:
|
| 1165 |
+
create_area_chart(hourly_mix_impact, title=f'Hourly average of GHG emissions by country in {selected_country_name}',resolution="hourly",unit="gCO2eq/KWh")
|
| 1166 |
+
download_col, info_col = st.columns([0.7, 0.3])
|
| 1167 |
+
with download_col:
|
| 1168 |
+
download_data_as_csv(hourly_mix_impact, f"Hourly_average_of_GHG_emissions_by_country_in_{selected_country_name.replace(' ', '_')}.csv")
|
| 1169 |
+
with info_col:
|
| 1170 |
+
with st.expander("ℹ️ Chart's Information"):
|
| 1171 |
+
st.write(f"""
|
| 1172 |
+
**Chart Description:**
|
| 1173 |
+
|
| 1174 |
+
This stacked area chart shows the hourly average of greenhouse gas (GHG) emissions by country in **{selected_country_name}**, measured in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh).
|
| 1175 |
+
Each color band represents the GHG emissions associated with electricity produced or imported from different countries.
|
| 1176 |
+
|
| 1177 |
+
**Data Source:** EcoDynElec
|
| 1178 |
+
""")
|
| 1179 |
+
|
| 1180 |
+
|
| 1181 |
+
|
| 1182 |
+
|
| 1183 |
+
|
| 1184 |
+
|
| 1185 |
+
|
| 1186 |
+
|
| 1187 |
+
|
| 1188 |
+
|
| 1189 |
+
|
| 1190 |
+
|
| 1191 |
+
|
| 1192 |
+
|
| 1193 |
+
|
| 1194 |
+
|
| 1195 |
+
|
| 1196 |
+
|
| 1197 |
+
|