Repository navigation
A place's population by year can be worked out once and handed back to SWEET - #91
Merged
Merged
Conversation
…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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks done
There was a problem hiding this comment.
🟡 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_newuse 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
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>
4 tasks done
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.

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_growthalready 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_growthwould 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 throughpopulation_series. The WasteMAP PR that uses this follows once this is released.Numbers
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
population × rate^(year − population year)on each side; any other city's ispopulation × P_country(year) / P_country(population year).load_csv_newgrows 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.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