transforms.capacities
Determine installed-capacity targets (p_nom_min) for PyPSA from IAM output.
The shared pipeline is:
1. read the capacity spec via load_spec (handles unit conversion and
backend dispatch)
2. optionally apply a consolidation block from the spec (VRE-variant merging,
battery scaling — only exercised when the symbol config declares it, e.g. for GDX input),
3. adjust link-like techs to input-capacity basis, and aggregate to PyPSA carriers.
adjust_link_capacities_to_input(capacities, efficiencies, link_techs, *, on=('year', 'region', 'technology'), tech_col='technology', value_col='value', eff_col='efficiency')
¶
Divide output-based capacities by efficiency for link-like techs (→ input basis). (PyPSA links are defined by input capacity, but some IAMs report output capacity.)
Rows with missing or zero efficiency are left unchanged (with a warning).
Source code in src/iampypsa/transforms/capacities.py
aggregate_capacities_to_carriers(capacities, tech_to_carrier, *, group_cols=('year', 'region'), tech_col='technology', map_tech_col, map_carrier_col, value_col='value', unit='MW', min_value=0.0, round_digits=2)
¶
Map model tech tokens to target carrier names, sum per (group, carrier).
Returns [year, region, carrier, value, unit].
Rows whose tech token is absent from tech_to_carrier are dropped with a warning.
Aggregation is needed when the mapping is not 1:1 (several tokens share a carrier).
Source code in src/iampypsa/transforms/capacities.py
apply_consolidation(caps, *, vre_to_primary=None, battery_scaling=None, tech_col='technology', value_col='value')
¶
Apply the optional consolidation block from the capacity symbol spec.
Two steps, both driven by config — no-op when params are absent (e.g. IAMC configs
that have no consolidation block):
- VRE-variant merge: rename coupled VRE tech tokens to their primary token
(e.g.
elh2VRE→elh2). - Battery scaling: fold storage tech rows into the charger token (
btin) by multiplying each storage row by its scaling factor. If abtinrow already carries a positive value, the storage rows are dropped instead (bidirectional-coupling guard).
Source code in src/iampypsa/transforms/capacities.py
build_capacity_targets(loader, symbols, regions, tech_map, *, map_tech_col, map_carrier_col)
¶
Build installed-capacity targets per [year, region, carrier, value, unit].
Prepare capacities (:func:prepare_capacities), map tech tokens to carriers via tech_map
and sum, then filter to regions. The unit column reflects the target unit declared in
the capacity spec (to_unit).
Source code in src/iampypsa/transforms/capacities.py
prepare_capacities(loader, symbols)
¶
Read capacities at model-tech resolution, before any carrier aggregation.
Shared preparation for every consumer:
1. Read the capacity spec via load_spec (dispatches on spec shape; unit conversion
applied by the spec's to_unit).
2. Apply the consolidation block if present (VRE-variant merge, battery scaling).
3. Adjust link-like techs to input-capacity basis (requires efficiency_conv symbol).
Returns [year, region, technology, value, unit]. Callers that need PyPSA carriers pass
this to :func:aggregate_capacities_to_carriers; callers that need model-tech resolution
(e.g. group-wise brownfield harmonisation) consume it directly.