-
-
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
Open
Shohail-Ismail
wants to merge
24
commits into
openclimatefix:main
Choose a base branch
from
Shohail-Ismail:german-solar-csv
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d322e06
Add window-fetching feature
Shohail-Ismail 0da5299
Add 5 year backfill process using data retrieval windows
Shohail-Ismail c2a937c
Add main function
Shohail-Ismail 14be2e0
Add tests
Shohail-Ismail 0baf6a6
Minor cosmetic changes
Shohail-Ismail 7940aad
Add missing import
Shohail-Ismail 25a26db
Fix imports to be cleaner
Shohail-Ismail d828798
Fix CI-related error
Shohail-Ismail f00ee15
Fix CI error not showing up in pytest
Shohail-Ismail f5dc2bc
Fix PSR code check for solar rows
Shohail-Ismail ca02289
Move solar export code into separatede_export.py script
Shohail-Ismail fa02153
Move solar export code into separate 'de_export.py' script
Shohail-Ismail dc45a28
Merge branch 'german-solar-csv' of https://github.com/Shohail-Ismail/…
Shohail-Ismail e5e5e90
Make XML more accurate to new ENTSOE API docs
Shohail-Ismail adc564c
Correct tests to align with new XML, and fix HTTP error path in inval…
Shohail-Ismail 43fd709
Remove 361K line backfilled-CSV
Shohail-Ismail 6fdefd6
Correct Ruff and Black errors
Shohail-Ismail 7d7a46f
Delete solar_consumer/exports/de_5_year_repopulate.csv
Shohail-Ismail 6f02f2b
Moved de_export.py to \scripts
Shohail-Ismail 5970e2c
Add ENTSOE_API_KEY to example.env + fix formatting
Shohail-Ismail 86c9551
Add entsoe-py as dependency + migrate DE solar data fetching to use i…
Shohail-Ismail d923a9f
Refactor tests to mock EntsoePandasClient, and add 2 new tests accord…
Shohail-Ismail 95c5b3b
Clean up code/comments
Shohail-Ismail c4abc62
Merge branch 'main' into german-solar-csv
Shohail-Ismail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,31 @@ | ||
| import os | ||
| from datetime import datetime, timedelta, timezone | ||
| from solar_consumer.data.fetch_de_data import fetch_de_data_range | ||
|
|
||
|
|
||
| def main(): | ||
| # 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 | ||
zakwatts marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # 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() | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.