Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ build/
!rate_design/hp_rates/md/config/tariffs/**
!rate_design/hp_rates/ny/config/tariff_maps/**
!rate_design/hp_rates/ri/config/tariff_maps/**
!rate_design/hp_rates/md/config/tariff_maps/**
!rate_design/hp_rates/ny/config/marginal_costs/**
!rate_design/hp_rates/ri/config/marginal_costs/**
!rate_design/hp_rates/md/config/marginal_costs/**
Expand Down
7 changes: 2 additions & 5 deletions data/resstock/utility/assign_utility_ny.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pygris import pumas as get_pumas

from data.resstock.utils import (
get_excluded_gas_utilities,
load_state_configs,
select_puma_and_heating_fuel_metadata,
)
Expand All @@ -35,11 +36,7 @@

STORAGE_OPTIONS = {"aws_region": get_aws_region()}

EXCLUDED_GAS_UTILITIES: frozenset[str] = frozenset(
(load_state_configs()[_STATE]["utility_assignment"].get("kwargs") or {}).get(
"excluded_gas_utilities", []
)
)
EXCLUDED_GAS_UTILITIES: frozenset[str] = get_excluded_gas_utilities(_STATE)


def assign_utility(
Expand Down
36 changes: 36 additions & 0 deletions data/resstock/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,42 @@ def load_state_configs(path: Path | None = None) -> dict[str, dict]:
return yaml.safe_load(f)


def get_excluded_gas_utilities(
state: str | None = None,
*,
path: Path | None = None,
) -> frozenset[str]:
"""Return excluded gas utility ``std_name``s from ``state_configs.yaml``.

Canonical source: each state's
``utility_assignment.kwargs.excluded_gas_utilities`` list (utilities we do
not model — zeroed in assignment and mapped to ``null_gas_tariff``).

Args:
state: 2-letter state code (e.g. ``"NY"``). If ``None``, return the
union across all states (for cross-state consumers like the gas
tariff mapper).
path: Optional override for the config file path (tests).
"""
configs = load_state_configs(path)
if state is not None:
if state not in configs:
raise KeyError(
f"State {state!r} not found in state_configs.yaml "
f"(known: {sorted(configs)})"
)
state_codes = [state]
else:
state_codes = list(configs)

excluded: set[str] = set()
for code in state_codes:
ua = configs[code].get("utility_assignment") or {}
kwargs = ua.get("kwargs") or {}
excluded.update(kwargs.get("excluded_gas_utilities") or [])
return frozenset(excluded)


def normalize_nargs_list(values: list[str]) -> list[str]:
"""Flatten a ``nargs="+"`` list that may contain space-separated entries.

Expand Down
5 changes: 4 additions & 1 deletion rate_design/hp_rates/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ path_supply_energy_mc := env_var_or_default('SUPPLY_ENERGY_MC', "s3://data.sb/sw
path_supply_capacity_mc := env_var_or_default('SUPPLY_CAPACITY_MC', "s3://data.sb/switchbox/marginal_costs/" + state + "/supply/capacity/utility=" + utility + "/year=" + mc_year + "/data.parquet")
path_supply_ancillary_mc := env_var_or_default('SUPPLY_ANCILLARY_MC', "")
path_resstock_release := "/ebs/data/nrel/resstock/res_2024_amy2018_2_sb"
# Raw NREL release (no _sb): full-population load_curve_annual lives here.
path_resstock_raw := "/ebs/data/nrel/resstock/res_2024_amy2018_2"
path_resstock_metadata := path_resstock_release + "/metadata"
path_utility_assignment := path_resstock_release + "/metadata_utility"
path_resstock_loads_00 := path_resstock_release + "/load_curve_hourly/state=" + state_upper + "/upgrade=" + upgrade
Expand Down Expand Up @@ -344,7 +346,8 @@ create-gas-tariff-map electric_utility upgrade_id output_dir:
"{{ state_upper }}" \
"{{ electric_utility }}" \
"{{ upgrade_id }}" \
"{{ output_dir }}"
"{{ output_dir }}" \
"{{ path_resstock_raw }}/load_curve_annual/state={{ state_upper }}/upgrade={{ upgrade_id }}"

create-gas-tariff-maps-all:
just create-gas-tariff-map {{ utility }} "00" {{ path_tariff_maps }}/gas
Expand Down
73 changes: 73 additions & 0 deletions rate_design/hp_rates/md/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,79 @@ split-chesapeake-gas-tariffs:
--path-res2-phase2-csv "{{ path_tariffs_gas }}/chesapeake_utilities_res2_phase2.csv" \
--output-dir "{{ path_tariffs_gas }}"

# =============================================================================
# MD-only: gas tariff maps
#
# Gas tariff maps are partitioned by electric utility (output:
# tariff_maps/gas/<electric_utility>_u00.csv and _u02.csv). MD has 8 modeled
# gas utilities (bge, washington_gas, columbia_gas_md, chesapeake_utilities,
# sandpiper, elkton_gas, ugi_central_penn, easton_muni) served across these
# electric territories. Gas-only LDCs (washington_gas, etc.) appear as
# tariff_keys inside the electric utility's map — only easton_muni among the
# munis is dual-fuel and needs its own map file. somerset_rec / berlin_muni /
# hagerstown_muni stay outside this list (electric-only for our purposes).
#
# Chesapeake-territory RES-1/RES-2 split reads load_curve_annual from the raw
# NREL release (passed automatically by the shared create-gas-tariff-map recipe).
#
# Shortcuts (upgrade 00 only — quick per-utility run):
# just -f md/Justfile map-gas-bge
# just -f md/Justfile map-gas-all-utilities
#
# Full batch (upgrades 00 + 02):
# just -f md/Justfile create-gas-tariff-maps-md-all
# =============================================================================

# Electric utilities for which gas tariff maps are generated (covers all 8
# modeled MD gas utilities, including easton_muni dual-fuel territory).
md_electric_utilities := "bge pepco dpl poted smeco choptank easton_muni"

# Per-utility shortcuts (upgrade 00). Mirror NY map-gas-<name> convention.
map-gas-bge:
just create-gas-tariff-map bge 00 {{ path_tariff_maps }}/gas

map-gas-pepco:
just create-gas-tariff-map pepco 00 {{ path_tariff_maps }}/gas

map-gas-dpl:
just create-gas-tariff-map dpl 00 {{ path_tariff_maps }}/gas

map-gas-poted:
just create-gas-tariff-map poted 00 {{ path_tariff_maps }}/gas

map-gas-smeco:
just create-gas-tariff-map smeco 00 {{ path_tariff_maps }}/gas

map-gas-choptank:
just create-gas-tariff-map choptank 00 {{ path_tariff_maps }}/gas

map-gas-easton_muni:
just create-gas-tariff-map easton_muni 00 {{ path_tariff_maps }}/gas

# Run upgrade-00 gas tariff maps for all MD electric utilities in the list.
map-gas-all-utilities:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p {{ path_tariff_maps }}/gas
for utility in {{ md_electric_utilities }}; do
echo ">> MD gas tariff map: utility=${utility} upgrade=00" >&2
just create-gas-tariff-map "${utility}" "00" "{{ path_tariff_maps }}/gas"
done
echo ">> Done: MD gas tariff maps (upgrade 00)" >&2

# Full batch: upgrades 00 + 02 for all MD electric utilities in the list.
create-gas-tariff-maps-md-all:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p {{ path_tariff_maps }}/gas
for utility in {{ md_electric_utilities }}; do
for upgrade in 00 02; do
echo ">> MD gas tariff map: utility=${utility} upgrade=${upgrade}" >&2
just create-gas-tariff-map "${utility}" "${upgrade}" "{{ path_tariff_maps }}/gas"
done
done
echo ">> Done: all MD gas tariff maps" >&2

# =============================================================================
# MD-only: ISO-native load source for sub-TX/DX marginal costs
#
Expand Down
Loading