Skip to content

WasteMAP's tools grow waste with the country's UN population, year by year - #71

Merged
HughRunyan merged 2 commits into
mainfrom
waste-grows-with-the-uns-yearly-population
Sep 30, 2026
Merged

HughRunyan merged 2 commits into
mainfrom
waste-grows-with-the-uns-yearly-population

Conversation

@HughRunyan

@HughRunyan HughRunyan commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

What this changes

WasteMAP's tools grow waste with the country's UN population, year by year, the way Climate TRACE's model already does: P(year) / P(anchor year), from the UN's World Population Prospects 2024.

Before, WasteMAP compounded flat rates:

  • Site tool: the form's rate (2% a year if the API was sent none).
  • City tool: two growth columns from the cities table.
  • Custom Location: one constant for every country.

Paired with RMI/WasteMAP#839, on the same branch name so WasteMAP CI installs this branch.

Why

As a WasteMAP modeler, I want the site and city tools to grow waste the way Climate TRACE's model does, so the tools and the published Climate TRACE numbers agree.

The city columns come from the UN's list of cities over 300,000 (World Urbanization Prospects 2018), matched to the nearest listed city. A smaller city therefore had another city's rates, and for many Brazilian towns those were wrong:

  • For small towns, the town's own 2020 population was mixed with a big city's 1950 and 2035 figures.
  • Serra da Saudade (781 people) had −8.6% a year to 2020 and +83% a year after, from Belo Horizonte's figures.
  • 424 of 5,693 cities had more than 10% a year.

The bug

  • Environment: SWEET_python main @ 50a80cf, as installed by the WasteMAP API (/v1/city_emissions/*, /v1/site_emissions/sdst_v1_5) and the map-data build (make_cities_table.py).
  • Reproduction: load a small city through load_csv_new or load_andre_params, e.g. Serra da Saudade (BRA, 781 people), from cities_for_map_20260930T135753Z. Its "Population Growth Rate" columns are −8.56% / +83.03%, and SWEET compounds them. For Custom Location, call dst_baseline_blank for any country: the growth rates are the same constants everywhere.
  • Expected: waste grows with the country's population, as it does on Climate TRACE's path.
  • Actual: the rates compounded are another city's figures (a big city's 1950 and 2035 populations mixed with the town's own 2020), or one global constant. 424 of 5,693 cities had more than 10% a year.

Changes

  • SWEET_python/pops_yearly.csv: Climate TRACE's static_data/pops_yearly.csv (1970–2050) unchanged, plus 1950–1969 from the same UN file, because the site tool models from a landfill's real opening year.
    • Rebuilt with Climate TRACE's generator: it matches Climate TRACE's 1970–2050 values for all 237 UN countries, and its 1950 values match pops.csv.
    • Svalbard's row differs in units only: the generator writes persons, Climate TRACE's file thousands.
  • SWEET_python/population.py: country_population_series(iso3) and average_growth_rates(series, anchor_year). The averages are the one-number rates a person reads, which the city tool shows.
  • Site tool: cityparams_obj_for_blank_site and sdst_v1_5 take growth_rate_override=None to mean the country's population. A passed rate is compounded exactly as before.
  • City tool and the map's city emissions (load_csv_new, load_andre_params): a city under 300,000 grows with its country.
    • A city of 300,000 or more keeps its own UN city rates, because a big city outgrows its country.
    • The exception is a rate outside −2% to +7% a year, which is the same data mix-up (Manila City +16.9%, Kuala Lumpur +11.7%, Penang −8.6%).
  • Custom Location (dst_baseline_blank) grows with its country. The constant was 2.5% a year to 2020, then 1.4%, everywhere.
  • The city scenario (implement_dst_changes_simple_v1_5) grows its waste and diversions the same way as its baseline.
  • WasteGeneratedDF.create_advanced, create_advanced_2 and DivsDF.create_simple take population_series. Without it they compute exactly what they did.

Climate TRACE's pipeline calls none of the changed functions; it passes its own pop_data. Its outputs do not move.

Effect (city tool baseline, this branch vs main, cities_for_map_20260930T135753Z)

City Growth before → after (%/yr, historic / future) CH4 2050 before → after (t)
Lagos, London, Delhi, Nairobi own UN city rates, unchanged identical
Manila City 0.22 / 16.87 → 2.22 / 0.62 (Philippines) 1,849,470 → 33,968
Arroio do Tigre (BRA) 3.98 / 0.77 → 1.62 / 0.17 (Brazil) 35 → 30
Custom Location, USA 2.52 / 1.40 → 0.97 / 0.40 —

Review fixes

  • Countries are found by exact code or name before the fuzzy search. The fuzzy search turned "MUS" into Turkey (province Muş) and "Niger" into Nigeria, which now mattered because the code picks the population series.
  • CityParameters.city_growth_rate_* keeps a city's own rates as read. WasteMAP's map build republishes those, so the city tool re-running _city_growth on the table makes the same choice. Publishing the applied averages had turned 13 big cities, e.g. Bangkok and Manila City, back into flat rates.
  • A custom site's prefill starts from the country's population projection, not the 2019 default table.
  • The growth constructors call growth_factors_for_years once each: bit-identical on 1,584 cases.
  • constants.py names both copies of the population table.

Tests

  • New tests/test_population_growth.py (18 tests), which checks:
    • the table;
    • the averages;
    • each constructor, with the series and with a rate;
    • the city growth rule;
    • Custom Location;
    • the city scenario;
    • a custom site with no rate (follows Brazil's population) and with a typed 2% (compounds as before).
  • Full suite: 265 passed.
  • WasteMAP's backend fast suite against this branch: 395 passed.

Acceptance criteria

  • The site tool, the city tool (cities under 300,000, or with implausible rates), Custom Location and the city scenario grow waste by the country's UN population series.
  • A city of 300,000 or more with plausible rates, and a site-tool rate that is set, give exactly the results they gave before.
  • Climate TRACE's paths are unchanged.

Definition of done

Acceptance criteria met · tests and checks pass · changelog updated · reviewed and merged, together with the WasteMAP PR.

🤖 Generated with Claude Code

… year

Climate TRACE's pipeline grows each site by P(year) / P(anchor year) from the
UN's WPP2024. WasteMAP's paths compounded two flat rates: the site tool's form
value, the cities table's columns, and one constant for every Custom Location.

SWEET now ships pops_yearly.csv (Climate TRACE's table, extended back to 1950)
and grows by it:
- site tool: growth_rate_override=None means the country's population; a
  passed rate is compounded as before
- city tool and the map's city emissions: a city under 300,000 grows with its
  country, because its table rates are the nearest big city's; a bigger city
  keeps its own UN city rates unless one is implausible (-2% to +7% a year)
- Custom Location, and the city scenario's waste and diversions

Climate TRACE's paths are unchanged; they pass their own pop_data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HughRunyan HughRunyan added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs test Adds or modifies tests labels Sep 30, 2026
…blish

Review fixes for #71:
- Countries are found by exact code or name before the fuzzy search, which
  turned "MUS" into Turkey (province Mus) and "Niger" into Nigeria. That now
  mattered, because the code picks the population series.
- CityParameters keeps the city's own two rates as the loader read them
  (city_growth_rate_*). WasteMAP's map build republishes those, so the city
  tool re-running _city_growth on the table reaches the same choice.
- A custom site's prefill starts the rate from the country's population
  projection, not the 2019 default table.
- The growth constructors call growth_factors_for_years once each instead of
  keeping parallel series/scalar branches (bit-identical on 1,584 cases);
  DivsDF.create_simple computes the factors once, not per stream.
- constants.py names both copies of the population table.
- The changelog bullet links its PRs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HughRunyan
HughRunyan merged commit d5c592e into main Sep 30, 2026
2 checks passed
@HughRunyan
HughRunyan deleted the waste-grows-with-the-uns-yearly-population branch September 30, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs test Adds or modifies tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant