Skip to content
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

Improve REE capacity parser time granularity #6218

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

silimotion
Copy link
Contributor

Description

I have updated the REE capacity parser so it takes into account the month of the given timestamp instead of only the year

This will allow to have more recent and accurate capacities

Preview

poetry run update_capacity --zone ES --target_datetime 2023-12-03
INFO:electricitymap.contrib.capacity_parsers.REE:Fetched capacity for ES on 2023-12-03: 
{'hydro': {'datetime': '2023-12-03', 'value': 17096.0, 'source': 'ree.es'}, 'hydro storage': {'datetime': '2023-12-03', 'value': 3331.0, 'source': 'ree.es'}, 'nuclear': {'datetime': '2023-12-03', 'value': 7117.0, 'source': 'ree.es'}, 'coal': {'datetime': '2023-12-03', 'value': 3223.0, 'source': 'ree.es'}, 'gas': {'datetime': '2023-12-03', 'value': 30152.0, 'source': 'ree.es'}, 'wind': {'datetime': '2023-12-03', 'value': 29905.0, 'source': 'ree.es'}, 'solar': {'datetime': '2023-12-03', 'value': 25667.0, 'source': 'ree.es'}, 'unknown': {'datetime': '2023-12-03', 'value': 1474.0, 'source': 'ree.es'}, 'biomass': {'datetime': '2023-12-03', 'value': 132.0, 'source': 'ree.es'}}
Updated ES.yaml with new capacity data
Running prettier...

Double check

  • I have tested my parser changes locally with poetry run update_capacity --zone "zone_key"
  • I have run pnpx prettier --write . and poetry run format to format my changes.

@silimotion silimotion changed the title Improve time granularity Improve REE capacity parser time granularity Dec 3, 2023
@VIKTORVAV99 VIKTORVAV99 requested a review from a user December 4, 2023 07:46
"end_date": target_datetime.strftime("%Y-12-31T23:59"),
"time_trunc": "year",
"start_date": target_datetime.strftime("%Y-%m-01T00:00"),
"end_date": target_datetime.strftime("%Y-%m-31T23:59"),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like the code works if running for November but this can lead to errors for months that do not have 31 days.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should do the trick:

calendar.monthrange(test_date.year, test_date.month)[1]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for me for other months, even February. I could change it to"%Y-%m-01T23:59", if you wish. That one seems to also work. Is it necessary to be the last day of the month?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no i don't think it need to be the last day if the parser returns the same data when you query for 1 day

@github-actions github-actions bot added python Pull requests that update Python code capacity parser and removed parser labels Dec 15, 2023
@madsnedergaard madsnedergaard requested a review from a user January 19, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
capacity parser capacity python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants