Repository navigation
Moving waste to a city's existing gas capture changes its emissions - #75
Open
HughRunyan wants to merge 3 commits into
Open
HughRunyan wants to merge 3 commits into
HughRunyan wants to merge 3 commits into
Conversation
The City DST's "move waste to existing gas capture" lever (move_gas and existing_gas_pct in implement_dst_changes_simple_v1_5) rewrote split_fractions in the generic branch but never passed the split to the landfills, whose waste comes from their own fraction_of_waste. Only the new-landfill-with-capture block did that, and WasteMAP switches that lever off for every city it offers this one to. So the slider returned the no-change scenario at every setting for all 7 cities in the June 2026 table where it is live. The arithmetic was wrong too: it multiplied the shares without capture by existing / original, scaling them up (Lahore's landfill without capture came out at 171% of its waste) and zeroing them for a city with no capture. _move_to_existing_gas_capture gives capture existing_gas_pct and the landfill and dumpsite without capture the rest, in their original proportions, and the scenario applies that split to the landfills. A request the lever can't carry out raises INVALID_PARAMETERS. The new-landfill sum check now builds CustomError with both arguments; it raised TypeError, a 500 at the API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 9, 2026
"Add gas capture" losing the oxidation it sets is fixed in #78 (with RMI/WasteMAP#856), so this changelog no longer lists it as a known limitation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 of 6 tasks
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.
Bug
The City DST's "% of waste diverted to existing landfill with gas capture" slider (
move_gas,existing_gas_pctinCity.implement_dst_changes_simple_v1_5) did nothing. At every setting it returned the no-change scenario exactly.Environment: SWEET_python
mainat d5c592e, the generic branch ofimplement_dst_changes_simple_v1_5(if not scenario_parameters.sites_method:). WasteMAP/v1/city_emissions/implement_dst_simple_v1_5, with the June 2026 cities table (cities_for_map_0626.csv) andload_cityreplicated offline.Reproduction: load Lahore (34.4% of disposal to landfills with gas capture). Run the scenario twice with its own diversions and
implement_year=2026: once withmove_gas=0, once withmove_gas=1, existing_gas_pct=0.9.Expected: moving waste from the landfill without capture to the one with it lowers emissions after 2026.
Actual: both give 92,872 t CH₄ in 2040. The scenario's
split_fractionscame out as 0.9 / 1.714 / 0, and the landfills kept 0.344 / 0.656 / 0. Mexico City (2.3%) gave 0.9 / 38.48 / 0, also with no change. The same no-op held for all 7 cities in the June table where the slider is live (0 < share < 99%): Mexico City, Lahore, Santiago, Amman, Tegucigalpa, Cebu City, Tunis.Root cause
LandfillWasteMassDF.createreads each landfill'sfraction_of_waste. Only theif new_gas_pct > 0:block copiedsplit_fractionsthere. WasteMAP's frontend offers this slider only to a city that already captures gas, and disables "new landfill with gas capture" for exactly those cities (useChartData.ts), so the two never ran together.existing_gas_pct, then multiplied the shares without capture byexisting / original, scaling them up. With no capture to start from, it zeroed them. Combined withnew_gas_pct, the inflated split failed its sum check, and that check builtCustomErrorwith one argument, so it raisedTypeError(an API 500).Fix
_move_to_existing_gas_capture(split_fractions, existing_gas_pct)gives captureexisting_gas_pct. The landfill and dumpsite without capture take the rest,1 − existing_gas_pct, in the proportions they had.move_gasblock applies that split tolandfills[0..2].fraction_of_waste. As with every lever, years before the implementation year are still copied from the baseline.INVALID_PARAMETERS(400 at the API) instead of silently returning the no-change scenario:CustomError("INVALID_PARAMETERS", …).Model output (
model-output-change)2040 emissions against the no-change scenario, on the June table:
Before the fix every cell was 0%.
Unchanged, bit for bit: the no-change scenario and every request with
move_gas=0(all other levers), plus all 41 cities at 100% for everything the UI sends.Visible side effect in WasteMAP: an untouched slider sends the city's share rounded to a whole percent. So Lahore's default scenario now sits 0.35% above its baseline in 2040, Tegucigalpa's 0.25% below, and Santiago, Mexico City and Tunis move less than 0.2%. The diversion sliders already round the same way: Mexico City's untouched scenario was 0.72% below its baseline before this fix.
Fixed separately: "Add gas capture" loses its oxidation settings
In the same generic branch,
add_gassets oxidation to 0.22 for the landfill without capture and 0.1 for the converted dumpsite after the implementation year, and an override at the end of the method reset both to the no-capture defaults. That is fixed in #78 (with RMI/WasteMAP#856), so the Known limitations entry this PR added tochangelog/2026-10.mdhas been dropped (f69fdac).Tests
tests/test_move_to_existing_gas_capture.py: 16 tests. They build a city from country defaults (dst_baseline_blank) with a 30/50/20 split and run the realimplement_dst_changes_simple_v1_5, with no database.main, each on the defect: no emissions change, the landfills keep the baseline split, Lahore's split comes out 0.9 / 1.714 / 0,TypeErrorwithnew_gas_pct, and no error for impossible requests.mainis the guard that a city's own share reproduces the no-change scenario.The WasteMAP side, RMI/WasteMAP#854 (same branch name, so its CI installs this branch), adds an endpoint test on Lahore's real table row through
load_city. Two of its four tests fail againstmainhere. Merge this PR first. WasteMAP CI falls back to SWEET_pythonmainonce this branch is gone, so RMI/WasteMAP#854 is green onmainonly after this lands.Acceptance criteria
move_gas=1with a share different from the city's own changes emissions from the year after implementation, and never before it.existing_gas_pct. The landfill and dumpsite without capture share the rest in their original proportions, and the split sums to 1.move_gas=0, and the 41 cities at 100% give the same results as before.INVALID_PARAMETERSrather than a silent no-op or a 500.changelog/2026-10.md), cross-linked with WasteMAP's backend changelog.Definition of done
tests/fastagainst this branch: 580 passed, 1 skipped)🤖 Generated with Claude Code