Repository navigation
A city with no waste figure of its own generates waste at its country's default rate - #79
Open
HughRunyan wants to merge 2 commits into
Open
HughRunyan wants to merge 2 commits into
HughRunyan wants to merge 2 commits into
Conversation
When a cities-table row has no generated or collected tonnage, load_andre_params sizes the city's waste as the IPCC per-capita default times the city's population. That population is the population year's, so the mass already describes the population year. The loader labelled it 2019, and the adjustment that moves a surveyed tonnage from its survey year to the population year then moved it again: the city got default x P(population year) / P(2019). Kuwait City published 7.92 kg/person/day against Kuwait's 8.36. The default branch now takes the population year as its year, so the adjustment leaves it alone; a surveyed tonnage is still moved. The legacy SINIR loader, import_basics, had the same rule and gets the same fix. The 39 defaulted cities in WasteMAP's June 2026 table change by -7.9% to +53.9% (mass and CH4 alike), and publish their population year as "Year of Data Collection (MSW)" instead of 2019. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
When a cities-table row has no tonnage,
City.load_andre_paramssizes the city's waste as the IPCC per-capita default × the city's population. That population is the one for the row's population year, so the mass already describes the population year. The loader labelled it 2019 anyway, then ran the adjustment that moves a surveyed tonnage from its survey year to the population year. That moved the mass a second time, so every defaulted city gotdefault × P(population year) / P(2019), or the compounded equivalent for a big city on its own UN rates.With this PR, the default takes the population year as its year, so the adjustment leaves it alone.
Bug report
Environment: SWEET_python
mainat d5c592e,City.load_andre_params, non-backfill branch (SWEET_python/city_params.py, the default block and the "difference in reporting years" adjustment below it). WasteMAP's cities-table build (backend/scripts/make_cities_table.py) reaches this code. That build publishes the map's city figures and the table the City DST reads.Reproduction:
_rowintests/test_default_waste_per_capita.pydoes this.City("Kuwait City").load_andre_params(row).Expected:
waste_per_capitais Kuwait's default: 3.05 t/yr, or 8.356 kg/person/day. The waste mass is 8.356 × 2,779,000 × 365 / 1000 = 8,475,950 t/yr.Actual: 7.923 kg/person/day and 8,036,460 t/yr, which is the default × 1.0134⁻⁴. The June 2026 cities table publishes exactly this for Kuwait City (7.92 kg/person/day, 8,036,459.98 t/yr).
Evidence: on
main, the new tests give 13 failed and 1 passed. Each failing value equals the default × P(population year) / P(2019) to the last digit:The test that passes on both is the control: a surveyed tonnage still moves from its survey year to the population year.
The fix
In the default branch,
year_of_data_msw = int(year_of_data_pop)replaces2019. The adjustment below then leaves the mass alone. A surveyed tonnage moves exactly as before.City.import_basics, the legacy SINIR loader, had the same rule and gets the same one-line fix. Onlymodel_city_via_sitesreaches it, and nothing calls that.Effect
In WasteMAP's June 2026 cities table, 39 of 5,962 cities have "Defaults Used: Waste Mass". SWEET's emissions are linear in waste mass, so each city's CH4 changes by the same ratio as its waste, in every year. I checked this: for all 39 cities, the CH4 ratio equals the mass ratio to within 1e-15 in both 2025 and 2050.
waste_mass_year.load_andre_params(no matches on CTmain).Per-city before/after (39 cities)
How the columns were computed:
load_andre_paramson each city's published population, population year, country and own UN rates. Those are the only inputs that decide a defaulted city's mass.main, this reproduces the June table's mass to within 6e-8 for the 14 cities on their own rates. The 25 cities on their country's series differ, because WasteMAP's tools grow waste with the country's UN population, year by year #71 changed their growth after the table was built.Needs your input: which year these 39 rows publish
The arithmetic doesn't depend on this choice: a per-capita rate × population gives the same mass whatever year the rate is said to describe. The label matters downstream.
year_of_data_mswis published as "Year of Data Collection (MSW)" and appended to all three "Data Source" labels. The API also returns it aswaste_mass_year, the year the ADST prefill anchors the city's tonnage on.waste_mass_yearbecomes correct for these rows. The catch: 21 of the 39 carry their own composition, and its label would show the population year, which isn't that data's year either. Today it shows 2019.Options 2–4 need the label kept separately from the year the adjustment uses. That is a one-line follow-up.
Not in this PR
import_basics_site. They size a site for a placeholder population of 100, so a default there means nothing either way. Climate TRACE also drops sites with no tonnage before SWEET runs.waste_mass_yearfor cities with their own tonnage. 205 of them publish a survey year that differs from the population year SWEET moved their tonnage to, so the API mislabels them. That is WasteMAP's to fix, separately.changelog/2026-10.md. Whichever of those merges after another needs its## Fixedentries stacked.Acceptance criteria
import_basicsfollows the same rule.Definition of Done
pytest -m "not integration": 286 passed locally)Test plan
tests/test_default_waste_per_capita.py(14 tests): 13 fail onmain, and all 14 pass on this branch.🤖 Generated with Claude Code