Skip to content

implement analysis for decisions 3, 5, and 7 in dicussion #85#481

Open
jvendries wants to merge 7 commits into
jv_print_electricity_PR3_to_excelfrom
jv_PR3_decisions_analysis
Open

implement analysis for decisions 3, 5, and 7 in dicussion #85#481
jvendries wants to merge 7 commits into
jv_print_electricity_PR3_to_excelfrom
jv_PR3_decisions_analysis

Conversation

@jvendries

@jvendries jvendries commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

cc: cornerstone-data/methods#85
Closes:

What changed? Why?

Adds a new d_85 analysis module under bedrock/analysis/electricity/ to support the methods discussion #85 resolution analysis covering Decisions 3, 5, and 7.

Decision 3 explores using EPA Table 8.3 IOU expense shares (Production/Transmission/Distribution) as an alternative to UGO305-A gross output weights for the Use-intersection step. Two variants are implemented: d8_mixed (Table 8.3 weights for the Use intersection only) and d8_offdiag (a full 3×3 absolute-dollar intersection matrix where generation columns are forced diagonal per Rules D1/D2).

Decision 5 introduces price-differentiated commodity row splits using EIA Table 2.4 retail electricity prices (cents/kWh) by end-use sector (Residential, Commercial, Industrial, Transportation). Each purchaser column is assigned an EPA end-use class via a rule-based NAICS chapter mapping, and weights are tilted by the ratio of that sector's price to the national average.

Decision 7 simulates differentiated UGO305 year-scaling by computing per-child GO ratios (generation/transmission/distribution) between the 2017 detail year and the IO target year, with a pure variant and an anchored variant that preserves the weighted mean against the Utilities summary ratio.

A derive_post_reallocation_checkpoint() helper is extracted into disaggregation_matrices.py so the stage-2 IO state (post-reallocation, pre-disaggregation) can be shared cleanly between the existing pipeline and the new scenario analysis. The existing _build_stage_tables function is updated to call this helper rather than duplicating the logic.

Each decision has a corresponding report builder that writes an Excel workbook to d_85/output/ (gitignored). A CLI entry point (run_resolution_analysis.py) accepts --decision 3|5|7|all and a config name argument.

Testing

Unit tests cover:

  • table83_go_weights normalization and ordering
  • build_ugo_col_table83_row_intersection_matrix column-sum (Rule D1) and total preservation, including a worked numeric example
  • apply_use_intersection_custom total preservation and aggregate cell zeroing
  • split_y_commodity_row_by_column aggregate row removal
  • table_8_3_gtd_expenses_musd and table_2_4_prices_cents_kwh value extraction and missing-flow error raising
  • classify_industry_end_use rule coverage and build_price_tilt_weights_by_column per-column normalization
  • compute_balance_metrics shape and zero relative error on balanced inputs; va_summary_by_scenario negative VA flagging
  • diff_ef_vectors skipping metrics_only scenarios; report_metadata key presence
  • _run_baseline parity against the production disaggregate_electricity_make_use_va path (V, Udom, Uimp, VA, Y, q, x all match within DISAGG_BALANCE_ATOL)
  • d8_mixed scenario routing Table 8.3 weights to the Use-intersection step
  • p24_2017 per-column weight normalization
  • build_ugo305_detail_ratios ratio computation and build_anchored_overrides weighted-mean preservation
  • derive_Aq_from_scenario, scenario_vnorm, and _apply_electricity_q_overrides shape and value correctness

jvendries commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@jvendries jvendries force-pushed the jv_print_electricity_PR3_to_excel branch from 5189c68 to ff7e43e Compare June 23, 2026 16:27
@jvendries jvendries force-pushed the jv_PR3_decisions_analysis branch from b0debb2 to 8233e92 Compare June 23, 2026 16:27
@jvendries

Copy link
Copy Markdown
Contributor Author

Report from the analysis on this branch can be found in this discussion_85_analysis_report.md

@jvendries jvendries force-pushed the jv_PR3_decisions_analysis branch from 92c2478 to 4686d0d Compare June 24, 2026 19:52
@jvendries jvendries force-pushed the jv_print_electricity_PR3_to_excel branch from ff7e43e to 03cd4d0 Compare June 24, 2026 19:52
@jvendries jvendries force-pushed the jv_PR3_decisions_analysis branch from 4686d0d to 584e55a Compare June 25, 2026 01:20
@jvendries jvendries force-pushed the jv_print_electricity_PR3_to_excel branch from 03cd4d0 to 7f6de22 Compare June 25, 2026 01:20
@jvendries jvendries marked this pull request as ready for review June 25, 2026 20:29
@WesIngwersen WesIngwersen added this to the v0.4 milestone Jun 29, 2026
@WesIngwersen

Copy link
Copy Markdown
Member

Report from the analysis on this branch can be found in this discussion_85_analysis_report.md

These AI-generated reports are just unreadable to an extent. This needs some human interpretation.

@WesIngwersen

Copy link
Copy Markdown
Member

I ran run_resolution_analysis successfully but I don't trust my results due to use of GHGI instead of eGRID, related to the comment i made recommending just coding for eGRID use (and the code error trying to import the flowsa package).
I would like to see the differences in use of generation after Decision 5 compared more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants