Skip to content

Index

Expose view functions from inside the views module.

view_balance_biomass(result_path, nc, config)

Evaluate and export the solid biomass balance showing biomass supply and consumption.

This function analyzes solid biomass flows in the energy system, including biomass supply from forestry and agriculture, biomass imports, and consumption in biomass boilers, combined heat and power plants, and other biomass-using technologies. It delegates to the simple_bus_balance function to collect and export supply and withdrawal statistics for solid biomass buses.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, chart type, and export parameters.

required
Source code in evals/views/balances.py
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
def view_balance_biomass(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export the solid biomass balance showing biomass supply and consumption.

    This function analyzes solid biomass flows in the energy system, including biomass
    supply from forestry and agriculture, biomass imports, and consumption in biomass
    boilers, combined heat and power plants, and other biomass-using technologies. It
    delegates to the simple_bus_balance function to collect and export supply and
    withdrawal statistics for solid biomass buses.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        chart type, and export parameters.
    """
    simple_bus_balance(nc, config, result_path)

view_balance_carbon(result_path, nc, config)

Evaluate and export the carbon balance showing CO2 flows to and from atmosphere.

This function analyzes CO2 emissions and deductions from the atmosphere bus only. It corresponds shows the national CO2 budget per year.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, chart type, and export parameters.

required
Source code in evals/views/balances.py
21
22
23
24
25
26
27
28
29
30
31
32
33
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
def view_balance_carbon(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export the carbon balance showing CO2 flows to and from atmosphere.

    This function analyzes CO2 emissions and deductions from the atmosphere bus only.
    It corresponds shows the national CO2 budget per year.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        chart type, and export parameters.
    """
    bus_carrier = config["view"]["bus_carrier"]

    co2_balance = collect_myopic_statistics(
        nc, "energy_balance", bus_carrier=bus_carrier
    )

    # need to deduct emission from international aviation.
    first_year = nc.index[0]
    energy_totals = pd.DataFrame.from_dict(
        nc[first_year].meta["resources"]["energy_totals"], orient="tight"
    )
    domestic_aviation_factors = get_energy_totals_domestic_share(
        energy_totals, kind="aviation"
    )

    # The domestic aviation factor reduces co2 emissions for aviation per country
    for ct in energy_totals.index:
        mask_country = co2_balance.index.get_level_values(DM.LOCATION).str.startswith(
            ct
        )
        mask_carrier = (
            co2_balance.index.get_level_values(DM.CARRIER) == "kerosene for aviation"
        )
        co2_balance.loc[mask_country & mask_carrier] *= domestic_aviation_factors[ct]

    exporter = Exporter(statistics=[co2_balance], view_config=config["view"])
    exporter.export(result_path, config["global"]["subdir"])

view_balance_electricity(result_path, nc, config)

Evaluate and export electricity production and demand by country and year.

This function calculates the electricity balance showing generation sources and consumption patterns across the network. It delegates to the simple_bus_balance function to collect and export supply and withdrawal statistics for electricity buses.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, chart type, and export parameters.

required
Notes

Balances do not add up to zero, because of domestic transmission losses.

Source code in evals/views/balances.py
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
def view_balance_electricity(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export electricity production and demand by country and year.

    This function calculates the electricity balance showing generation sources and
    consumption patterns across the network. It delegates to the simple_bus_balance
    function to collect and export supply and withdrawal statistics for electricity buses.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        chart type, and export parameters.

    Notes
    -----
    Balances do not add up to zero, because of domestic transmission losses.
    """
    simple_bus_balance(nc, config, result_path)

view_balance_fuels(result_path, nc, config)

Evaluate and export the fuel balance showing primary fuel supply and consumption.

This function calculates the energy balance for primary fuel carriers including coal, lignite, oil, solid biomass, methanol, ammonia, waste, and uranium. It delegates to the simple_bus_balance function to collect and export supply and withdrawal statistics for specified fuel bus carriers. The view supports grouping of related fuels (e.g., coal and lignite) through the bus_carrier_groups configuration.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, bus_carrier_groups for aggregating related fuels, chart type, and export parameters.

required
Notes

This view is particularly useful for analyzing primary energy supply and fuel consumption patterns across different sectors (industry, transport, heat, power generation). The bus_carrier_groups configuration allows aggregation of similar fuels for clearer visualization, such as combining coal and lignite into a single "Coal" category.

Source code in evals/views/balances.py
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
def view_balance_fuels(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export the fuel balance showing primary fuel supply and consumption.

    This function calculates the energy balance for primary fuel carriers including coal,
    lignite, oil, solid biomass, methanol, ammonia, waste, and uranium. It delegates to
    the simple_bus_balance function to collect and export supply and withdrawal statistics
    for specified fuel bus carriers. The view supports grouping of related fuels (e.g.,
    coal and lignite) through the bus_carrier_groups configuration.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        bus_carrier_groups for aggregating related fuels, chart type, and export parameters.

    Notes
    -----
    This view is particularly useful for analyzing primary energy supply and fuel consumption
    patterns across different sectors (industry, transport, heat, power generation). The
    bus_carrier_groups configuration allows aggregation of similar fuels for clearer
    visualization, such as combining coal and lignite into a single "Coal" category.
    """
    simple_bus_balance(nc, config, result_path)

view_balance_heat(result_path, nc, config)

Evaluate and export the heat balance showing heat production and consumption.

This function calculates the heat balance for specified heat bus carriers (urban central, urban decentral, rural heat) by analyzing link energy flows and load withdrawals. Heat supply is determined from link energy balance data, showing the input energy carriers feeding heat production. Heat demand includes consumption loads, with central heat losses separated from actual consumption. The function exports both supply and demand data with appropriate chart formatting based on the configured chart type.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, chart type, and export parameters.

required
Notes

Heat supply is calculated from link energy balances, excluding CO2 flows. For urban central heat, distribution losses are separated from consumption using heat loss factors. The function supports both ESMGroupedBarChart (preserving individual bus carriers) and ESMBarChart (aggregating bus carriers) visualization modes.

Source code in evals/views/balances.py
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
158
159
def view_balance_heat(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export the heat balance showing heat production and consumption.

    This function calculates the heat balance for specified heat bus carriers (urban central,
    urban decentral, rural heat) by analyzing link energy flows and load withdrawals. Heat
    supply is determined from link energy balance data, showing the input energy carriers
    feeding heat production. Heat demand includes consumption loads, with central heat losses
    separated from actual consumption. The function exports both supply and demand data with
    appropriate chart formatting based on the configured chart type.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        chart type, and export parameters.

    Notes
    -----
    Heat supply is calculated from link energy balances, excluding CO2 flows. For urban
    central heat, distribution losses are separated from consumption using heat loss factors.
    The function supports both ESMGroupedBarChart (preserving individual bus carriers) and
    ESMBarChart (aggregating bus carriers) visualization modes.
    """
    bus_carrier = config["view"]["bus_carrier"]

    heat_mix = get_energy_for_heat_production(nc, drop_regex="")
    heat_mix = heat_mix.swaplevel(DM.CARRIER, DM.BUS_CARRIER)
    heat_mix.index.names = DM.YEAR_IDX_NAMES

    generator_supply = collect_myopic_statistics(
        nc,
        statistic="supply",
        comps="Generator",
        bus_carrier=bus_carrier,
    )

    heat_loss_factor = get_heat_loss_factor(nc)
    demand = (
        collect_myopic_statistics(
            nc,
            statistic="withdrawal",
            bus_carrier=bus_carrier,
        )
        .pipe(split_urban_central_heat_losses_and_consumption, heat_loss_factor)
        .mul(-1)
    )

    exporter = Exporter(
        statistics=[heat_mix, demand, generator_supply], view_config=config["view"]
    )
    exporter.export(result_path, config["global"]["subdir"])

view_balance_hydrogen(result_path, nc, config)

Evaluate and export the hydrogen balance showing H2 production and consumption.

This function analyzes hydrogen flows in the energy system, including production from electrolyzers and other sources, as well as consumption from fuel cells, industrial processes, and other hydrogen-using technologies. It delegates to the simple_bus_balance function to collect and export supply and withdrawal statistics for hydrogen buses.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, chart type, and export parameters.

required
Source code in evals/views/balances.py
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
def view_balance_hydrogen(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export the hydrogen balance showing H2 production and consumption.

    This function analyzes hydrogen flows in the energy system, including production
    from electrolyzers and other sources, as well as consumption from fuel cells,
    industrial processes, and other hydrogen-using technologies. It delegates to the
    simple_bus_balance function to collect and export supply and withdrawal statistics
    for hydrogen buses.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        chart type, and export parameters.
    """
    simple_bus_balance(nc, config, result_path)

view_balance_methane(result_path, nc, config)

Evaluate and export the methane balance showing natural gas and biogas flows.

This function analyzes methane (CH4) flows in the energy system, including natural gas supply from pipelines and storage, biogas production, methanation processes, and consumption in gas boilers, combined heat and power plants, and other gas-consuming technologies. It delegates to the simple_bus_balance function to collect and export supply and withdrawal statistics for methane buses.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, chart type, and export parameters.

required
Source code in evals/views/balances.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
def view_balance_methane(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export the methane balance showing natural gas and biogas flows.

    This function analyzes methane (CH4) flows in the energy system, including natural gas
    supply from pipelines and storage, biogas production, methanation processes, and
    consumption in gas boilers, combined heat and power plants, and other gas-consuming
    technologies. It delegates to the simple_bus_balance function to collect and export
    supply and withdrawal statistics for methane buses.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        chart type, and export parameters.
    """
    simple_bus_balance(nc, config, result_path)

view_capacity_electricity_demand(result_path, nc, config)

Evaluate the optimal capacity for AC technologies that withdraw electricity.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Directory path where results will be saved

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects for analysis

required
config dict

Configuration dictionary containing model parameters

required
Source code in evals/views/capacities.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
def view_capacity_electricity_demand(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate the optimal capacity for AC technologies that withdraw electricity.

    Parameters
    ----------
    result_path
        Directory path where results will be saved
    nc
        Dictionary containing PyPSA network objects for analysis
    config
        Configuration dictionary containing model parameters
    """
    simple_optimal_capacity(nc, config, result_path, kind="demand")

view_capacity_electricity_production(result_path, nc, config)

Evaluate the optimal capacity for AC technologies that produce electricity.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Directory path where results will be saved

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects for analysis

required
config dict

Configuration dictionary containing model parameters

required
Source code in evals/views/capacities.py
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def view_capacity_electricity_production(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate the optimal capacity for AC technologies that produce electricity.

    Parameters
    ----------
    result_path
        Directory path where results will be saved
    nc
        Dictionary containing PyPSA network objects for analysis
    config
        Configuration dictionary containing model parameters
    """
    simple_optimal_capacity(nc, config, result_path, kind="production")

view_capacity_electricity_storage(result_path, nc, config)

Evaluate the optimal capacity for AC technologies that store electricity.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Directory path where results will be saved

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects for analysis

required
config dict

Configuration dictionary containing model parameters

required
Source code in evals/views/capacities.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
def view_capacity_electricity_storage(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate the optimal capacity for AC technologies that store electricity.

    Parameters
    ----------
    result_path
        Directory path where results will be saved
    nc
        Dictionary containing PyPSA network objects for analysis
    config
        Configuration dictionary containing model parameters
    """
    simple_storage_capacity(nc, config, result_path)

view_capacity_gas_production(result_path, nc, config)

Evaluate the optimal capacity for technologies that produce methane.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Directory path where results will be saved

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects for analysis

required
config dict

Configuration dictionary containing model parameters

required
Source code in evals/views/capacities.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def view_capacity_gas_production(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate the optimal capacity for technologies that produce methane.

    Parameters
    ----------
    result_path
        Directory path where results will be saved
    nc
        Dictionary containing PyPSA network objects for analysis
    config
        Configuration dictionary containing model parameters
    """
    simple_optimal_capacity(nc, config, result_path, kind="production")

view_capacity_gas_storage(result_path, nc, config)

Evaluate optimal storage capacities for gas stores (CH4, H2).

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Directory path where results will be saved

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects for analysis

required
config dict

Configuration dictionary containing model parameters

required
Notes

FixMe: No Hydrogen Storage with current config?

Source code in evals/views/capacities.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def view_capacity_gas_storage(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate optimal storage capacities for gas stores (CH4, H2).

    Parameters
    ----------
    result_path
        Directory path where results will be saved
    nc
        Dictionary containing PyPSA network objects for analysis
    config
        Configuration dictionary containing model parameters

    Notes
    -----
    FixMe: No Hydrogen Storage with current config?
    """
    simple_storage_capacity(nc, config, result_path)

view_capacity_heat_production(result_path, nc, config)

Evaluate the optimal capacity for technologies that produce heat.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Directory path where results will be saved

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects for analysis

required
config dict

Configuration dictionary containing model parameters

required
Source code in evals/views/capacities.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
def view_capacity_heat_production(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate the optimal capacity for technologies that produce heat.

    Parameters
    ----------
    result_path
        Directory path where results will be saved
    nc
        Dictionary containing PyPSA network objects for analysis
    config
        Configuration dictionary containing model parameters
    """
    simple_optimal_capacity(nc, config, result_path, kind="production")

view_capacity_hydrogen_production(result_path, nc, config)

Evaluate the optimal capacity for technologies that produce hydrogen.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Directory path where results will be saved

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects for analysis

required
config dict

Configuration dictionary containing model parameters

required
Source code in evals/views/capacities.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def view_capacity_hydrogen_production(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate the optimal capacity for technologies that produce hydrogen.

    Parameters
    ----------
    result_path
        Directory path where results will be saved
    nc
        Dictionary containing PyPSA network objects for analysis
    config
        Configuration dictionary containing model parameters
    """
    simple_optimal_capacity(nc, config, result_path, kind="production")

view_demand_fed_sectoral(result_path, nc, config, subdir='evaluation')

Evaluate and export final energy demand (FED) disaggregated by sector.

This function calculates and exports final energy demand broken down by sector (Transport, Industry, Agriculture, HH & Service) with detailed energy carrier information. The output includes charts and Excel exports showing energy demand with sector-level disaggregation for comprehensive energy system analysis.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results (plots and data files) will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario. Each network should contain Load, Link, and Generator components with energy data.

required
config dict

Configuration dictionary containing view settings and chart specifications. Must include 'view' key with chart type and other plotting parameters.

required
subdir str | pathlib.Path

Subdirectory name within result_path where outputs will be saved.

'evaluation'
Notes

Uses _get_sectoral_fed() to calculate FED with detailed heat mix processing, distribution loss accounting, and sector aggregation. Results are exported with sector-level disaggregation to show how energy demand is distributed across different end-use sectors of the economy.

See Also

_get_sectoral_fed : Core calculation function for final energy demand view_demand_fed_total : Export FED aggregated across all sectors

Source code in evals/views/demand.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
def view_demand_fed_sectoral(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
    subdir: str | Path = "evaluation",
) -> None:
    """
    Evaluate and export final energy demand (FED) disaggregated by sector.

    This function calculates and exports final energy demand broken down by sector
    (Transport, Industry, Agriculture, HH & Service) with detailed energy carrier
    information. The output includes charts and Excel exports showing energy demand
    with sector-level disaggregation for comprehensive energy system analysis.

    Parameters
    ----------
    result_path
        Path where the evaluation results (plots and data files) will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
        Each network should contain Load, Link, and Generator components with energy data.
    config
        Configuration dictionary containing view settings and chart specifications.
        Must include 'view' key with chart type and other plotting parameters.
    subdir
        Subdirectory name within result_path where outputs will be saved.

    Notes
    -----
    Uses _get_sectoral_fed() to calculate FED with detailed heat mix processing,
    distribution loss accounting, and sector aggregation. Results are exported
    with sector-level disaggregation to show how energy demand is distributed across
    different end-use sectors of the economy.

    See Also
    --------
    _get_sectoral_fed : Core calculation function for final energy demand
    view_demand_fed_total : Export FED aggregated across all sectors
    """
    fed = _get_sectoral_fed(nc)
    exporter = Exporter(statistics=[fed], view_config=config["view"])
    exporter.export(result_path, subdir=subdir)

view_demand_fed_total(result_path, nc, config, subdir='evaluation')

Evaluate and export total final energy demand (FED) aggregated across all sectors.

This function calculates and exports final energy demand aggregated across transport, industry, agriculture, and household & service sectors. The output is organized by bus_carrier (heat bus types and energy carriers) to show the total energy demand across the entire energy system without sector-level disaggregation.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results (plots and data files) will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario. Each network should contain Load, Link, and Generator components with energy data.

required
config dict

Configuration dictionary containing view settings and chart specifications. Must include 'view' key with chart type and other plotting parameters.

required
subdir str | pathlib.Path

Subdirectory name within result_path where outputs will be saved.

'evaluation'
Notes

Uses _get_sectoral_fed() to calculate FED with detailed heat mix processing and distribution loss accounting. Results are exported with bus_carrier as the primary plot category, showing the total energy demand pattern across all carriers without sector-level breakdown.

See Also

_get_sectoral_fed : Core calculation function for final energy demand view_demand_fed_sectoral : Export FED with sector-level disaggregation

Source code in evals/views/demand.py
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
def view_demand_fed_total(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
    subdir: str | Path = "evaluation",
) -> None:
    """
    Evaluate and export total final energy demand (FED) aggregated across all sectors.

    This function calculates and exports final energy demand aggregated across transport,
    industry, agriculture, and household & service sectors. The output is organized by
    bus_carrier (heat bus types and energy carriers) to show the total energy demand
    across the entire energy system without sector-level disaggregation.

    Parameters
    ----------
    result_path
        Path where the evaluation results (plots and data files) will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
        Each network should contain Load, Link, and Generator components with energy data.
    config
        Configuration dictionary containing view settings and chart specifications.
        Must include 'view' key with chart type and other plotting parameters.
    subdir
        Subdirectory name within result_path where outputs will be saved.

    Notes
    -----
    Uses _get_sectoral_fed() to calculate FED with detailed heat mix processing and
    distribution loss accounting. Results are exported with bus_carrier as the primary
    plot category, showing the total energy demand pattern across all carriers without
    sector-level breakdown.

    See Also
    --------
    _get_sectoral_fed : Core calculation function for final energy demand
    view_demand_fed_sectoral : Export FED with sector-level disaggregation
    """
    fed = _get_sectoral_fed(nc)
    exporter = Exporter(statistics=[fed], view_config=config["view"])
    exporter.export(result_path, subdir=subdir)

view_demand_heat_system(result_path, nc, config, subdir='evaluation')

Evaluate and export heat system energy flows with carrier-focused visualization.

This function analyzes the complete heat system by combining energy input for heat production from Link components with direct heat generation from Generator components (specifically solar thermal). Unlike view_demand_heat(), this function organizes results by carrier rather than bus_carrier to provide insight into the energy sources feeding the heat system. Solar heat generation is specifically aggregated and labeled for clear identification in the output.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results (plots and data files) will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario. Each network should contain Link and Generator components with energy data.

required
config dict

Configuration dictionary containing view settings and chart specifications. Must include 'view' key with chart type and other plotting parameters.

required
subdir str | pathlib.Path

Subdirectory name within result_path where outputs will be saved.

'evaluation'
Notes

The function combines two data sources: 1. Energy input for heat production from Link components (from get_energy_for_heat_production) 2. Solar heat generation from Generator components, aggregated as "solar heat"

Key differences from view_demand_heat(): - Results organized by carrier (energy source) rather than bus_carrier (heat bus type) - Generator supply specifically renamed to "solar heat" for clarity - Index levels swapped to prioritize carrier information during visualization - Simplified chart configuration without specific pivot settings

This view is particularly useful for understanding the overall energy source mix feeding the heat system across all heat bus types.

Source code in evals/views/demand.py
 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
def view_demand_heat_system(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
    subdir: str | Path = "evaluation",
) -> None:
    """
    Evaluate and export heat system energy flows with carrier-focused visualization.

    This function analyzes the complete heat system by combining energy input for heat
    production from Link components with direct heat generation from Generator components
    (specifically solar thermal). Unlike view_demand_heat(), this function organizes
    results by carrier rather than bus_carrier to provide insight into the energy
    sources feeding the heat system. Solar heat generation is specifically aggregated
    and labeled for clear identification in the output.

    Parameters
    ----------
    result_path
        Path where the evaluation results (plots and data files) will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
        Each network should contain Link and Generator components with energy data.
    config
        Configuration dictionary containing view settings and chart specifications.
        Must include 'view' key with chart type and other plotting parameters.
    subdir
        Subdirectory name within result_path where outputs will be saved.

    Notes
    -----
    The function combines two data sources:
    1. Energy input for heat production from Link components (from get_energy_for_heat_production)
    2. Solar heat generation from Generator components, aggregated as "solar heat"

    Key differences from view_demand_heat():
    - Results organized by carrier (energy source) rather than bus_carrier (heat bus type)
    - Generator supply specifically renamed to "solar heat" for clarity
    - Index levels swapped to prioritize carrier information during visualization
    - Simplified chart configuration without specific pivot settings

    This view is particularly useful for understanding the overall energy source mix
    feeding the heat system across all heat bus types.
    """
    fed_for_heat = get_energy_for_heat_production(nc)
    # swap index levels to keep carrier information during plotting
    fed_for_heat = fed_for_heat.swaplevel(DataModel.CARRIER, DataModel.BUS_CARRIER)
    fed_for_heat.index.names = DataModel.YEAR_IDX_NAMES

    generator_supply = collect_myopic_statistics(
        nc,
        statistic="supply",
        comps="Generator",
        bus_carrier=BusCarrier.heat_buses(),
    ).pipe(rename_aggregate, "solar heat")

    exporter = Exporter(
        statistics=[fed_for_heat, generator_supply],
        view_config=config["view"],
    )

    exporter.export(result_path, subdir=subdir)

view_demand_heat_total(result_path, nc, config, subdir='evaluation')

Evaluate and export energy required for heat production and generation.

This function analyzes the energy input mix used for heat production by combining data from both link components (for heat production technologies like heat pumps, boilers) and generator components (for direct heat generation). Results are grouped by bus_carrier rather than carrier to show the input energy carrier mix for each type of heat bus. The output includes charts and Excel exports showing the energy balance for heat production across different heat technologies and carriers.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results (plots and data files) will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario. Each network should contain Link and Generator components with energy data.

required
config dict

Configuration dictionary containing view settings and chart specifications. Must include 'view' key with chart type and other plotting parameters.

required
subdir str | pathlib.Path

Subdirectory name within result_path where outputs will be saved.

'evaluation'
Notes

The function combines two data sources: 1. Energy input for heat production from Link components (from get_energy_for_heat_production) 2. Direct heat supply from Generator components connected to heat buses

The data is organized by bus_carrier (heat bus types) rather than the usual carrier grouping to provide insight into the energy mix feeding different heat systems (urban central, urban decentral, rural heat). Index levels are swapped between carrier and bus_carrier to facilitate plotting with the specified chart class.

Source code in evals/views/demand.py
24
25
26
27
28
29
30
31
32
33
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
def view_demand_heat_total(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
    subdir: str | Path = "evaluation",
) -> None:
    """
    Evaluate and export energy required for heat production and generation.

    This function analyzes the energy input mix used for heat production by combining
    data from both link components (for heat production technologies like heat pumps,
    boilers) and generator components (for direct heat generation). Results are grouped
    by bus_carrier rather than carrier to show the input energy carrier mix for each
    type of heat bus. The output includes charts and Excel exports showing the energy
    balance for heat production across different heat technologies and carriers.

    Parameters
    ----------
    result_path
        Path where the evaluation results (plots and data files) will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
        Each network should contain Link and Generator components with energy data.
    config
        Configuration dictionary containing view settings and chart specifications.
        Must include 'view' key with chart type and other plotting parameters.
    subdir
        Subdirectory name within result_path where outputs will be saved.

    Notes
    -----
    The function combines two data sources:
    1. Energy input for heat production from Link components (from get_energy_for_heat_production)
    2. Direct heat supply from Generator components connected to heat buses

    The data is organized by bus_carrier (heat bus types) rather than the usual carrier
    grouping to provide insight into the energy mix feeding different heat systems
    (urban central, urban decentral, rural heat). Index levels are swapped between
    carrier and bus_carrier to facilitate plotting with the specified chart class.
    """
    fed_for_heat = get_energy_for_heat_production(nc)

    generator_supply = collect_myopic_statistics(
        nc,
        statistic="supply",
        comps="Generator",
        bus_carrier=BusCarrier.heat_buses(),
    )
    # swap index levels to keep carrier information during plotting
    generator_supply = generator_supply.swaplevel(
        DataModel.CARRIER, DataModel.BUS_CARRIER
    )
    generator_supply.index.names = DataModel.YEAR_IDX_NAMES

    exporter = Exporter(
        statistics=[fed_for_heat, generator_supply],
        view_config=config["view"],
    )

    exporter.defaults.plot_category = DataModel.BUS_CARRIER
    exporter.defaults.pivot_index = [
        DataModel.YEAR,
        DataModel.LOCATION,
        DataModel.BUS_CARRIER,
    ]

    exporter.export(result_path, subdir=subdir)

view_sankey(result_path, nc, config)

Generate Sankey diagrams for energy flow visualization.

Creates comprehensive Sankey diagrams showing energy flows, including supply/demand balances, transmission losses, trade statistics, and regional energy exchanges. The function processes PyPSA network data to extract energy flows and exports them as interactive visualizations.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the generated Sankey diagrams and data will be saved.

required
nc pypsa.NetworkCollection

Dictionary of PyPSA network objects containing the energy system data to be analyzed and visualized.

required
config dict

Configuration dictionary containing view settings, chart specifications, transmission components to exclude, and export parameters.

required

Returns:

Type Description
None

Exports Sankey diagrams and underlying energy flow data to the specified result path. Generated files include interactive Plotly visualizations and CSV data files containing the processed statistics.

Notes

The function processes several types of energy flows: - Supply and demand statistics (excluding transmission components) - Grid losses from electricity distribution - Trade statistics (foreign and domestic imports/exports) - Link losses and conversion inefficiencies - Regional trade balances for specific carriers (oil, coal, lignite, NH3)

All statistics are aggregated by year, component, location, and carrier.

Source code in evals/views/sankey.py
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
def view_sankey(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Generate Sankey diagrams for energy flow visualization.

    Creates comprehensive Sankey diagrams showing energy flows, including supply/demand
    balances, transmission losses, trade statistics, and regional energy exchanges.
    The function processes PyPSA network data to extract energy flows and exports
    them as interactive visualizations.

    Parameters
    ----------
    result_path
        Path where the generated Sankey diagrams and data will be saved.
    nc
        Dictionary of PyPSA network objects containing the energy system data
        to be analyzed and visualized.
    config
        Configuration dictionary containing view settings, chart specifications,
        transmission components to exclude, and export parameters.

    Returns
    -------
    :
        Exports Sankey diagrams and underlying energy flow data to the specified
        result path. Generated files include interactive Plotly visualizations
        and CSV data files containing the processed statistics.

    Notes
    -----
    The function processes several types of energy flows:
    - Supply and demand statistics (excluding transmission components)
    - Grid losses from electricity distribution
    - Trade statistics (foreign and domestic imports/exports)
    - Link losses and conversion inefficiencies
    - Regional trade balances for specific carriers (oil, coal, lignite, NH3)

    All statistics are aggregated by year, component, location, and carrier.
    """
    (
        _,
        transmission_comps,
        transmission_carrier,
        _,
        _,
    ) = _parse_view_config_items(nc, config)

    supply = get_supply(nc, transmission_comps, transmission_carrier)
    demand = get_demand(
        nc, transmission_comps, transmission_carrier, unit=supply.attrs["unit"]
    )

    grid_losses = net_distribution_grid_losses(supply, demand)
    trade_statistics = get_trade_statistics(
        nc, transmission_comps, transmission_carrier, unit=supply.attrs["unit"]
    )
    link_losses = get_link_losses(supply, demand)

    regional_trade = [
        regionalize_statistics(supply, demand, bus_carrier)
        for bus_carrier in BusCarrier.eu_buses()
    ]

    exporter = Exporter(
        statistics=[
            supply,
            demand,
            grid_losses,
        ]
        + trade_statistics
        + regional_trade
        + link_losses,
        view_config=config["view"],
    )

    exporter.defaults.xaxis_title = ""
    exporter.defaults.plotby = [DM.YEAR, DM.LOCATION]
    exporter.defaults.pivot_index = [
        DM.COMPONENT,
        DM.YEAR,
        DM.LOCATION,
        DM.CARRIER,
        DM.BUS_CARRIER,
    ]
    exporter.export(result_path, config["global"]["subdir"])

view_timeseries_carbon(result_path, nc, config)

Evaluate and export time series data for carbon emissions, capture, and sequestration.

This function generates hourly or sub-hourly time series showing CO2 emissions from combustion processes (power plants, boilers, industry), CO2 capture from direct air capture and carbon capture systems, and CO2 sequestration or storage. The temporal resolution enables analysis of emission patterns, the operation of carbon capture facilities, and the timing of CO2 storage operations. The function delegates to simple_timeseries for data collection and export.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, storage_links, chart type, and export parameters.

required
Notes

Time series data reveals the temporal patterns of CO2 emissions and the operation of carbon management infrastructure. It shows how emissions vary with electricity and heat demand, and how carbon capture facilities operate to manage system-wide emissions constraints.

Source code in evals/views/balances_timeseries.py
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
def view_timeseries_carbon(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export time series data for carbon emissions, capture, and sequestration.

    This function generates hourly or sub-hourly time series showing CO2 emissions from
    combustion processes (power plants, boilers, industry), CO2 capture from direct air
    capture and carbon capture systems, and CO2 sequestration or storage. The temporal
    resolution enables analysis of emission patterns, the operation of carbon capture
    facilities, and the timing of CO2 storage operations. The function delegates to
    simple_timeseries for data collection and export.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        storage_links, chart type, and export parameters.

    Notes
    -----
    Time series data reveals the temporal patterns of CO2 emissions and the operation
    of carbon management infrastructure. It shows how emissions vary with electricity
    and heat demand, and how carbon capture facilities operate to manage system-wide
    emissions constraints.
    """
    simple_timeseries(nc, config, result_path)

view_timeseries_electricity(result_path, nc, config)

Evaluate and export time series data for electricity supply, demand, and trade.

This function generates hourly or sub-hourly time series showing electricity production from various sources (renewables, thermal plants, storage) and consumption across different sectors (industry, transport, heat, electrolysis). It preserves temporal resolution to enable analysis of system operation patterns, peak demand, and renewable generation variability. The function delegates to simple_timeseries for data collection and export.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, storage_links, chart type, and export parameters.

required
Notes

Time series data is useful for analyzing hourly patterns, ramping requirements, storage cycling, and the integration of variable renewable energy sources. Net trade combines foreign and domestic imports/exports into a single saldo value.

Source code in evals/views/balances_timeseries.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def view_timeseries_electricity(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export time series data for electricity supply, demand, and trade.

    This function generates hourly or sub-hourly time series showing electricity production
    from various sources (renewables, thermal plants, storage) and consumption across
    different sectors (industry, transport, heat, electrolysis). It preserves temporal
    resolution to enable analysis of system operation patterns, peak demand, and renewable
    generation variability. The function delegates to simple_timeseries for data collection
    and export.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        storage_links, chart type, and export parameters.

    Notes
    -----
    Time series data is useful for analyzing hourly patterns, ramping requirements,
    storage cycling, and the integration of variable renewable energy sources.
    Net trade combines foreign and domestic imports/exports into a single saldo value.
    """
    simple_timeseries(nc, config, result_path)

view_timeseries_hydrogen(result_path, nc, config)

Evaluate and export time series data for hydrogen supply, demand, and trade.

This function generates hourly or sub-hourly time series showing hydrogen production from electrolysis, steam methane reforming, and other sources, along with hydrogen consumption in fuel cells, industrial processes, synthetic fuel production, and other applications. The temporal resolution enables analysis of hydrogen system operation, including electrolyzer operation patterns, storage cycling, and the coupling between electricity and hydrogen systems. The function delegates to simple_timeseries for data collection and export.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, storage_links, chart type, and export parameters.

required
Notes

Time series data reveals the coupling between hydrogen and electricity sectors, particularly the role of electrolyzers in providing demand flexibility and the operation of hydrogen storage for seasonal energy shifting.

Source code in evals/views/balances_timeseries.py
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
def view_timeseries_hydrogen(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export time series data for hydrogen supply, demand, and trade.

    This function generates hourly or sub-hourly time series showing hydrogen production
    from electrolysis, steam methane reforming, and other sources, along with hydrogen
    consumption in fuel cells, industrial processes, synthetic fuel production, and other
    applications. The temporal resolution enables analysis of hydrogen system operation,
    including electrolyzer operation patterns, storage cycling, and the coupling between
    electricity and hydrogen systems. The function delegates to simple_timeseries for
    data collection and export.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        storage_links, chart type, and export parameters.

    Notes
    -----
    Time series data reveals the coupling between hydrogen and electricity sectors,
    particularly the role of electrolyzers in providing demand flexibility and the
    operation of hydrogen storage for seasonal energy shifting.
    """
    simple_timeseries(nc, config, result_path)

view_timeseries_methane(result_path, nc, config)

Evaluate and export time series data for methane supply, demand, and trade.

This function generates hourly or sub-hourly time series showing methane (natural gas) supply from production, imports, biogas upgrading, and methanation processes, along with methane consumption in gas boilers, combined heat and power plants, gas turbines, steam methane reforming, and industrial applications. The temporal resolution enables analysis of gas system operation, storage cycling, and the seasonal patterns of gas demand for heating. The function delegates to simple_timeseries for data collection and export.

Parameters:

Name Type Description Default
result_path str | pathlib.Path

Path where the evaluation results will be saved.

required
nc pypsa.NetworkCollection

Dictionary containing PyPSA network objects, typically keyed by year or scenario.

required
config dict

Configuration dictionary containing view settings including bus_carrier specification, storage_links, chart type, and export parameters.

required
Notes

Time series data shows the seasonal nature of gas demand, particularly for heating, and the role of gas storage in balancing supply and demand. It also reveals the transition from fossil natural gas to renewable and synthetic methane sources.

Source code in evals/views/balances_timeseries.py
 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
def view_timeseries_methane(
    result_path: str | Path,
    nc: NetworkCollection,
    config: dict,
) -> None:
    """
    Evaluate and export time series data for methane supply, demand, and trade.

    This function generates hourly or sub-hourly time series showing methane (natural gas)
    supply from production, imports, biogas upgrading, and methanation processes, along
    with methane consumption in gas boilers, combined heat and power plants, gas turbines,
    steam methane reforming, and industrial applications. The temporal resolution enables
    analysis of gas system operation, storage cycling, and the seasonal patterns of gas
    demand for heating. The function delegates to simple_timeseries for data collection
    and export.

    Parameters
    ----------
    result_path
        Path where the evaluation results will be saved.
    nc
        Dictionary containing PyPSA network objects, typically keyed by year or scenario.
    config
        Configuration dictionary containing view settings including bus_carrier specification,
        storage_links, chart type, and export parameters.

    Notes
    -----
    Time series data shows the seasonal nature of gas demand, particularly for heating,
    and the role of gas storage in balancing supply and demand. It also reveals the
    transition from fossil natural gas to renewable and synthetic methane sources.
    """
    simple_timeseries(nc, config, result_path)