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

First try at building a parser using data from Quebec #3237

Merged
merged 11 commits into from
Jul 29, 2021

Conversation

pjakobsen
Copy link
Contributor

Hopefully this will show up on the map somehow. I look forward to seeing what changes will be made in order to make this parser functional.

Copy link
Member

@madsnedergaard madsnedergaard left a comment

Choose a reason for hiding this comment

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

I have added some comments that needs to be fixed, but overall this is great! :)

parsers/CA_QC.py Outdated Show resolved Hide resolved
parsers/CA_QC.py Outdated Show resolved Hide resolved
parsers/CA_QC.py Outdated Show resolved Hide resolved
config/zones.json Outdated Show resolved Hide resolved
parsers/CA_QC.py Outdated Show resolved Hide resolved
parsers/CA_QC.py Outdated Show resolved Hide resolved
parsers/CA_QC.py Outdated Show resolved Hide resolved
parsers/CA_QC.py Outdated Show resolved Hide resolved
@madsnedergaard
Copy link
Member

madsnedergaard commented Jul 27, 2021

One more thing I forgot in the first pass: timezones 😄

Here's how it could be done (inspired by CA_ON parser):

# TODO: Add this after the constants
tz_obj = timezone(timedelta(hours=-4), name="GMT-4")


# TODO: Use it like this for both production and consumption
"datetime": arrow.get(elem["date"], tzinfo=tz_obj).datetime,

Is the UTC offset correct and is DST something we should consider?

I have asked in #3210 (comment) whether the data is in local time or not :)

@pjakobsen
Copy link
Contributor Author

Somewhat lost on all the fancy Github features for such a large collaboration. Looks like you have automated pull requests set up, need to read up on this feature. Thanks for your support @madsnedergaard - I hope to pay it forward.

@pjakobsen
Copy link
Contributor Author

pjakobsen commented Jul 28, 2021

One more thing I forgot in the first pass: timezones 😄

I have implemented your suggestions, and the code runs using python CA_QC.py, but now poetry run test-parser CA-QC fails:

...
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1163 column 5 (char 24851)

Should I commit, or make the test pass first? Looking forward to more suggestions.

Copy link
Member

@madsnedergaard madsnedergaard left a comment

Choose a reason for hiding this comment

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

Somewhat lost on all the fancy Github features for such a large collaboration. Looks like you have automated pull requests set up, need to read up on this feature. Thanks for your support @madsnedergaard - I hope to pay it forward.

Happy to help, super excited about getting Quebec on the map!

Thanks for the swift response and for fixing all the comments 💪
Just a few things left:

parsers/CA_QC.py Outdated Show resolved Hide resolved
config/zones.json Show resolved Hide resolved
@madsnedergaard
Copy link
Member

Maybe using just the timezone "name" (America/Montreal) is easier and could potentially(?) make sure it handles DST for us? 🤔

timezone = 'America/Montreal'
arrow.get(elem["date"], tzinfo=timezone).datetime

@KabelWlan
Copy link
Contributor

I'm excited that Quebec will be on the map soon!

I'd suggest changing the capacity and using the following values:
biomass: 257
coal: 0
gas: 411
geothermal: 0
hydro: 42180 (includes Churchill Falls and the small hydro plants)
nuclear: 0
oil: 131
solar: 10
unknown: 1056
wind: 3508

Sources used:
solar: http://news.hydroquebec.com/en/press-releases/1730/hydro-quebec-inaugurates-its-first-two-solar-generating-stations/
(I think they round the production values to full numbers that's why I'd go with 10 MW instead of 9.5 MW here)
other: https://www.hydroquebec.com/generation/generating-stations.html

@pjakobsen
Copy link
Contributor Author

I'm excited that Quebec will be on the map soon!

I've added you as a contributor to zones.json. :)

@pjakobsen
Copy link
Contributor Author

Maybe using just the timezone "name" (America/Montreal) is easier and could potentially(?) make sure it handles DST for us? 🤔

timezone = 'America/Montreal'
arrow.get(elem["date"], tzinfo=timezone).datetime

Hi Mads, do you mean add timezone = 'America/Montreal as a constant in CA_OC.py? Or will it get picked up from zones.json

As a constant, and using datetime": arrow.get(elem["date"], tzinfo=timezone).datetime :

 python3 CA_QC.py
fetch_production() ->
{'datetime': datetime.datetime(2021, 7, 28, 6, 30, tzinfo=tzfile('/usr/share/zoneinfo/America/Montreal')),
....

@madsnedergaard
Copy link
Member

Maybe using just the timezone "name" (America/Montreal) is easier and could potentially(?) make sure it handles DST for us? 🤔

timezone = 'America/Montreal'
arrow.get(elem["date"], tzinfo=timezone).datetime

Hi Mads, do you mean add timezone = 'America/Montreal as a constant in CA_OC.py? Or will it get picked up from zones.json

As a constant, and using datetime": arrow.get(elem["date"], tzinfo=timezone).datetime :

 python3 CA_QC.py
fetch_production() ->
{'datetime': datetime.datetime(2021, 7, 28, 6, 30, tzinfo=tzfile('/usr/share/zoneinfo/America/Montreal')),
....

I was basically thinking it could be used like arrow.get(elem["date"], tzinfo='America/Montreal').datetime in the response object for production + consumption - I was originally thinking it could be a variable in the same file, not that it matters much :)

Copy link
Member

@madsnedergaard madsnedergaard left a comment

Choose a reason for hiding this comment

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

Last few comments to make CI happy and then I think we're done! 🥳

parsers/CA_QC.py Outdated Show resolved Hide resolved
parsers/CA_QC.py Outdated Show resolved Hide resolved
parsers/CA_QC.py Outdated Show resolved Hide resolved
Copy link
Member

@madsnedergaard madsnedergaard left a comment

Choose a reason for hiding this comment

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

👏 👏

@madsnedergaard madsnedergaard merged commit bf97a38 into electricitymaps:master Jul 29, 2021
skovhus pushed a commit that referenced this pull request Aug 3, 2021
* First try at building a parser using recently released data from Quebec, Canada

* Fixes as suggested by @madsnedergaard for #3237.  Fixes #3237

* Fixes time zone issues. Note, America/Montreal is not available, thus using America/Toronto

* Fix time zone issues. Added more contributors

* Yet anotother timezone_id fix

* Removed unused imports and updated function definitions

* New information on capacities and implemented special case for gas production from ticket #3218 and #3254

* Clean up of explanatory notes related to production gas in QC

* Pythonic suggestion for Ternary logic from @jarek

* Clear up notes realted to production, drop biomass default value of 0.0

* Clear up notes re. production and drop biomass default value of 0.0

Co-authored-by: Mads Nedergaard <nedergaardmads@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants