Gas-capture flag gates the site-type default in both trace paths - #68
Open
HughRunyan wants to merge 1 commit into
Open
HughRunyan wants to merge 1 commit into
HughRunyan wants to merge 1 commit into
Conversation
`site_only_estimate_trace` and `citysite_estimate_trace` carried copies of the gas-capture logic and the copies drifted. The citysite copy applied the site-type default (0.60 / 0.45 / 0.0) with no check on `landfill_gas_collection`, while still reading that same flag to pick `ox_cap` vs `ox_nocap`. So a city-linked landfill was built with `gas_capture=False` and `gas_capture_efficiency=0.6` on the same object. On the 10_05_26 submission that hit 1,994 sites: every Brazilian city-linked asset and nothing else. 959 controlled dumpsites at 0.45 and 1,035 sanitary landfills at 0.60, all flagged False. Mexico's 1,938 equally-unverified False sites ran at zero, because they take the site_only path. Same history as the MCF table, same fix. `_resolve_gas_capture` is now the single definition of the rule and both methods call it; `GAS_EFF_OPTIONS` and `OX_OPTIONS` move to module level and the two per-method copies are deleted. `site_only`'s semantics are preserved exactly. citysite additionally picks up the pd.NA guard (its `== True` raised "boolean value of NA is ambiguous" on a null flag) and the empty-gascap_df fallback. The copies in `sinar_city_and_site` and `site_only_estimate` are untouched -- neither is on the Climate TRACE path. Model output moves: Brazil's modelled FOD rises ~2.34x on those 1,994 sites, about +879 kt CH4 in 2024. Their published uncertainty also rises, from 0.254 to ~0.446, because `uncertainty.py` already assumed the gated behaviour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
landfill_gas_collectionnow gates the site-type gas-capture default in both trace paths, not just one. A site with no recorded collection system is modelled at zero capture wherever it lives.The defect
site_only_estimate_traceandcitysite_estimate_tracecarried copies of the gas-capture logic and the copies drifted. The citysite copy applied the site-type default (0.60 / 0.45 / 0.0) with no check on the flag, while still reading that same flag to pickox_capvsox_nocap. The resultingLandfillwas internally contradictory — constructed withgas_capture=Falseandgas_capture_efficiency=0.6on the same object.The rule it broke is not invented here. Two modules already state it:
build_gas_capture_rates.classify_assets— "gccs NaN & lgc True→ has a system, efficiency unknown. Emphatically NOT zero";False→ a genuine 0.uncertainty.recovery_and_oxidation_components— "Mirror SWEET's gate, not just its tables: city_params.py applies the site-type capture default ONLY when gas-capture presence is true."Reproduction
10_05_26 submission archive, run_id
20260921T231117Z, SWEET1c98d59(city_params.pybyte-identical tomain, so this is the code that ran). Joinsite,site_yearandcity_site_yearonasset_identifieratyear = 2024:Falseox_nocap)Falseox_nocap)Trueox_cap)False/NULLExpected: capture 0 wherever the flag is not a yes.
Actual: 1,994 sites at 0.45/0.60 while flagged
False. Every one is city-linked; nothing outside that set is affected.The symmetry is the argument:
Falseis an unverified default in both Brazil and Mexico (the repo's own diagnostic says so), yet Brazil's 1,994 ran with full capture and Mexico's 1,938 ran at zero — decided only by whether the site is attached to a city record.There was also a latent crash.
citysite'sgas_capture_presence == TrueraisesTypeError: boolean value of NA is ambiguouson a null flag; it has not fired only because all 3,886 city-linked assets carry a realTrue/False.The fix
Same history as the MCF table, same fix: one definition, two callers.
_resolve_gas_captureis now the single home of the rule; both methods call it.GAS_EFF_OPTIONS/OX_OPTIONSmove to module level; the two per-method copies are deleted.site_only's semantics are preserved exactly.citysiteadditionally picks up thepd.NAguard and the empty-gascap_dffallback.sinar_city_and_siteandsite_only_estimateare untouched — neither is on the Climate TRACE path.Expected change in output
Derived by rescaling the archive against
emissions = ch4 * (1 - gce*0.98) * (1 - ox); not yet confirmed by a run.uncertainty.pyalready assumed the gated behaviour and was therefore charging no recovery-error termLabelled
model-output-change, notbreaking-change: nothing stops running, the numbers move.Acceptance criteria
False,None,NaN,pd.NA,0,"No") yields zero capture in both pathsox_capgas_collection_efficiencystill overrides the flag in both directionsreported_emissions_yearfalls back to the gated default, not NaN_tracemethod keeps its own copy of the tables (guard test)site_only's behaviour is unchangedDefinition of Done
GAS_CAPTURE_LINKAGE.mdin the pipeline repo carries the full investigationPairing
Must be merged and run with RMI/RMI_Climate_TRACE_Waste_Methane branch
the-gas-capture-flag-gates-the-default, which carries the investigation write-up and the companion skiptop fixes.🤖 Generated with Claude Code