Implement industry mecs allocation - #736
Draft
jvendries wants to merge 4 commits into
Draft
Conversation
…ECS vs original). Vs-footing histograms reuse archived original and pre-MECS EIA panels; extend the pre-MECS freeze with D and class MWh so tables can fill without a live re-run.
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.

cc: cornerstone-data/methods#90
Closes:
What changed? Why?
Introduces MECS Table 7.7 purchased-kWh shares as the default weighting method for Industrial manufacturing purchasers in the EIA-anchored G/T/D electricity allocation, replacing the previous dollar-bill weighting inside manufacturing. The allocation now splits the Industrial class into two pools: manufacturing sectors (weighted by Table 7.7 kWh) and residual Industrial sectors (weighted by dollar bills). A
dollarsfallback is preserved for diagnostics and tests that must not load Table 7.7. The table was uploaded to GCS as excel and parquet FBA files.To support comparison between the new MECS-weighted path and the prior dollar-weighted path, a pre-MECS freeze is introduced under
historical/pre_mecs_industrial_weights/output/, capturing EIA G/T/D mixed-unitsqandNwith dollar manufacturing weights. Awrite_freezescript generates this snapshot, and acompare_to_pre_mecsmodule compares live MECS output against it (not a CI gate).A five-slide PPTX comparison deck (
diagnostics/deck/) is added to visualize differences across three implementation pairs: current (post-MECS) vs. EIA G/T/D pre-MECS, current vs. original electricity disaggregation, and EIA G/T/D pre-MECS vs. original. Each deck includes class MWh tables, per-step D/N EF tables withsame/N/Acell labeling, and two-row histogram panels using frozen archived PNGs where available.The
purchaser_tablesmodule is updated to renamed0_*terminology toclass_mwh_targets/class_target_mwhthroughout, add amanufacturing_mecs_vs_dollar_framefor dual-run comparison, and exposep_share_from_allocation. EIA MECS Energy extraction is extended to parse Table 7.7 (million kWh) for both 2018 and 2022 survey years, with correct unit assignment distinct from Table 7.2 (money). The 2022 MECS year is added to the raw data extraction script.Cache reset logic is extended to clear the new
mecs_purchased_kwhLRU cache alongside existing electricity caches. Existing tests that exercise the allocation path are wrapped with adollar_industrial_weightscontext manager so they do not trigger Table 7.7 loading.Testing
test_electricity_gtd_mecs.pycover MECS year mapping, NAICS overlay deduplication, 3-digit suppressed-value imputation, two-pool Industrial MWh identity, dollar-path isolation, zero-bill and zero-residual edge cases, cache mutation safety, and cache reset behavior.test_eia_mecs_energy_units.pyconfirm Table 7.7 producesmillion kWhunits and Table 7.2 continues to produceUSD / million btu.test_purchaser_tables.pycoverp_share_from_allocation,manufacturing_mecs_vs_dollar_frameflags, and the renamedclass_mwh_targets_frame.test_deck.pycover data helpers, histogram frame construction, frozen panel stacking, table grid generation, and end-to-end PPTX assembly (five slides, at least two media files).test_pre_mecs_freeze_exists.pyasserts the committed parquet files are present on disk.pytest.mark.eeio_integration) validates post-overlay NAICS presence in live Table 7.7 data for 2018 and 2022.