sdst honors the caller-supplied gas flaring efficiency - #41
Open
HughRunyan wants to merge 2 commits into
Open
Conversation
City.sdst_v1_5 declared a `new_landfill_flaring` parameter but its flaring block referenced an undefined bare name `flaring`. The resulting NameError was swallowed by a bare `except`, which forced flare destruction efficiency to a hardcoded 0.98 on every call — so the flaring efficiency forwarded by the WasteMAP /v1/site_emissions/sdst_v1_5 endpoint (the "Gas flaring efficiency" control) never affected results. Read `new_landfill_flaring[scenario_key][0]` instead (sdst models a single landfill, index 0), fall back to DEFAULT_FLARE_EFFICIENCY only when no value is supplied, and drop the bare `except` so real errors are no longer masked. Model-output change: any sdst run that set a non-0.98 flaring efficiency, with gas capture on so there is captured methane to flare, now produces different and correct results. Verified end-to-end through the WasteMAP endpoint: with gas capture at 0.75, flaring 0.0 vs 0.98 returned an identical 6648.34 total before this change and 23422.34 vs 6648.34 after it. Runs that left flaring at the default are unchanged. The newer adst endpoint already handled flaring correctly and is unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
andrewmilligan
approved these changes
Aug 6, 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.
City.sdst_v1_5declared anew_landfill_flaringparameter but never read it. Its flaring block referenced an undefined bare nameflaring, and the resultingNameErrorwas swallowed by a bareexceptthat forced flare destruction efficiency to a hardcoded0.98. The flaring efficiency forwarded by WasteMAP's/v1/site_emissions/sdst_v1_5endpoint — the/sdst"Gas flaring efficiency" control — therefore never affected results.Environment
SWEET_python/city_params.py,City.sdst_v1_5/v1/site_emissions/sdst_v1_5(backend/sweet_launch.py), which passes itsflaringBody param asnew_landfill_flaring=flaringadstpath is not affectedReproduction
Call
/v1/site_emissions/sdst_v1_5twice with gas capture on (so there is captured methane to flare), changing only the flaring efficiency:gas_efficiencies: {"baseline": [0.75], "scenario": [0.75]}flaring: {"baseline": [0.0], "scenario": [0.0]}(no flaring)flaring: {"baseline": [0.98], "scenario": [0.98]}(full flaring)Expected vs actual
Summed total emissions across all modeled years:
0.0— no flaring0.98— full flaringActual (before): both runs return an identical
6648.34— the input is discarded and flaring is always0.98.Expected (after): no flaring produces materially higher emissions, since captured methane is vented rather than destroyed.
Root cause
flaringis not defined in this scope; the method's parameter isnew_landfill_flaring. Every call took theexceptbranch.The fix
Read
new_landfill_flaring[scenario_key][0](sdst models a single landfill, index0), fall back toDEFAULT_FLARE_EFFICIENCYonly when no value is supplied, and drop the bareexceptso genuine errors surface instead of silently degrading to a default.Acceptance criteria
City.sdst_v1_5reads the caller-suppliednew_landfill_flaringfor both baseline and scenario.implement_yearonward; the baseline value applies before it.None), behaviour is unchanged:DEFAULT_FLARE_EFFICIENCY(0.98).exceptmasking errors in this block.Model-output change
Labelled
model-output-change, notbreaking-change: nothing stops running and no data contract changes. Any/sdstrun that set a non-0.98 flaring efficiency with gas capture on will now return different — correct — numbers. Runs that left flaring at the default are unchanged, as are alladstruns.Notes for the reviewer
backend/requirements.txttracks SWEET_pythonmainunpinned, so WasteMAP picks this up automatically once merged — no pin bump needed.changelog/2026-08.mdand achangelog/README.mdentry. Whichever merges second should combine the two — WP-419 adst callers can set site depth and override the decomposition rate (k) #40's entry is under Added, this one is under Fixed, so they slot together without rewording.Definition of Done
🤖 Generated with Claude Code