Repository navigation
A Climate TRACE site can grow its waste with the city near it - #108
Conversation
A site row may carry city_population: the nearby city's UN World Urbanization Prospects 2025 population by year. SWEET grows the site's waste with that series instead of the country's. Before the city's first year and after its last, the city's nearest number moves with the country's population; between two reported years growth is constant. A row without the column grows with the country, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
It changes modelled waste for about 8,500 Climate TRACE sites, and three moderate issues (a pd.NA crash, a silent flat-line on gappy country data, and a reused city_population key) still need fixing.
3 open issues
What changed in this PR
This PR lets a Climate TRACE site grow its waste with the UN-listed city near it, instead of its whole country. A site row can carry city_population, a mapping (or JSON text) of the city's population by year. Where the city has a number, SWEET uses it. In gaps between reported years, it grows at a constant rate. Before the first or after the last reported year, it scales the city's nearest number by the country's population curve. Sites without a city keep the country curve, so WasteMAP paths are unchanged.
Changes:
- Adds
parse_city_populationandcity_population_seriestopopulation.py, which read the city's data and fill its yearly gaps. - Uses the city series in
import_basics_sitewhen a Climate TRACE row has a city. - Updates the
population-growthdecision entry, the changelog, and adds 16 tests.
| File | Description |
|---|---|
| tests/test_site_city_population.py | New tests for parsing, gap filling, and a site growing with its city or country. |
| SWEET_python/population.py | Adds the city parser and the yearly series builder. |
| SWEET_python/MODEL_DECISIONS.md | Updates the population-growth entry with the un-city-series option and the ct-site path. |
| SWEET_python/city_params.py | Uses the city series in import_basics_site when a Climate TRACE row has a city. |
| changelog/2026-10.md | Records the model-output change for Climate TRACE sites with a city. |
Review effort: Lite
…se a gappy country - The site-row key is now city_population_by_year. city_population already names the Brazil city-site path's one number per city, on a different frame. - parse_city_population treats any scalar missing value (pd.NA, NaT) as no city. - city_population_series returns None when the country series has a gap or a non-positive year, so the site falls back to the country instead of a NaN end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-its-nearest-city # Conflicts: # changelog/2026-10.md
There was a problem hiding this comment.
🟡 Changes recommended
A critical active defect leaves single-row sites using the frozen CAGR for landfill waste because the selected population series is not passed into the waste-generation frame.
1 open issue
3 resolved since last review
Review effort: Lite
…ear data Ingestion #299 lists every year from a city's first to 2050, not every fifth year, so log-linear growth now only bridges a gap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the changes are supported by focused tests and documentation covering city-population parsing, growth application, fallback behavior, and Climate TRACE integration.
No open issues 🎉
1 resolved since last review
Review effort: Lite


What changed
A Climate TRACE site row can now carry
city_population_by_year: the population, by year, of the UN-listed city near the site (UN World Urbanization Prospects 2025). When it does, SWEET grows the site's waste with that city's population instead of the country's.The UN lists a city only once it passes 50,000 people, so many cities start after 1975, and a quarter of those near our sites start after 2000. SWEET fills the missing years like this:
50,000 × country(1990) / country(2005)in 1990.Why the country's curve and not a fitted line: a straight line back from a fast-growing city reaches zero within a few decades, and its growth rate carried back shrinks it to almost nothing. The country's curve joins smoothly, never goes negative, and is what a site with no city gets anyway. A city usually grows faster than its country, so this slightly overstates a city's population before its first year.
A row without the column grows with the country, exactly as before. No WasteMAP path passes one.
population.parse_city_population: reads the mapping or its JSON text.population.city_population_series: builds the yearly series.city_params.import_basics_site(Climate TRACE path): uses it when the row has a city.Climate TRACE decides which city a site gets (same country, within 50 km): RMI/RMI_Climate_TRACE_Waste_Methane#246.
Does this change a modelling decision?
population-growthgains aun-city-seriesoption, used on thect-sitepath.Do model numbers change?
model-output-change, and the changelog entry says what moves. Only Climate TRACE sites whose row carries a city move. On the dev input that is 8,518 of 14,054 modelled sites. Against the country curve, a site's 1970 waste relative to 2023 moves by a median 0.97x (10th–90th percentile 0.50x–1.28x).Acceptance criteria
city_population_by_yeargrows with that city; a row without it grows with its country, unchanged.SWEET_python/MODEL_DECISIONS.mdandchangelog/2026-10.mdare updated.tests/test_site_city_population.py(22). Full suite: 667 passed, 1 skipped.Definition of done
Merged with main (2026-10-29)
The only conflict was
changelog/2026-10.md. The merge brings in #111–#113, which are unreleased, so the release that ships this also ships them. #113's new_site_intake_seriesgrows a site's averaged intake withpopulation_series, which is the city's series when the row carries one, so the two work together. 731 fast tests pass.Nothing changed here for the new upstream format: the supplement's
city_populationis a mapping of year text to people, whichparse_city_populationalready reads.🤖 Generated with Claude Code