Skip to content

Modeled landfills use measured site oxidation when available#34

Open
HughRunyan wants to merge 4 commits into
mainfrom
ers-update
Open

Modeled landfills use measured site oxidation when available#34
HughRunyan wants to merge 4 commits into
mainfrom
ers-update

Conversation

@HughRunyan

@HughRunyan HughRunyan commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Modeled landfills previously always received a type/gas-capture default oxidation factor (sanitary 0.10 no-capture / 0.22 with capture; controlled dump 0.05/0.10; dumpsite 0). The Climate TRACE waste-methane pipeline's input query carries a per-site oxidation column (populated for ~19% of sites from the standardized source table; NULL for the GPW/OSM area-matched branch) that was never read. This wires it in.

What changed

site_only_estimate_trace and citysite_estimate_trace now prefer the input oxidation over the default, via a new _build_oxidation_series(default, canonical_row, time_series_rows, years_range) helper:

  • Site-wide mean of the non-null input values as the full-series baseline, then a per-year overwrite (mean of conflicting same-year rows) keyed by reported_emissions_year where present — mirrors the existing gas_collection_efficiency handling one block below.
  • No input → the prior type/gas-capture default, broadcast across all years (unchanged for the ~81% of sites without a measured value).
  • Values are used as-is (no clamping) — a measured 0.35 passes through; the 0.25 biocover clamp is dead code (doing_fancy_ox is hardcoded False) and does not apply here.

The legacy WasteMAP builders (site_only_estimate, sinar_city_and_site) are intentionally left on defaults — they use a different row schema and are not on the Climate TRACE modeled-site path.

Model-output change (not breaking)

Emissions shift for the ~19% of sites with a measured oxidation; higher oxidation destroys more CH₄, so those sites model lower emissions. No API/schema/contract change.

Testing

  • New RMI_Climate_TRACE_Waste_Methane/tests/manual/test_input_oxidation.py: helper logic (mean baseline, per-year overwrite, conflicting-same-year averaging, unclipped 0.35, out-of-range years, no-input fallback) + end-to-end baseline (default 0.10 / 0.22, input 0.35 propagates, higher oxidation lowers emissions).
  • SWEET test suite (86) and the RMI manual mitigation suite (106) pass against this change.

Definition of done

  • Input oxidation preferred over the type/gas-capture default; default retained as fallback.
  • Tests pass (SWEET suite; RMI manual + smoke/unit).
  • Reviewed & merged (paired with the RMI PR below).

Paired PR

Consumed by RMI/RMI_Climate_TRACE_Waste_Methane#74 (same ers-update branch), which carries the value through to the mitigation stage and adds max(existing, new) oxidation semantics to the ERS strategies.

Flaring baseline (added — explicit default)

Also sets each modeled landfill's flaring destruction efficiency explicitly to dst_common.DEFAULT_FLARE_EFFICIENCY (0.98) in site_only_estimate_trace / citysite_estimate_trace, instead of leaving it unset and relying on model_v2's internal default. There is no per-site flaring-efficiency source (only flared volumes + a has_flaring boolean), so 0.98 is the canonical default; mitigation raises it to 0.98/0.99 for the few improve-GCCS strategies via _gccs_flaring's floor (max/clip). No TRACE output change — numerically identical to the prior monthly default. model_v2's annual-vs-monthly default inconsistency (1.0 vs 0.98) was left untouched (TRACE never uses the annual path; changing it would shift WasteMAP output).

🤖 Generated with Claude Code

Review responses (Copilot / andre)

  • The default-broadcast fallback in _build_oxidation_series is intentional, and now documented (de1ef58). It serves callers whose input frame carries no per-year oxidation column — the older city DST / make_cities_table path, which predates per-year oxidation and supplies a single baseline value. The Climate TRACE sites and cities pipelines both SELECT oxidation into their multi-row frames, so measured oxidation is used there; this only defaults when the column is genuinely absent. (This "time-series for sites / single value for cities" switch is the reason several isinstance(..., Series/DataFrame) branches exist here.)
  • Single-row time_series_rows (a Series) is now honored (7e7d1ef): the branch chain previously skipped it and fell to canonical_row. Added the Series branch so a single-row site's own time_series_rows oxidation is used, matching the docstring. Harmless in the TRACE pipelines (multi-row DataFrame path, or canonical_row carries the same value), but removes the code/docstring mismatch Copilot flagged.

Merge note

Deploy pairs with RMI/RMI_Climate_TRACE_Waste_Methane#74 by branch name (ers-update). Merge/land the two together.

Previously every modeled landfill got a type/gas-capture default oxidation
(sanitary 0.10 no-capture / 0.22 with capture; controlled dump 0.05/0.10;
dumpsite 0). The pipeline input query carries a per-site `oxidation` column
(populated for ~19% of rows from the standardized source table, NULL for the
GPW/OSM area-matched branch) that was never read.

site_only_estimate_trace and citysite_estimate_trace now prefer that input
value over the default via a new _build_oxidation_series helper:
- site-wide mean of non-null input values as the full-series baseline, then a
  per-year overwrite (mean of conflicting same-year rows) keyed by
  reported_emissions_year where present -- mirrors the existing
  gas_collection_efficiency handling;
- no input -> the prior type/gas-capture default, broadcast across all years;
- values used as-is (no clamping); the dead 0.25 biocover clamp does not apply.

model-output-change: emissions shift for the ~19% of sites with a measured
oxidation. Not a breaking change (schemas/contracts unchanged).

Paired with RMI_Climate_TRACE_Waste_Methane ers-update.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@HughRunyan HughRunyan added model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs enhancement New feature or request labels Jul 10, 2026
The modeled baseline previously left each landfill's `flaring` unset, so it fell to
model_v2's internal default (0.98 in the monthly path used by TRACE). There is no
per-site flaring-efficiency source column (the source has only flared volumes and a
has_flaring boolean), so no per-site value can be read.

site_only_estimate_trace and citysite_estimate_trace now set flaring explicitly to
dst_common.DEFAULT_FLARE_EFFICIENCY (0.98) on every TRACE landfill, so the value no
longer depends on model internals. A function-local import is used because dst_common
imports city_params (a top-level import would be circular).

No TRACE output change: baseline flaring was already effectively 0.98 via the monthly
default, so this is numerically identical. Mitigation still raises it to 0.98/0.99 for
the few improve-GCCS strategies via _gccs_flaring's floor (max/clip).

Deliberately NOT touched: model_v2's default handling. The annual estimate_emissions2
defaults unset flaring to 1.0 vs the monthly estimate_emissions_monthly's 0.98 -- a real
inconsistency, but TRACE/mitigation only use the monthly path, and changing the annual
default would shift WasteMAP/DST output. Left as a separate, optional cleanup.

Paired with RMI_Climate_TRACE_Waste_Methane ers-update.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the Climate TRACE modeled-landfill path to (1) prefer per-site input oxidation factors when provided by the input query and (2) explicitly set baseline flaring destruction efficiency to the project’s canonical default, avoiding reliance on model_v2 internal defaults.

Changes:

  • Introduces _build_oxidation_series(...) to construct a per-year oxidation factor series from input data (with fallback to the existing type/gas-capture defaults).
  • Wires the resulting oxidation series into site_only_estimate_trace and citysite_estimate_trace.
  • Sets flaring explicitly to dst_common.DEFAULT_FLARE_EFFICIENCY for TRACE-modeled landfills.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SWEET_python/city_params.py
HughRunyan and others added 2 commits July 13, 2026 12:23
…_series

The default-broadcast fallback when the input frame lacks a per-year 'oxidation'
column is deliberate: it supports older callers (city DST / make_cities_table)
that predate per-year oxidation. The Climate TRACE sites and cities pipelines both
SELECT oxidation into their frames, so measured oxidation is used there. Comment
only; no behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot #34: the docstring says time_series_rows is a Series for single-row sites,
but the branch chain skipped it and fell to canonical_row. Add the Series branch so
a single-row site's own time_series_rows oxidation is used (matches the documented
contract). Harmless in the Climate TRACE pipelines (multi-row DataFrame path, or
canonical_row carries the same value), but removes the code/docstring mismatch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants