Implement print to excel for PR3#463
Conversation
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
36c1a36 to
cb4e7d7
Compare
bl-young
left a comment
There was a problem hiding this comment.
My main concern with this approach is unintended opportunities for drift or deviation from the core pipeline given that this script to some extent hard codes some of the derivation. How different would it be to use the existing publish tools to get out what you need across 2 or 3 model configs?
There was a problem hiding this comment.
This feels like something that doesn't need additional tests
|
|
||
|
|
||
| def assert_disaggregation_export_config() -> None: | ||
| """Require waste + reallocation + disaggregation flags (mirrors USAConfig validator).""" |
There was a problem hiding this comment.
is this necessary to have this again? wouldn't this be covered already?
The main driver for this decision was to keep all the printing and analysis pathing independent from the core pipeline and contained within A secondary consideration was ease of review for this PR vs #463 by avoiding any confusion on which printing was related to which PR. What I'd propose is once #463 is merged, then we can re-work this PR to use existing publish tools. Would this be an acceptable course of action? |
cb4e7d7 to
41e9b43
Compare
8218c3f to
10187f4
Compare
41e9b43 to
98e9e49
Compare
98e9e49 to
9820d15
Compare
53cccd9 to
8920451
Compare
a1f6655 to
f5271c7
Compare
93416b2 to
f31e667
Compare
f5271c7 to
5189c68
Compare
f31e667 to
309998f
Compare
5189c68 to
ff7e43e
Compare
309998f to
669acb4
Compare
ff7e43e to
03cd4d0
Compare
669acb4 to
120547f
Compare
03cd4d0 to
7f6de22
Compare
WesIngwersen
left a comment
There was a problem hiding this comment.
Successfully generated electricity_pipeline_stages_V_U_Y.xlsx

cc:
Closes:
What changed? Why?
Adds a new analysis module for exporting three-stage electricity pipeline matrices (V, extended U, and Y) at each checkpoint — after waste disaggregation, after electricity reallocation, and after electricity disaggregation — to an Excel workbook for offline PR3 inspection.
The
disaggregation_matrices.pymodule introduces aPipelineStagedataclass to hold per-checkpoint tables, a_build_stage_tables()function that replicates the waste → reallocation → disaggregation pipeline read-only, andwrite_electricity_disaggregation_intermediate_outputs()which writes a 16-sheet workbook alongside GO weight and disaggregation weight CSVs. Anelectricity_balancesheet is included to verify preservation of key metrics (gross output, commodity totals, value added, final demand) across the reallocation → disaggregation boundary.A CLI entry point (
write_221100_disaggregation_matrices.py) is provided to invoke the export with a config YAML that has all three pipeline flags enabled. Generated output files are excluded from version control via.gitignore.Testing
Unit tests cover:
assert_disaggregation_export_configraises when any required flag is disabledwrite_electricity_disaggregation_intermediate_outputswrites the expected Excel workbook with all 16 sheets and both CSV files, and confirms the aggregate electricity sector (221100) is absent from the post-disaggregation V matrix_build_electricity_balance_summarycorrectly computes a zero delta and passing check for gross output row_derive_y_after_waste_disaggdoes not call the electricity row split function and preserves the aggregate electricity sector in the output index