Repository navigation
feat(china): use official 2023 MEE/NBS provincial emission factors - #1448
Merged
Merged
Conversation
Add the 30 provincial electricity CO2 factors published in Announcement 2025 No. 47, a province name lookup, and a CHN branch next to USA/CAN in get_region_emissions. Tibet, Hong Kong, Macao, Taiwan and unknown regions keep using the national value.
Contributor
|
Thanks for this great improvement. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1448 +/- ##
==========================================
+ Coverage 92.07% 92.15% +0.07%
==========================================
Files 49 49
Lines 5202 5227 +25
==========================================
+ Hits 4790 4817 +27
+ Misses 412 410 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add a 'Regional data' section to the methodology page listing the sub-national sources (USA, Canada, Nordic bidding zones, China provinces) and the CO2 vs CO2eq convention of the MEE/NBS factors. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
benoit-cty
approved these changes
Oct 17, 2026
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
Adds the official 2023 provincial electricity CO2 emission factors for China (MEE/NBS Announcement 2025 No. 47, Table 3) and uses them for private-infrastructure emissions when the geolocation service reports a Chinese province.
codecarbon/data/private_infra/2023/china_provincial_emissions.json: 30 provinces keyed by ISO 3166-2 code,emission_factorin gCO2/kWh, withmetadata(source URL, announcement number, publication date, year, unit, convention, note that Tibet is not published) and, per province, the lower-case names accepted from geolocation (names).codecarbon/input.py: loads the file with the other static data (same cache pattern as the Nordic file) and exposesDataSource.get_china_provincial_emissions_data().codecarbon/core/emissions.py: newCHNbranch inget_region_emissionsnext to USA/CAN, via_try_get_china_province_emissions. Matching is case-insensitive and ignores a trailing "province", "municipality" or "autonomous region". The CHN branch is only entered when the country code isCHN, so Hong Kong, Macao and Taiwan (their own country codes) never get a mainland value.get_country_emissions), as today, with no warning logged.pyproject.toml: adds the JSON to the package data.Convention: the values are exactly as published, CO2 only (not CO2eq, no lifecycle), average over all generation in the province, location-based. This is stated in the JSON metadata.
Related Issue
Resolves #1444
Motivation and Context
Grid carbon intensity in China differs by a factor of about five between provinces (for example Yunnan 133.3 g/kWh, Tianjin 679.6 g/kWh), but codecarbon applies a single national value to every Chinese IP. The ipinfo.io fallback returns the province for Chinese IPs (geojs returns no region for them), so the information is already available; only the factors and the name mapping were missing. The structure follows the one described in the discussion on the issue: JSON data file with the source URL, a name-to-key mapping, and a branch in
emissions.pywith tests.How Has This Been Tested?
tests/test_emissions.py: province hit with an exact expected value, all 30 provinces resolve to their own factor, name variants (case, whitespace, "Inner Mongolia", "Nei Mongol", "Ningxia Hui", "Xinjiang Uygur", "Guangxi Zhuang", "... Autonomous Region", "... Province"), Shaanxi and Shanxi kept distinct, alias uniqueness, Tibet / Xizang / Hong Kong / Macao / Taiwan / unknown / no region fall back to the national value without warnings, a province name under another country code (HKG, TWN, MAC, FRA) is not used, a data loading error falls back to the national value, forced carbon intensity still takes precedence.GeoMetadataandEmissions.pre-commit run --all-filespasses; full suite (test-packagetask) 681 passed, 20 skipped; the built wheel contains the JSON file.Screenshots (if appropriate):
Types of changes
What types of changes does your code introduce? Put an
xin all the boxes that apply:AI Usage Disclosure
Please refer to docs/how-to/ai-policy.md for detailed guidelines on how to disclose AI usage in your PR. Accurately completing this section is mandatory.
The AI tool read the codebase, drafted the data file, the name mapping, the emissions branch and the tests, and ran the tests and linters. I reviewed the diff line by line, re-checked all 30 values against the official PDF, and re-ran the tests locally.
Checklist:
Go over all the following points, and put an
xin all the boxes that apply.