Repository navigation
The City DST's "add gas capture" applies the oxidation it sets - #78
Open
HughRunyan wants to merge 2 commits into
Open
HughRunyan wants to merge 2 commits into
HughRunyan wants to merge 2 commits into
Conversation
In the generic branch of implement_dst_changes_simple_v1_5, add_gas gives the landfill without capture an oxidation factor of 0.22 after the implementation year and the dumpsite it converts to a controlled dumpsite 0.1, and sets skip_ox = True to keep them. The emissions loop at the end replaced that with skip_ox = scenario_parameters.sites_method, which is false on this branch, so Landfill.estimate_emissions reset both from gas_capture (still False) to 0.1 and 0: the gas capture applied, the oxidation never did. Each branch now sets skip_ox itself and the loop uses it; the real-sites branch keeps True. Every add_gas result falls another 10.0-13.3% after the implementation year; a city that landfills everything goes from -60.0% to -65.3% against no change in 2040. Across WasteMAP's June 2026 table and a Custom Location in every country, the no-change scenario, the other levers and every year up to the implementation year are bit-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HughRunyan
added a commit
that referenced
this pull request
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>
This was referenced Oct 9, 2026
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 "Add gas capture" lever (
add_gasinCity.implement_dst_changes_simple_v1_5) applied the gas capture it adds but not the oxidation it sets.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 Lima (all disposal to a landfill without gas capture, no diversion). Run the scenario with
implement_year=2026, once withadd_gas=0and once withadd_gas=1.Expected: after 2026 the landfill captures 60% of its methane and oxidises 22% of the rest instead of 10%. Emissions are the no-change scenario's × 0.4 × 0.78 / 0.9 = 0.347, i.e. 65.3% lower.
Actual: × 0.4, i.e. 60.0% lower: 30,393 t CH₄ in 2040 instead of 26,341. After the run, the landfill's
oxidation_factoris the scalar 0.1 and the dumpsite's is 0, in every year.Root cause
After the implementation year,
add_gasgives the landfill without capture 60% gas capture and an oxidation factor of 0.22. It converts the dumpsite to a controlled dumpsite with 30% capture and 0.1. Then it setsskip_ox = Trueso thatLandfill.estimate_emissionskeeps those factors. The emissions loop at the end of the method overwrote that:With
skip_ox=False,estimate_emissionsresets every non-advancedlandfill's oxidation factor from itsgas_captureflag (ox_cap/ox_nocap).add_gasnever sets that flag, so the converted sites got the no-capture defaults: 0.1 for the landfill and 0 for the dumpsite. Both lines date from the repository's first commit (2c5db07).Are 0.22 and 0.1 the right values?
Yes. I found no reason they shouldn't apply.
estimate_emissions'ox_captable gives alandfill0.22 and acontrolled_dumpsite0.1, and so doesdefaults_2019.oxidation_factor["with_lfg"]. The real-sites branch of this method also gives a sanitary landfill 0.22 when it adds capture.add_gaskeeps the no-capture defaults (0.1 and 0) through the implementation year. So nothing moves before it, and the converted sites are a capped landfill and a controlled dump only from the year their capture starts.Fix
Each branch sets
skip_oxitself, and the emissions loop uses it:False, orTruewhenadd_gashas set its oxidation factors (as it already did)True(what it got before, fromsites_method)The overwrite is gone. Real sites are
advancedand keep the oxidation they carry whateverskip_oxsays.skip_oxmatters on that branch only for the generic landfills that WasteMAP's Brazilian rows bring there; see RMI/WasteMAP#851.Model output (
model-output-change)Measured over WasteMAP's June 2026 cities table (5,689 city names) and a Custom Location in each of 249 countries (2 million people, 500 mm, 25 °C). Each scenario uses the city's own diversions with gas capture added in 2026, compared before and after this change.
2040 emissions against the no-change scenario:
add_gasresult falls another 10.0–13.3% in 2040 (median 13.3%). That is 13.3% for a landfill (0.78 / 0.9) and 10.0% for a dumpsite (0.9 / 1).no_landfills_present), but the API runs it.load_citystill sends them down the real-sites branch, whereadd_gaschanges nothing for generic sites. With RMI/WasteMAP#851'sload_city, 4,622 of the 4,627 that run move by 10.0–13.3%; the other 5 model zero emissions.add_gasresult up to and including the implementation yearadd_gas, whoseskip_oxis what it wasClimate TRACE's pipeline doesn't call this method, so its outputs do not move.
Tests
tests/test_add_gas_capture_oxidation.py: 12 tests. They build a city from country defaults (dst_baseline_blank) with a 0/50/50 split, as intests/test_move_to_existing_gas_capture.py(#75), and run the realimplement_dst_changes_simple_v1_5, with no database.main, each on the defect:skip_ox=Falsewithadd_gasmainare guards: the no-change scenario keeps the default oxidation and reproduces the baseline's landfill emissions, and each branch passes theskip_oxit should (the generic branch withoutadd_gas, and the sites branch with and without it).The WasteMAP side, RMI/WasteMAP#856 (same branch name, so its CI installs this branch), adds an endpoint test on Lima's table row through
load_city. It fails againstmainhere and passes against this branch. Merge this PR first.changelog/2026-10.mddoesn't exist onmainyet. #73, #74, #75 and this PR each create it, so whichever merges later resolves a changelog conflict; the code merges cleanly with all three. #75 documented this bug as a known limitation; I've removed that entry from #75, so no merge order leaves it behind.Acceptance criteria
add_gas, the landfill without capture oxidises at 0.22 and the converted dumpsite at 0.1 from the year after implementation, and at 0.1 and 0 up to and including it.add_gas, and every year up to the implementation year are bit-identical to before.skip_ox=True.changelog/2026-10.md), cross-linked with WasteMAP's backend changelog; the known-limitation entries in Moving waste to a city's existing gas capture changes its emissions #75 and RMI/WasteMAP#854 are removed.Definition of done
tests/fastagainst this branch: 577 passed, 1 skipped)🤖 Generated with Claude Code