Skip to content

Commit

Permalink
manage new year
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinetavant committed Jan 3, 2025
1 parent ee31f46 commit 68db227
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 7 additions & 4 deletions data/gold/our_tempo_prediction.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions scripts/tempo_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/energy_forecast/meteo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 68db227

Please sign in to comment.