Skip to content

Conversation

@Hinetziedacted
Copy link

  • Created nordic_emissions.json with static emission factors (gCO2eq/kWh) for Nordic regions: SE1-4, NO1-5, FI
  • Updated emissions.py to check for Nordic regions and load static factors from the new JSON file
  • Sweden/Norway regions use 18 gCO2eq/kWh, Finland uses 72 gCO2eq/kWh based on ENTSO-E data

Description

Please explain the changes you made here.

Related Issue

Please link to the issue this PR resolves: [issue #]

Motivation and Context

Why is this change required? What problem does it solve?

How Has This Been Tested?

Please describe in detail how you tested your changes.

Screenshots (if appropriate):

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

- Created nordic_emissions.json with static emission factors (gCO2eq/kWh) for Nordic regions: SE1-4, NO1-5, FI
- Updated emissions.py to check for Nordic regions and load static factors from the new JSON file
- Sweden/Norway regions use 18 gCO2eq/kWh, Finland uses 72 gCO2eq/kWh based on ENTSO-E data
@Hinetziedacted Hinetziedacted requested a review from a team as a code owner January 24, 2026 03:56
@benoit-cty
Copy link
Contributor

Hello,
Thanks for the contribution.

Can you describe in the code how to proceed to update these values next year ? The best way is to provide a script. If it's too difficult, an URL to the data could be fine.

Also, can you fix the linting of the code ?
Look at how to use pre-commit in https://github.com/mlco2/codecarbon/blob/master/CONTRIBUTING.md

@Hinetziedacted
Copy link
Author

Hinetziedacted commented Jan 26, 2026

Hey @benoit-cty, thanks for taking a look!

So for the documentation - I'm thinking I'll add some detailed comments right in the code explaining where these numbers come from. The values are based on ENTSO-E data:

Sweden/Norway (SE1-4, NO1-5): 18 gCO2eq/kWh - this is based on the Nordic grid average which sits around 60 gCO2eq/kWh. Sweden's specifically around 19 gCO2/kWh from 2023 data.

Finland: 72 gCO2eq/kWh - got this from Fingrid's real-time estimates which show it's in the 63-73 range.

I'll drop in links to:

For the linting stuff - yeah I see the pre-commit check is waiting for approval. Once you approve it I can see what breaks and fix it. Or I can just run pre-commit locally right now if that's easier? Let me know what you prefer!

- Added detailed comments explaining data sources (ENTSO-E, Fingrid)
- Included update procedure for annual maintenance
- Documented emission values: 18 gCO2eq/kWh (SE/NO), 72 gCO2eq/kWh (FI)
- Added direct links to data sources for future updates
@Hinetziedacted
Copy link
Author

Hinetziedacted commented Jan 26, 2026

Done! I just pushed the documentation in commit 2ce226a.

Added detailed comments in the code with:

  • Links to ENTSO-E and Fingrid data sources
  • Instructions for updating the values yearly
  • Explanation of where each number comes from

For the linting - I'll run pre-commit locally now and push the fixes in a sec.

@Hinetziedacted
Copy link
Author

Just ran pre-commit locally - all checks passed! isort, black, flake8, and autoflake all came back clean. The code's good to go on the linting side.

@SaboniAmine
Copy link
Member

Hello, thanks for your contribution!
There is a weird indentation in the file, which seems to prevent it to run correctly, see screenshot:
image
Could you please :

  • Add a unit test
  • Use the caching mechanism to load data in cache, the same way US data is loaded in get_country_energy_mix_data ?
    This way, the json load won't be executed at each measurement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants