io.remind_symbols
Central REMIND symbol configuration: load logical→GDX/IAMC symbol maps and load frames.
Symbol definitions evolve, so they live in YAML (not code) and are layered:
- the package default ships at
iampypsa/data/remind_symbols_gdx.yaml(or…_mif.yaml), selected bybackend— neither is the implicit default when an explicit backend is given; - a model/run may overlay its own YAML — passed as
path=or via theIAMPYPSA_SYMBOLSenvironment variable — which is deep-merged on top of the default, so the overlay only needs to list what differs (a new symbol, a renamed candidate, a region override).
load_symbol_specs is split into debuggable steps: read_symbol_config (I/O + overlay →
raw {default, overrides} dict) and merge_region_overrides (pure per-logical-name merge
→ the flat map). Inspect either on its own when debugging.
Loading layer:
load_frame— single-quantity symbol, addressed viasymbol:key.load_set— mixed-unit set symbol (index:/schema:shape).load_variable_set— many-variables-to-one-frame assembly (variables:shape); only satisfiable by a loader whose source format exposes named-variable lookup (IAMC today).load_spec— dispatcher: picks by spec shape (variables:→load_variable_set;index:/schema:→load_set; else →load_frame). Avariables:spec still requires an IAMC-backed loader; the dispatch is on spec shape, not a guarantee that every spec shape works with every backend.
report_fallbacks returns a summary of all fallback declarations in a symbol map so
coverage gaps are inspectable without running a full coupling.
build_capacity_reporting_technologies()
¶
Return every canonical technology REMIND reports installed capacity for.
Reads the capacity spec's variables:/derived: tokens (hydro is included there).
Source code in src/iampypsa/io/remind_symbols.py
default_symbol_config_path(backend=None)
¶
Return the path to the packaged default symbol config for backend.
backend="gdx" → remind_symbols_gdx.yaml;
backend="iamc" → remind_symbols_mif.yaml;
backend=None → remind_symbols_gdx.yaml (backward-compatible default).
Source code in src/iampypsa/io/remind_symbols.py
load_frame(loader, spec)
¶
Load the frame for one single-quantity symbol spec, applying its unit conversion.
Resolves symbol (falls back to legacy gdx), then scales value via the central
iampypsa.units factor when both a source unit (unit:/units:) and to_unit:
are declared (a legacy unit_factor: scalar is also honoured). Stamps the resolved unit
onto a unit column, matching load_set/load_variable_set, unless no unit is
declared at all. Use load_set for mixed-unit symbols.
An optional filter: {column: value} drops rows that don't match — e.g. selecting a
single GAMS domain slice (rlf: 1) out of a symbol that carries extra dimensions.
Source code in src/iampypsa/io/remind_symbols.py
load_set(loader, spec)
¶
Load a mixed-unit set symbol: one REMIND symbol whose index column selects several
quantities with different units (e.g. pm_data indexed by char → lifetime/FOM/VOM).
The spec's schema maps each index value to {parameter, unit, to_unit}. Returns a long
frame with a parameter column, value converted per row via the central units table,
and a unit column set to the target unit. Index values not in the schema are dropped.
Source code in src/iampypsa/io/remind_symbols.py
load_spec(loader, spec)
¶
Dispatch to load_variable_set or load_frame based on the spec shape.
Dispatches on spec shape (variables: vs symbol:), not on loader.backend —
though a variables: spec still only works against a loader whose format supports it
(currently IAMC; see load_variable_set).
Source code in src/iampypsa/io/remind_symbols.py
load_symbol_specs(region=None, path=None, *, backend=None)
¶
Return the resolved symbol map for backend and region.
region and path are positional for backward compatibility with existing callers.
Pass backend=loader.backend as a keyword argument to select the GDX or IAMC config.
backend=None (default) falls back to the GDX config.
Source code in src/iampypsa/io/remind_symbols.py
load_variable_set(loader, spec)
¶
Load a variable-set spec: many IAMC variables → one token-labelled frame.
IAMC-only (no GDX equivalent — GDX already carries a tech-domain column per symbol).
variables: maps IAMC variable names to token labels; optional derived: declares
linear combinations. Fallback tokens in spec['fallback'] ({token: {value, unit,
reason}}) are synthesised for every (year, region) when absent from the data.
Source code in src/iampypsa/io/remind_symbols.py
merge_region_overrides(config, region)
¶
Merge default with overrides[region] per logical name (region entry wins).
Pure dict logic (no I/O): region=None returns default unchanged; an unknown region
(absent from overrides) also returns default. Call directly to debug the merge.
Source code in src/iampypsa/io/remind_symbols.py
read_symbol_config(path=None, *, backend=None)
¶
Read the raw symbol config ({default, overrides}), overlaying a user file if any.
Always starts from the packaged default for backend. An overlay file (path, else
the IAMPYPSA_SYMBOLS env var) is deep-merged on top.
Source code in src/iampypsa/io/remind_symbols.py
rename_technologies(df, names, col='technology', *, on_missing='warn')
¶
Rename raw source-model technology tokens to the canonical vocabulary.
names is the technology_names token → canonical-name block; empty/absent is a
no-op. Unmapped values are kept as-is, per on_missing: "warn" (default), "raise",
or "ignore".
Source code in src/iampypsa/io/remind_symbols.py
report_fallbacks(symbols)
¶
Return a summary DataFrame of all fallback declarations in a symbol map.
Scans every spec in symbols for a fallback: block and returns
[logical_name, token, value, reason] so coverage gaps are inspectable without a run.