Skip to content

A place's population by year can be worked out once and handed back to SWEET - #91

Merged
HughRunyan merged 4 commits into
mainfrom
population-trajectories
Oct 20, 2026
Merged

HughRunyan merged 4 commits into
mainfrom
population-trajectories

Conversation

@HughRunyan

Copy link
Copy Markdown
Collaborator

Output

SWEET can work out a place's population by year once, and grow a city's waste along that stored series later:

  • city_params.city_population_trajectory(iso3, population_year, population, historic, future, city_points=None) returns a city's population in people for every model year (1970–2050), and what its shape comes from:

    • "UN city rates": a UN-listed city (300,000+ people, plausible rates) compounds its own two rates either side of its population year;
    • "country curve": any other city follows its country's WPP2024 population, year by year.

    This is the choice _city_growth already makes, so nothing it returns is new.

  • city_params.country_population_trajectory(iso3) returns a country's WPP population in people. For the 12 places WPP has no series for (ALA, ATA, ATF, BVT, CCK, CXR, HMD, IOT, NFK, PCN, SGS, UMI), it returns the fallback rates a Custom Location there grows by ("country fallback rates"). Those places have no population to give it, so that trajectory is 1.0 in 2022. Kosovo has a WPP series (XKX).

  • City.load_csv_new(..., population_series=) grows a city along a stored trajectory instead of the one _city_growth would pick now. The two growth rates it reports are unchanged.

  • city_points ({year: people}, the UN's own points for one city) is where full UN city trajectories come in later. It grows at a constant rate between neighbouring points. Nothing passes it yet.

  • dst_baseline_blank's fallback constants become module constants (FALLBACK_GROWTH_RATE_*, CUSTOM_LOCATION_POPULATION_YEAR). The values are the same.

Why

WasteMAP's cities stage and its API each re-ran _city_growth, so a SWEET pin change could make the city DST grow a city differently from the build behind it (#71 / WasteMAP #839 did). WasteMAP now stores each build's trajectories and hands them back through population_series. The WasteMAP PR that uses this follows once this is released.

Numbers

  • No number moves in SWEET: nothing calls the new argument by default.
  • A stored trajectory handed back grows a city as SWEET would have, to within ~1e-15 relative, not to the bit. SWEET's growth factor is series[year] / series[population year]. With the series in people, about 8% of city-years have no stored float that divides back to exactly the old factor (checked over WasteMAP's 0626 table, ±5 ULP). Storing growth factors would be exact; WasteMAP stores people by decision.

Acceptance criteria

  • A big city's trajectory is population × rate^(year − population year) on each side; any other city's is population × P_country(year) / P_country(population year).
  • load_csv_new grows a city along the series it is handed: a flat series stops its growth, and the stored series matches SWEET's own to 1e-14.
  • Every country SWEET knows has a trajectory; a Custom Location in a country without WPP grows exactly along the fallback trajectory.
  • Changelog updated.

Definition of Done

Acceptance criteria met · tests pass (pytest -m "not integration": 568 passed) · changelog updated · reviewed & merged · then a release (sweet/2026.10.4) for WasteMAP to pin.

🤖 Generated with Claude Code

…o SWEET

city_population_trajectory and country_population_trajectory give a city's or a
country's population in every model year, with what its shape comes from, and
load_csv_new takes a stored trajectory as population_series. WasteMAP's map build
stores them so its city DST grows a city the way the build did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HughRunyan HughRunyan added the enhancement New feature or request label Oct 20, 2026
HughRunyan and others added 2 commits October 20, 2026 08:40
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Rounding exported populations changes SJM’s growth ratios instead of preserving the existing country curve.

1 open issue
What changed in this PR

Adds reusable population trajectories so WasteMAP can store growth curves and pass them back to SWEET.

Changes:

  • Adds city and country trajectory helpers.
  • Lets load_csv_new use a stored population series while preserving reported growth rates.
  • Shares fallback constants and adds regression tests and release notes.
File Description
tests/​test_population_trajectory.py Tests trajectory generation and stored-series growth.
SWEET_python/​city_params.py Adds trajectory APIs, stored-series input, and shared constants.
changelog/​2026-10.md Documents trajectory storage and reuse.

Review effort: Balanced

Comment thread SWEET_python/city_params.py Outdated
Rounding to whole people bent the curve of the few places WPP interpolates
(Svalbard and Jan Mayen: 2,591.78 people in 2022, the 1975/2022 ratio off by
0.03%), so a Custom Location there would not grow as dst_baseline_blank does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HughRunyan
HughRunyan merged commit bde963b into main Oct 20, 2026
2 checks passed
@HughRunyan
HughRunyan deleted the population-trajectories branch October 20, 2026 16:29
HughRunyan added a commit that referenced this pull request Oct 20, 2026
…ed-country

#91/#92 were squash-merged, so the base's own files are taken from origin/am-waste-flow and
only this branch's Custom Location change is kept on top.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HughRunyan added a commit that referenced this pull request Oct 20, 2026
#91/#92 were squash-merged, so the base's own files are taken from origin/main and
only this branch's Custom Location change is kept on top.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants