-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Antoine TAVANT
committed
Jul 1, 2024
1 parent
5849530
commit 442e91d
Showing
8 changed files
with
120 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import streamlit as st | ||
|
||
if __name__ == "__main__": | ||
st.set_page_config( | ||
page_title="Prévision ENR", | ||
page_icon="🌞", | ||
) | ||
|
||
st.markdown("""# Bienvenue dans Energy Forecast! 🌞 | ||
Cette application est une démonstration d'un tableau de bord de prévision énergétique simple. | ||
Il est divisé en trois sections: | ||
- <a href="weather" target = "_self">Prévision météo</a> | ||
- <a href="power_generation" target = "_self">Prévision énergétique</a> | ||
- <a href="consumption_prediction" target = "_self">Prévision de consommation</a> | ||
- <a href="prediction_tempo" target = "_self">Prédiction Tempo</a> | ||
""" | ||
, unsafe_allow_html=True) | ||
|
||
st.sidebar.success("Sélectionnez une démo ci-dessus.") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Create a Streamlit page to display the consumption forecast. | ||
The Consumption forecast is obtained from the :class:`energy_forecast.consumption_forecast.PredictionForecastAPI` class. | ||
It uses RTE predictions. | ||
""" | ||
|
||
from energy_forecast.consumption_forecast import PredictionForecastAPI | ||
from energy_forecast import ROOT_DIR | ||
import pandas as pd | ||
import streamlit as st | ||
import altair as alt | ||
alt.renderers.set_embed_options(time_format_locale="fr-FR", format_locale="fr-FR") | ||
|
||
@st.cache | ||
def get_weekly_forecast(secret: str)->pd.DataFrame: | ||
"""Get the weekly forecast for the total electricity consumption. | ||
Parameters | ||
---------- | ||
secret : str | ||
The secret key to access the RTE API. | ||
Returns | ||
------- | ||
pd.DataFrame | ||
The weekly forecast for the total electricity consumption. | ||
The columns are ["time", "predicted_consumption"] | ||
""" | ||
consumption_forecast_api = PredictionForecastAPI(secret=secret) | ||
consumption_forecast = consumption_forecast_api.get_weekly_forecast( | ||
start_date=pd.Timestamp.now().date() | ||
).reset_index() | ||
return consumption_forecast | ||
|
||
if __name__ == "__main__": | ||
env_file = ROOT_DIR / ".env" | ||
with env_file.open("r") as f: | ||
secret = f.readline().strip().split("=", 1)[1] | ||
consumption_forecast = get_weekly_forecast(secret) | ||
|
||
|
||
st.title("Prévision de consomation electrique total") | ||
st.markdown("Prévision de consomation electrique total pour la semaine prochaine" | ||
" en utilisant les données de RTE.") | ||
|
||
title = alt.Title("Consomation electrique total prévue", anchor="start", | ||
subtitle="France métropolitaine") | ||
|
||
consumption_chart = alt.Chart(consumption_forecast, title=title).mark_line().encode( | ||
y=alt.Y("predicted_consumption:Q", title="Consomation electrique (MW)"), | ||
x=alt.X("time:T", title="Date") | ||
) | ||
st.altair_chart(consumption_chart, | ||
use_container_width=True | ||
) |
33 changes: 0 additions & 33 deletions
33
src/energy_forecast/dashboard/pages/3_consumption_prediction.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters