Repository navigation
feat(data): update US state carbon intensity to EPA eGRID2023 - #1452
Open
ArshiaBajaj wants to merge 2 commits into
Open
ArshiaBajaj wants to merge 2 commits into
ArshiaBajaj wants to merge 2 commits into
Conversation
Replace the eGRID2016 state CO2 rates with eGRID2023 CO2eq total output emission rates, add scripts/update_usa_emissions.py to rebuild the file from EPA's workbook, and update docs and tests.
benoit-cty
requested changes
Oct 20, 2026
benoit-cty
left a comment
Contributor
There was a problem hiding this comment.
Thanks, that's a great improvement.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1452 +/- ##
=======================================
Coverage 92.94% 92.94%
=======================================
Files 50 50
Lines 5440 5440
=======================================
Hits 5056 5056
Misses 384 384 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
@benoit-cty thanks for the review! I moved the script to codecarbon/data/private_infra/update_usa_emissions.py and updated the test and docs paths (commit 71061cf). On units: I'll keep lbs/MWh here to match the existing file and open a follow-up PR to switch the US data to gCO2eq/kWh like the China and Nordic files. Ready for another look whenever you have time. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
US regional emissions now use EPA eGRID2023 state CO₂eq total output emission rates instead of the eGRID2016 CO₂ rates.
codecarbon/data/private_infra/2023/usa_emissions.json: new data file, same schema as the 2016 one (emissionsin lbs/MWh,regionCode), plus a_sourceentry naming the eGRID edition and field.scripts/update_usa_emissions.py: builds that file from EPA's eGRID workbook (sheetsST23/US23, fieldsSTC2ERTA/USC2ERTA).--gas co2switches to CO₂-only rates (STCO2RTA).codecarbon/input.pyandpyproject.toml: point at, and package, the 2023 file. The 2016 file stays in the repo for history but is no longer shipped, like2016/canada_energy_mix.json.docs/explanation/methodology.md: updated the regional-data table and added a short US paragraph, including how to rerun the script.No logic in
emissions.pychanges.Related Issue
Closes #1451. Part of #947 (process for updating reference data).
Motivation and Context
The 2016 rates overstate emissions for 45 of 51 states (incl. DC), 40 of them by more than 10%. Examples: US average 998.4 → 770.9 lb/MWh, Georgia 1001.8 → 717.4, Illinois 811.3 → 474.4, New Mexico 1572.8 → 773.6. Idaho, Washington and Oregon were understated by more than 10%. Every US user on the offline/default path gets these numbers.
CO₂ vs CO₂eq: I used the CO₂eq rate because CodeCarbon reports
kg CO2eq. The gap from CO₂-only is under 2% for every state except Vermont (43.0 vs 52.2). If you'd rather keep CO₂ only, it's a one-flag change:--gas co2.How Has This Been Tested?
usa_emissions.jsonwith the new script from EPA's officialegrid2023_data_rev2.xlsx(rev. 2, June 2025); values match EPA's published Table 3 to within rounding.tests/test_update_usa_emissions.py: JSON format, every state and DC present, a missing state raises, extra regions (PR) are ignored, the packaged file round-trips through the script, and reading an eGRID-layout workbook (skipped whenopenpyxlisn't installed, since it isn't a project dependency).tests/test_emissions.py: updated the Illinois expected value (0.110 → 0.0646 kg for 0.3 kWh) and tightened its precision. Added spot checks against EPA's published table (GA, VT, WV, US) and a test that every state resolves to its own rate throughget_private_infra_emissions.tests/test_emissions.pyandtests/test_update_usa_emissions.pyon macOS: 44 passed, 1 skipped. Formatting hooks (autoflake, isort, black, flake8) pass.Types of changes
AI Usage Disclosure
Checklist: