couplers.base
The IAM→PyPSA coupling interface. This is exposed to pypsa models and is the entry point for the coupling workflow.
Coupleris the backend-neutral base: it holds the shared, concrete builders (build_co2_prices,discount_rates,downscale_country_demand)- it consumes the IAM symbols (resolved via their config) and the region map, and it contains the reference data (population, GDP, etc.) for downscaling.
Concrete subclasses are instantiated directly by the caller, which selects on loader.backend;
a new IAM or output format is added as a further Coupler subclass, not a branch here:
- RemindGdxCoupler (iampypsa.couplers.remind)
- RemindIamcCoupler (iampypsa.couplers.remind)
config keys used: currency_factor, sector_weights, countries, planning_horizons.
Coupler
¶
Backend-neutral base: shared builders + source-specific hook declarations.
Source code in src/iampypsa/couplers/base.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
__init__(loader, symbols, region_map, config, *, model_regions=None, reference_data=None, ssp_population=None, ssp_gdp=None)
¶
Bind the loader, resolved symbol map, region map, config, and reference data.
Source code in src/iampypsa/couplers/base.py
build_co2_prices(years=None)
¶
Build the per-(region, year) CO2 price pathway.
Conversion is spec-driven: applies whatever (unit, to_unit) factor the resolved
co2_price symbol's config declares (a no-op when the source already reports t CO2).
The runtime currency_factor is always applied.
years selects the year set to reindex to (missing filled with 0); when None
it falls back to config["planning_horizons"]. Callers that derive the coupled-year
set from the IAM source (e.g. the GDX t symbol) pass it explicitly.
Source code in src/iampypsa/couplers/base.py
build_regional_demand()
¶
Read IAM regional sectoral demand as [year, region, sector, value, unit] (MWh).
Implemented by RemindGdxCoupler / RemindIamcCoupler.
Source code in src/iampypsa/couplers/base.py
discount_rates(year)
¶
Return the discount rate per region for year, indexed by region.
When a region has no value for year (e.g. a trailing NaN in the source), the
most recent earlier year's value is used with a warning.
Source code in src/iampypsa/couplers/base.py
downscale_country_demand(regional=None)
¶
Downscale IAM regional demand to per-country annual demand by sector and year.
The proxy registry is self.reference_data verbatim — it already holds population/
gdp (and any heating_demand/cooling_demand the caller added). Each sector's
sector_weights entry names which of those proxies to blend.
Source code in src/iampypsa/couplers/base.py
extract_cost_parameters(year)
¶
Extract cost parameters as long [region, reference, parameter, value, unit].
Implemented by RemindGdxCoupler / RemindIamcCoupler.