-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add 5-year German solar data backfilling support with a CSV export #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 17 commits
d322e06
0da5299
c2a937c
14be2e0
0baf6a6
7940aad
25a26db
d828798
f00ee15
f5dc2bc
ca02289
fa02153
dc45a28
e5e5e90
adc564c
43fd709
6fdefd6
7d7a46f
6f02f2b
5970e2c
86c9551
d923a9f
95c5b3b
c4abc62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import os | ||
| from datetime import datetime, timedelta, timezone | ||
| from solar_consumer.data.fetch_de_data import fetch_de_data_range | ||
|
|
||
|
|
||
| def main(): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you move this to a |
||
| # Backfill from 01/01/2020 to yesterday and write to CSV | ||
| out_path = os.path.join("solar_consumer", "exports", "de_5_year_repopulate.csv") | ||
|
|
||
| now_utc = datetime.now(timezone.utc).replace(minute=0, second=0, microsecond=0) | ||
| end = (now_utc - timedelta(days=1)).replace(minute=0, second=0, microsecond=0) | ||
|
|
||
| # Start on 01/01/2020 for clean boundaries | ||
| start = datetime(2020, 1, 1, 0, 0, 0, tzinfo=timezone.utc) | ||
|
|
||
| # Perform backfill using week-long chunks | ||
| df = fetch_de_data_range( | ||
| start, end, chunk_hours=168 | ||
| ) ### Adjust if you hit API limits | ||
|
|
||
| # Write to file (done with temp to avoid empty file if failure midway) | ||
| temp = out_path + ".tmp" | ||
| df.to_csv(temp, index=False) | ||
| os.replace(temp, out_path) | ||
| print( | ||
| f"FINISHED: WROTE {len(df)} ROWS OF SOLAR GENERATION DATA TO FILE: {out_path}" | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| target_datetime_utc,solar_generation_kw,tso_zone | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.