Skip to content

Conversation

@sherryzuo
Copy link
Collaborator

@sherryzuo sherryzuo commented Feb 9, 2026

Summary

Configures the first RI rate design scenario run (run_scenario.py) with default configs against CAIRO, including all necessary data files, utility overrides, and supporting tooling. closes #142 #143

CAIRO Overrides (utils/cairo.py)

  • return_buildingstock(): Custom metadata loader with configurable columns (DEFAULT_BUILDINGSTOCK_COLUMNS) and default weight when weight column is missing from parquet
  • _return_load(): Custom load reader for per-building parquet files where bldg_id is not the parquet index (ResStock format → CAIRO format)
  • _initialize_tariffs(): Accepts explicit tariff_paths: dict[str, Path] so tariff JSONs are loaded from project directories instead of CAIRO's internal config.TARIFFSDIR
  • get_default_tariff_structures(): Takes dict[str, Path] (tariff key → JSON path) instead of CAIRO's customer class iteration
  • build_bldg_id_to_load_filepath(): Scans load directory with optional building_ids filter to avoid loading all buildings
  • patch_postprocessor_weight_handling(): Fixes CAIRO bug where combined elec+gas bill merge loses weight column due to suffixes=("_elec", "_gas"), breaking postprocess_group.* segmented bill stats

RI Scenario (rate_design/ri/hp_rates/)

  • run_scenario.py: Full precalc run for RIE A-16 tariff with 5 prototype buildings, gas bill calculation, distribution cost params, and customer reweighting
  • Tariff structures: tariff_structure_rie_a16.json, tariff_structure_rie_a60.json, tariff_structure_dummy_gas.json
  • Tariff maps: precalculation_testing.csv (elec), gas_tariff_map.csv (gas)
  • distribution_cost_params.json: AESC 2024 + RI Energy Rate Case RY1 NCP params

Utilities

  • utils/generate_precalc_mapping.py: Generate precalc period/tier mappings from tariff JSON (1-based indexing for PySAM)
  • utils/create_flat_tariff.py: Create flat-rate URDB v7 tariff JSONs
  • tests/test_generate_precalc_mapping.py: Unit tests for precalc mapping generation

NY Updates

  • rate_design/ny/hp_rates/run_scenario.py: Minor import updates to use build_bldg_id_to_load_filepath from utils.cairo

Key Fixes

  • Tariff key type mismatch: Changed tariff_paths from list[Path] to dict[str, Path] so keys match tariff_map["tariff_key"] string values
  • 1-based indexing: generate_default_precalc_mapping uses enumerate(start=1) to match PySAM/CAIRO period/tier convention
  • Per-building parquet format: Custom _return_load handles files where bldg_id is not the index (ResStock per-building format)
  • Combined bill weight loss: Patched calculate_bill_stats_by_group to restore weight from metadata when missing in combined bills

Remaining TODOs

  • Verify inflation adjustment consistency between CAIRO and test scenario parameters (year_dollar_conversion)
  • Create proper load test utilities (prototype load curves w/ heat pumps)
  • Add post-processing module for delivered fuels bills
  • merge some of our cairo utils as PRs into NREL/cairo

Test plan

  • Run run_scenario.py on EC2 end-to-end with 5 prototype buildings and verify outputs

@sherryzuo sherryzuo linked an issue Feb 9, 2026 that may be closed by this pull request
alxsmith and others added 22 commits February 9, 2026 15:14
CAIRO expects tariff_params keys to match tariff_map tariff_key strings
(e.g. "rie_a16"), but our get_default_tariff_structures was keying by
file Paths. Changed tariff_paths from list[Path] to dict[str, Path]
so param_grid keys align with what CAIRO uses internally.
@sherryzuo sherryzuo requested a review from jpvelez February 9, 2026 19:04
@sherryzuo sherryzuo self-assigned this Feb 9, 2026
sherryzuo and others added 18 commits February 9, 2026 19:58
…CSV engine

- Use script dir (__file__.parent) for path_project so paths work from any CWD
- Add _load_cambium_marginal_costs in utils/cairo with engine='c' to avoid
  Arrow-backed in-place division failure when loading Cambium marginal costs
- Import and call from run_scenario.py; remove local duplicate

Co-authored-by: Cursor <[email protected]>
Drop _load_cambium_marginal_costs, return_buildingstock, _return_load,
_initialize_tariffs, get_default_tariff_structures, _load_tariff_json,
patch_postprocessor_weight_handling, DEFAULT_BUILDINGSTOCK_COLUMNS, and
_LOAD_COL_RENAMES. These were temporary wrappers/patches superseded by
recent CAIRO merges: sz/combined-bill-weight-merge, sz/tariff-paths-explicit,
sz/return-buildingstock-columns-weight, and sz/bldg-id-index-handling.

Retain patch_postprocessor_peak_allocation (pending CAIRO branch merge)
and build_bldg_id_to_load_filepath (no core equivalent).
Switch _return_load, return_buildingstock, _load_cambium_marginal_costs,
and _initialize_tariffs to their core CAIRO equivalents. Pass
customer_count directly to return_buildingstock instead of calling
reweight_customer_counts separately. Remove weight patch call (fixed
upstream in CAIRO).
Injects a default weight=1.0 column into metadata parquets that lack
one, writing a patched copy alongside the original. Fixes ValueError
from CAIRO's __load_buildingstock__ requiring weight in schema.

Also restores tariff_paths kwarg (available in latest CAIRO main).
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.

Load in RI MVP Run Numbers and Configs Make run_scenario.py for run 1

4 participants