From 68db227b7f2186026739e3c9bdd4685f7a20a767 Mon Sep 17 00:00:00 2001 From: Antoine Tavant Date: Fri, 3 Jan 2025 12:06:49 +0000 Subject: [PATCH] manage new year --- data/gold/our_tempo_prediction.csv | 11 +++++++---- scripts/tempo_prediction.py | 5 +++++ src/energy_forecast/meteo.py | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/data/gold/our_tempo_prediction.csv b/data/gold/our_tempo_prediction.csv index b23cb1a..5f0e469 100644 --- a/data/gold/our_tempo_prediction.csv +++ b/data/gold/our_tempo_prediction.csv @@ -120,7 +120,10 @@ 2024-12-28,BLANC,prediction_bleu,,prediction_blanc 2024-12-29,BLEU,prediction_bleu,prediction_bleu, 2024-12-30,ROUGE,prediction_bleu,prediction_rouge,prediction_rouge -2024-12-31,BLANC,prediction_rouge,prediction_blanc,prediction_blanc -2025-01-01,,prediction_bleu,prediction_bleu,prediction_bleu -2025-01-02,,,prediction_rouge,prediction_rouge -2025-01-03,,,,prediction_rouge +2024-12-31,BLANC,prediction_bleu,prediction_blanc,prediction_blanc +2025-01-01,BLEU,prediction_bleu,prediction_bleu,prediction_bleu +2025-01-02,ROUGE,prediction_bleu,prediction_rouge,prediction_rouge +2025-01-03,ROUGE,prediction_bleu,,prediction_rouge +2025-01-04,,prediction_bleu,, +2025-01-05,,,prediction_bleu, +2025-01-06,,,,prediction_bleu diff --git a/scripts/tempo_prediction.py b/scripts/tempo_prediction.py index 35394cb..215ff28 100644 --- a/scripts/tempo_prediction.py +++ b/scripts/tempo_prediction.py @@ -45,6 +45,7 @@ def fetch_history_data() -> pd.DataFrame: TODO : add validation to check if the data is returned. """ one_year_ago = TODAY - pd.DateOffset(years=1) - pd.DateOffset(month=9, day=1) + print(one_year_ago) ecomix_data = get_eco2mix_data(start=one_year_ago, end=TODAY)[["consommation", "eolien", "solaire"]] ecomix_data_no_duplicates = ecomix_data[~ecomix_data.index.duplicated()] return ecomix_data_no_duplicates @@ -170,6 +171,8 @@ def get_history_tempo_days(): """Get the tempo signal since the start of the tempo year.""" client = TempoSignalAPI() start_date = TODAY - pd.DateOffset(day=1, month=9) + if start_date.date() >= TODAY: + start_date -= pd.DateOffset(years=1) after_tomorrow = TODAY + pd.DateOffset(days=2) history_tempo = client.get_data(start_date=start_date, end_date=after_tomorrow).sort_index(ascending=True) return history_tempo @@ -230,6 +233,8 @@ def main(): data = get_all_data() data = generate_features(data) first_day_of_tempo = (TODAY - pd.DateOffset(month=9, day=1)).tz_localize("Europe/Paris") + if first_day_of_tempo.date() >= TODAY: + first_day_of_tempo -= pd.DateOffset(years=1) predictor = TempoPredictor(data[first_day_of_tempo:].copy()) tempo_dummies = predictor.predict() our_tempo = pd.from_dummies(tempo_dummies).tz_convert("Europe/Paris").tz_localize(None) diff --git a/src/energy_forecast/meteo.py b/src/energy_forecast/meteo.py index f2ed290..8c060b6 100644 --- a/src/energy_forecast/meteo.py +++ b/src/energy_forecast/meteo.py @@ -586,7 +586,7 @@ def download_observations(url, filename): f.write(response.content) def download_observations_all_departments(cache_duration="12h", - file_type="latest-2023-2024_RR-T-Vent", + file_type="latest-2024-2025_RR-T-Vent", verbose=False): """Download the temperature for each department of France.""" url_template = "https://object.files.data.gouv.fr/meteofrance/data/synchro_ftp/BASE/QUOT/Q_{DEP_ID:0>2}_{file_type}.csv.gz"