Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
73 stars 23 forks source link

Add electricity map as an electricity impact factor provider #117

Open da-ekchajzer opened 2 years ago

da-ekchajzer commented 2 years ago

Problem

I want to use the electricity map API to provide the carbon electrical impact factor when I evaluate the usage impacts of my devices and components.

Solution

See : https://static.electricitymap.org/api/docs/index.html#introduction

Embed electricity map query parameter in the usage object :

"usage":{
"electricity_map": {
   "zone": "elec_map_zone"
   "date":{"date", "latest"},
   "token": "elec_map_token"
}
}

if date is "latest" : https://api.electricitymap.org/v3/carbon-intensity/latest?zone=[zone]

if date is a date : https://api.electricitymap.org/v3/carbon-intensity/past?zone=[zone]&datetime=[date]

If date is not given: https://api.electricitymap.org/v3/power-breakdown/latest?zone=[zone]

If zone is not given zone=[usage_location] note: A conversion need to be done between NATO country code use in Boaviztapi and electricity map zone name

-H 'auth-token: elec_map_token' must be added for each querry

TODO

Multicriteria

I added an issue to electricity map' repo to integrate multi-criteria impacts https://github.com/electricitymap/electricitymap-contrib/issues/4518

bpetit commented 2 years ago

This would be great. Only problem being, we certainly would have a free api key as we are a non profit, but users would not be able to test that feature on their own if their company don't pay for the api.

Maybe we should also have an entsoe feature and abstract the two between a "dynamic" usage feature ?

da-ekchajzer commented 2 years ago

If users doesn't have an premium API token, they could both provide a free token to access the current carbon intensity from electricity map or use the existing emission factors we have in our dataset if no API key is given.

I agree that this would mean a abstraction of the source of impacts factors. It is the architecture we are trying to build.

From what I know, ENTSOE only report data decrying the electricity mix and energy transfers between European country, but no data related to carbon intensity. Measuring the impacts from this source of data would require a significant amount of work (basically reconstructing electricity map). Did you have another idea to recover an impact from this data?

dorev commented 1 year ago

I did work a bit on this to try to match the zones with the country codes. Is there somewhere where you keep Jupyter Notebooks for explorations? electricityMapCountryCodes.ipynb.zip

da-ekchajzer commented 1 year ago

Nice work ! I just created a repo for this kind of resource : https://github.com/Boavizta/boaviztapi-utils.

I think that we might want to think a little bit about how we want to implement the geographical zone conversion, since we also want to convert cloud zone (see https://github.com/Boavizta/boaviztapi/issues/144). I am available if you wish to talk about it.

To give some context on how to implement this feature :

I have an electricity map API token given by electricity map for testing purposes.

da-ekchajzer commented 1 year ago

Here are some thought on how we should implement the input format :

https://github.com/Boavizta/boaviztapi/blob/dev/boaviztapi/data/config.yml

electricity_map_token=token
"usage":{
"usage_location": "FRA",
"elec_factor":{
"time_frame": {
   "start":"08/05/2018"
   "end":"08/06/2018"
}}

By default, if the user does not provide a time_frame we could use the average factor for the latest year.