Skip to content

constants.py

Constants and identifiers for PyPSA-AT energy system evaluations.

This module centralizes all constant values, color schemes, carrier names, and data model specifications used throughout the evaluation package. Values here should remain unchanged during runtime.

Key Components
  • DataModel: Column and index level name constants
  • BusCarrier: Bus carrier technology identifiers
  • Group: Nice names for carrier groupings
  • Regex: Regular expression patterns for parsing
  • COLOUR: Hex color code definitions
  • COLOUR_SCHEME: Carrier-to-color mapping
  • ALIAS_*: Location code to name mappings
  • UNITS: Unit conversion factors

BusCarrier

Container to collect all bus carrier names.

Source code in evals/constants.py
 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
class BusCarrier:
    """Container to collect all bus carrier names."""

    AC: str = "AC"
    DC: str = "DC"
    CH4: str = "gas"
    H2: str = "H2"
    OIL: str = "oil"
    LIGNITE: str = "lignite"
    COAL: str = "coal"
    NH3: str = "NH3"
    METHANOL: str = "methanol"
    URANIUM: str = "uranium"
    # TRANSPORT_P: str = "passenger transport"
    # TRANSPORT_P_LONG: str = "passenger transport long"
    FT: str = "Fischer-Tropsch"
    FT_1: str = "Fischer-Tropsch 1"
    FT_2: str = "Fischer-Tropsch 2"
    HEAT_URBAN_CENTRAL: str = "urban central heat"
    HEAT_URBAN_DECENTRAL: str = "urban decentral heat"
    HEAT_RURAL: str = "rural heat"
    # ESM heat buses:
    # HEAT_URBAN_SERVICES: str = "services urban decentral heat"
    # HEAT_URBAN_RESIDENTIAL: str = "residential urban decentral heat"
    # HEAT_RURAL_SERVICES: str = "services rural heat"
    # HEAT_RURAL_RESIDENTIAL: str = "residential rural heat"
    LI_ION: str = "Li ion"
    BATTERY: str = "battery"
    HOME_BATTERY: str = "home battery"
    EV_BATTERY: str = "EV battery"
    SOLID_BIOMASS: str = "solid biomass"

    @classmethod
    def ac_stores(cls) -> list[str]:
        """
        Return all AC-connected storage bus carriers.

        Returns
        -------
        List of bus carrier names for AC-connected storage systems
        including batteries and EV batteries.
        """
        return [
            cls.AC,
            cls.DC,
            cls.LI_ION,
            cls.BATTERY,
            cls.HOME_BATTERY,
            cls.EV_BATTERY,
        ]

    @classmethod
    def heat_buses(cls) -> list[str]:
        """
        Return all heat-related bus carriers.

        Returns
        -------
        List of bus carrier names for heating systems including
        central, decentral, and rural heat networks.
        """
        return [cls.HEAT_URBAN_CENTRAL, cls.HEAT_URBAN_DECENTRAL, cls.HEAT_RURAL]

    @classmethod
    def eu_buses(cls) -> list[str]:
        """
        Return bus carriers that only exist at EU-level locations.

        These carriers represent centralized EU-wide resources that are
        not regionalized to individual countries.

        Returns
        -------
        List of EU-level bus carrier names for fuels and uranium.
        """
        return [cls.OIL, cls.LIGNITE, cls.COAL, cls.METHANOL, cls.URANIUM]

ac_stores() classmethod

Return all AC-connected storage bus carriers.

Returns:

Type Description
List of bus carrier names for AC-connected storage systems
including batteries and EV batteries.
Source code in evals/constants.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@classmethod
def ac_stores(cls) -> list[str]:
    """
    Return all AC-connected storage bus carriers.

    Returns
    -------
    List of bus carrier names for AC-connected storage systems
    including batteries and EV batteries.
    """
    return [
        cls.AC,
        cls.DC,
        cls.LI_ION,
        cls.BATTERY,
        cls.HOME_BATTERY,
        cls.EV_BATTERY,
    ]

eu_buses() classmethod

Return bus carriers that only exist at EU-level locations.

These carriers represent centralized EU-wide resources that are not regionalized to individual countries.

Returns:

Type Description
List of EU-level bus carrier names for fuels and uranium.
Source code in evals/constants.py
112
113
114
115
116
117
118
119
120
121
122
123
124
@classmethod
def eu_buses(cls) -> list[str]:
    """
    Return bus carriers that only exist at EU-level locations.

    These carriers represent centralized EU-wide resources that are
    not regionalized to individual countries.

    Returns
    -------
    List of EU-level bus carrier names for fuels and uranium.
    """
    return [cls.OIL, cls.LIGNITE, cls.COAL, cls.METHANOL, cls.URANIUM]

heat_buses() classmethod

Return all heat-related bus carriers.

Returns:

Type Description
List of bus carrier names for heating systems including
central, decentral, and rural heat networks.
Source code in evals/constants.py
100
101
102
103
104
105
106
107
108
109
110
@classmethod
def heat_buses(cls) -> list[str]:
    """
    Return all heat-related bus carriers.

    Returns
    -------
    List of bus carrier names for heating systems including
    central, decentral, and rural heat networks.
    """
    return [cls.HEAT_URBAN_CENTRAL, cls.HEAT_URBAN_DECENTRAL, cls.HEAT_RURAL]

COLOUR

Container to collect colour codes in hex format.

Source code in evals/constants.py
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
class COLOUR:
    """Container to collect colour codes in hex format."""

    coral: str = "#E8B5B1"
    raspberry: str = "#961454"
    salmon: str = "#E19990"
    rose: str = "#C13A2A"
    peach: str = "#EBBFBA"

    red: str = "#CA0638"
    red_chestnut: str = "#96332C"
    red_bright: str = "#E53212"
    red_deep: str = "#B20633"
    red_fire: str = "#E63313"
    red_liquid: str = "#A7003F"

    green: str = "#619159"
    green_light: str = "#509554"
    green_ocean: str = "#3DCCBF"
    green_mint: str = "#B0D4B2"
    green_sage: str = "#82B973"
    turquoise: str = "#e8e8e8"

    grey_light: str = "#ECECEC"
    grey_dark: str = "#535353"
    grey_charcoal: str = "#485055"
    grey_deep: str = "#3C3C3C"
    grey_cool: str = "#919699"
    grey_silver: str = "#D0D0D0"
    grey_neutral: str = "#9F9F9F"

    black: str = "#000000"

    brown: str = "#AE8020"
    brown_dark: str = "#b37400"
    brown_sallow: str = "#bf9c5c"
    brown_light: str = "#e8cc99"
    brown_deep: str = "#4d3200"

    blue_pastel: str = "#B5C9D5"
    blue_moonstone: str = "#74AABA"
    blue_dark: str = "#5F5F5F"
    blue_persian: str = "#34629B"
    blue_celestial: str = "#4F8FCD"
    blue_cerulean: str = "#005082"
    blue_sky: str = "#99C1DA"
    blue_lavender: str = "#636EFA"
    blue_deepdark: str = "#1C3049"

    orange: str = "#FF6600"
    orange_mellow: str = "#FECB52"

    yellow_bright: str = "#EDD820"
    yellow_vivid: str = "#FEC500"
    yellow_canary: str = "#FFDE53"
    yellow_golden: str = "#FFB200"

DataModel

Metric data model constants.

Source code in evals/constants.py
35
36
37
38
39
40
41
42
43
44
45
46
class DataModel:
    """Metric data model constants."""

    LOCATION: str = "location"
    COMPONENT: str = "component"
    CARRIER: str = "carrier"
    BUS_CARRIER: str = "bus_carrier"
    METRIC: str = "metric"
    YEAR: str = "year"
    SNAPSHOTS: str = "snapshots"
    IDX_NAMES: list = [LOCATION, CARRIER, BUS_CARRIER]
    YEAR_IDX_NAMES: list = [YEAR, LOCATION, CARRIER, BUS_CARRIER]

Group

Container to collect carrier nice names used in PyPSA-AT evaluations.

Source code in evals/constants.py
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
158
159
160
161
162
163
164
165
166
167
168
169
170
class Group:
    """Container to collect carrier nice names used in PyPSA-AT evaluations."""

    # Biomass
    biomass: str = "Biomass"
    chp_biomass: str = "Biomass CHP"
    solid_biomass_boiler: str = "Solid Biomass Boiler"

    # Coal
    coal: str = "Coal"
    chp_coal: str = "Coal CHP"
    chp_coal_cc: str = "Coal CHP CC"
    pp_coal: str = "Coal PP"

    # Gas/Methane
    chp_ch4: str = "Gas CHP"
    chp_ch4_cc: str = "Gas CHP CC"

    # Import/Export
    export_domestic: str = "Export Domestic"
    export_foreign: str = "Export Foreign"
    export_net: str = "Net Export"
    import_domestic: str = "Import Domestic"
    import_foreign: str = "Import Foreign"
    import_global: str = "Import Global"
    import_net: str = "Net Import"

    # Storage
    storage_in: str = "Storage In"
    storage_out: str = "Storage Out"

    # Hydro metrics
    inflow_cum: str = "Accumulated Natural Inflow"
    pumping_cum: str = "Accumulated Pumping"
    soc: str = "State of Charge"
    soc_max: str = "Max State of Charge"
    spill_cum: str = "Accumulated Outflow Spill"
    turbine_cum: str = "Accumulated Turbining"

    # Market
    global_market: str = "Global Market"

    # Other
    power_disconnect: str = "Power Disconnect"

Regex

A collection of regular expression patterns.

Source code in evals/constants.py
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
class Regex:
    """A collection of regular expression patterns."""

    # ends with 4 digits
    year: re.Pattern = re.compile(r"\d{4}$")

    # matches:
    # ^ : startswith
    # [A-Z]{2} : 2 capital letters,
    # [\d,A-G,+]{0,3} : up to 3 digits, letter (German NUTS2 codes),
    # [+1]? : optional '+1' literal to match Austrian NUTS3 regions
    # \s?\d* : 1 optional space, and any number of digits for subnets.
    region: re.Pattern = re.compile(r"^(?!.*CH4)[A-Z]{2}[\d,A-G]{0,3}[+1]?\s?\d*")

    # matches: startswith 2 capital letters, followed by up to 3 digits,
    # groups: only the first 2 letters that are the country code
    country: re.Pattern = re.compile(r"^([A-Z]{2})[\d,A-G]{0,3}\s*")

    # match anything inside parenthesis.
    unit: re.Pattern = re.compile(r"\([^()]*\)")

TradeTypes

Collect trade type names.

Source code in evals/constants.py
223
224
225
226
227
228
class TradeTypes:
    """Collect trade type names."""

    LOCAL: str = "local"  # same node
    DOMESTIC: str = "domestic"  # same country, but different node
    FOREIGN: str = "foreign"  # different country